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 ListBoughtCloseList = new List(); public static List DressData = new List(); public static Dictionary CloseItemDic = new Dictionary(); public static Dictionary CloseIDDic = new Dictionary(); public static Dictionary CloseSpriteDic = new Dictionary(); #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(ResourceLabel.StandSke, Folder.Config)); Initializer.DebugLab.text = "error : mp0-2"; UnityFactory.factory.LoadTextureAtlasData(ResourceManager.Load(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("PlayerPos3"), false, ObjType.Player); PlayerBlond = ResourceManager.Get(ResourceLabel.Player, Folder.Scene, false, ResourceManager.Get("PlayerPos2"), false, ObjType.Player); PlayerBrown = ResourceManager.Get(ResourceLabel.Player, Folder.Scene, false, ResourceManager.Get("PlayerPos1"), false, ObjType.Player); if (PlayerPink.GetComponent() == null) { PlayerPink.AddScript().BuildPink(); //PlayerPink.transform.position = ManaReso.Get("PlayerPos3").position; } if (PlayerBlond.GetComponent() == null) { PlayerBlond.AddScript().BuildBlond(); //PlayerPink.transform.position = ManaReso.Get("PlayerPos2").position; } if (PlayerBrown.GetComponent() == null) { PlayerBrown.AddScript().BuildBrown(); //PlayerPink.transform.position = ManaReso.Get("PlayerPos1").position; } PlayerPink.localScale = new Vector3(0.8f, 0.8f, 0.8f); PlayerBlond.localScale = new Vector3(0.8f, 0.8f, 0.8f); PlayerBrown.localScale = new Vector3(0.8f, 0.8f, 0.8f); SeleTra = PlayerBlond; } #endregion #region DressRoom Initializer.DebugLab.text = "error : mp2"; List 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 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 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 DressData = new List(); 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("GardenNormal")); Player = tra.GetComponent(); if (Player == null) { Player = tra.AddScript(); Player.Build(); } BuildPlayer(DressData); Player.SetAllCollider(true); Player.Flip(PlayerDirection.Left); Player.transform.position = ResourceManager.Get("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 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]); } }