123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- using DragonBones;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- using UnityEngine;
- using UnityEngine.UI;
- using System;
- using System.Xml;
- using System.Text;
- using System.Linq;
- using System.Collections;
- using System.Diagnostics;
- using System.Collections.Generic;
- using Debug = UnityEngine.Debug;
- using Object = UnityEngine.Object;
- using Transform = UnityEngine.Transform;
- public class PlayerManager : Regist
- {
- #region Config
- public static bool Complete;
- public static Transform SeleTra;
- public static Player Player;
- public static Transform DressRoom;
- public static Transform PlayerPink;
- public static Transform PlayerBlond;
- public static Transform PlayerBrown;
- public static PlayerManager Instance;
- public static List<int>BoughtCloseList = new List<int>();
- public static List<string> DressData = new List<string>();
- public static Dictionary<int, CloseItem> CloseItemDic = new Dictionary<int, CloseItem>();
- public static Dictionary<string, int> CloseIDDic = new Dictionary<string, int>();
- public static Dictionary<string, Sprite> CloseSpriteDic = new Dictionary<string, Sprite>();
- #endregion
- public override void InstantiatePrefabs()
- {
- #region Player
- Initializer.DebugLab.text = "error : mp0";
- if (!Complete)
- {
- Initializer.DebugLab.text = "error : mp0-1";
- UnityFactory.factory.LoadDragonBonesData(ResourceManager.Load<TextAsset>(ResourceLabel.StandSke, Folder.Config));
- Initializer.DebugLab.text = "error : mp0-2";
- UnityFactory.factory.LoadTextureAtlasData(ResourceManager.Load<TextAsset>(ResourceLabel.StandTex, Folder.Config), ResourceLabel.StandTexture);
- Complete = true;
- }
- Initializer.DebugLab.text = "error : mp1";
- if (!TutorialManager.NewplayerTutorial || TutorialManager.NewplayerTutorialIndex != 1)
- {
- GetPlayer();
- DressData = ConfigManager.GetDressData();
- }
- else
- {
- PlayerPink = ResourceManager.Get(ResourceLabel.Player, Folder.Scene, false, ResourceManager.Get(TutorialLabel.PinkPlayerPos), false, ObjType.Player);
- PlayerBlond = ResourceManager.Get(ResourceLabel.Player, Folder.Scene, false, ResourceManager.Get(TutorialLabel.BlondPlayerPos), false, ObjType.Player);
- PlayerBrown = ResourceManager.Get(ResourceLabel.Player, Folder.Scene, false, ResourceManager.Get(TutorialLabel.BrownPlayerPos), false, ObjType.Player);
-
- if (PlayerPink.GetComponent<Player>() == null)
- {
- PlayerPink.AddScript<Player>().BuildPink();
- }
- if (PlayerBlond.GetComponent<Player>() == null)
- {
- PlayerBlond.AddScript<Player>().BuildBlond();
- }
- if (PlayerBrown.GetComponent<Player>() == null)
- {
- PlayerBrown.AddScript<Player>().BuildBrown();
- }
- Vector3 tutorialPlayerScale = new Vector3(0.8f, 0.8f, 0.8f);
- PlayerPink.localScale = tutorialPlayerScale;
- PlayerBlond.localScale = tutorialPlayerScale;
- PlayerBrown.localScale = tutorialPlayerScale;
- SeleTra = PlayerBlond;
- }
- #endregion
- #region DressRoom
- Initializer.DebugLab.text = "error : mp2";
- List<XmlAttributeCollection> attributeList = ConfigManager.GetDressRoomConfig();
- Player.JumpFrequency = float.Parse(attributeList[0][1].Value);
- Initializer.DebugLab.text = "error : mp3";
- DressRoom = ResourceManager.Get(ResourceLabel.DressRoom, Folder.Scene, true, null, true, ObjType.DressRoom);
- DressRoom.SetActive(false);
- DontDestroyOnLoad(DressRoom);
- Initializer.DebugLab.text = "error : mp4";
- List<int> dressList = ConfigManager.GetDressList();
- Initializer.DebugLab.text = "error : mp5";
- for (int i = 0; i < dressList.Count; i++)
- {
- BoughtCloseList.Add(dressList[i]);
- }
- #endregion
- }
- public override void FirstInit()
- {
- Instance = this;
- ResourceManager.Get(ResourceLabel.DressRoom).CreateTweenSr(0, 1, 0.25f, false, true, Curve.EaseOutQuad);
- }
- public static void InitializeDressRoom()
- {
- List<XmlAttributeCollection> attributeList = ConfigManager.GetDressRoomConfig();
- for (int i = 1; i < attributeList.Count; i++)
- {
- new CloseItem(attributeList[i]);
- }
- for (int i = 0; i < BoughtCloseList.Count; i++)
- {
- //Debug.Log(BoughtCloseList[i]);
- CloseItemDic[BoughtCloseList[i]].Unlock();
- }
- }
- public Player GetPlayer(XmlNode xmlNode = null)
- {
- List<string> DressData = new List<string>();
- if (xmlNode == null)
- {
- DressData = ConfigManager.GetDressData();
- }
- else
- {
- DressData = ConfigManager.GetDressData(xmlNode);
- }
- Transform tra = ResourceManager.Get(ResourceLabel.Player, Folder.Scene, false, transform, false, ObjType.Player);
- tra.SetParent(ResourceManager.Get(GardenLabel.GardenNormal));
- Player = tra.GetComponent<Player>();
- if (Player == null)
- {
- Player = tra.AddScript<Player>();
- Player.Build();
- }
- BuildPlayer(DressData);
- Player.SetAllCollider(true);
- Player.Flip(PlayerDirection.Left);
- Player.transform.position = ResourceManager.Get(GardenLabel.PlayerPosTra).position;
- tra.localScale = new Vector3(0.5f, 0.5f, 0.5f);
- ResourceManager.TraDic.Add(tra.name, tra);
- return Player;
- }
- public static void BuildPlayer(List<string> dressData, Player player = null)
- {
- if (player == null)
- {
- player = Player;
- }
- player.ChangeClose(BodyPart.Head, dressData[0]);
- player.ChangeClose(BodyPart.Dress, dressData[1]);
- player.ChangeClose(BodyPart.Shoe, dressData[2]);
- player.ChangeClose(BodyPart.Headwear, dressData[3]);
- player.ChangeClose(BodyPart.Top, dressData[4]);
- player.ChangeClose(BodyPart.Eye, dressData[5]);
- player.ChangeClose(BodyPart.Mouse, dressData[6]);
- player.ChangeClose(BodyPart.Wing, dressData[7]);
- player.ChangeClose(BodyPart.LeftLongSleeve, dressData[8]);
- player.ChangeClose(BodyPart.LeftShortSleeve, dressData[9]);
- player.ChangeClose(BodyPart.RightLongSleeve, dressData[10]);
- player.ChangeClose(BodyPart.RightShortSleeve, dressData[11]);
- }
- }
|