123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- 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 Inited;
- public static Player Player;
- public static Transform DressRoom;
- public static Transform DefaultPinkPlayer;
- public static Transform DefaultBlondPlayer;
- public static Transform DefaultBrownPlayer;
- public static Transform SelectedPlayer;
- public static PlayerManager Instance;
- public static List<int>BoughtCloseIDs = new List<int>();
- public static List<string> DressDatas = new List<string>();
- public static Dictionary<int, CloseItem> CloseItemDictionary = new Dictionary<int, CloseItem>();
- public static Dictionary<string, int> CloseIDDictionary = new Dictionary<string, int>();
- public static Dictionary<string, Sprite> CloseSpriteDictionary = new Dictionary<string, Sprite>();
- #endregion
- public override void InstantiatePrefabs()
- {
- #region Player
- Initializer.DebugText.text = "error : mp0";
- if (!Inited)
- {
- Initializer.DebugText.text = "error : mp0-1";
- UnityFactory.factory.LoadDragonBonesData(ResourceManager.Load<TextAsset>(ResourceLabel.StandSke, Folder.Config));
- Initializer.DebugText.text = "error : mp0-2";
- UnityFactory.factory.LoadTextureAtlasData(ResourceManager.Load<TextAsset>(ResourceLabel.StandTex, Folder.Config), ResourceLabel.StandTexture);
- Inited = true;
- }
- Initializer.DebugText.text = "error : mp1";
- if (!TutorialManager.NewplayerTutorial || TutorialManager.NewplayerTutorialIndex != 1)
- {
- GetPlayer();
- DressDatas = ConfigManager.GetDressData();
- }
- else
- {
- DefaultPinkPlayer = ResourceManager.Get(ResourceLabel.Player, Folder.Scene, false, ResourceManager.Get(TutorialLabel.PinkPlayerPos), false, ObjType.Player);
- DefaultBlondPlayer = ResourceManager.Get(ResourceLabel.Player, Folder.Scene, false, ResourceManager.Get(TutorialLabel.BlondPlayerPos), false, ObjType.Player);
- DefaultBrownPlayer = ResourceManager.Get(ResourceLabel.Player, Folder.Scene, false, ResourceManager.Get(TutorialLabel.BrownPlayerPos), false, ObjType.Player);
-
- if (DefaultPinkPlayer.GetComponent<Player>() == null)
- {
- DefaultPinkPlayer.AddScript<Player>().BuildPink();
- }
- if (DefaultBlondPlayer.GetComponent<Player>() == null)
- {
- DefaultBlondPlayer.AddScript<Player>().BuildBlond();
- }
- if (DefaultBrownPlayer.GetComponent<Player>() == null)
- {
- DefaultBrownPlayer.AddScript<Player>().BuildBrown();
- }
- Vector3 tutorialPlayerScale = new Vector3(0.8f, 0.8f, 0.8f);
- DefaultPinkPlayer.localScale = tutorialPlayerScale;
- DefaultBlondPlayer.localScale = tutorialPlayerScale;
- DefaultBrownPlayer.localScale = tutorialPlayerScale;
- SelectedPlayer = DefaultBlondPlayer;
- }
- #endregion
- #region DressRoom
- Initializer.DebugText.text = "error : mp2";
- List<XmlAttributeCollection> attributeList = ConfigManager.GetDressRoomConfig();
- Player.InDressRoomJumpFrequency = float.Parse(attributeList[0][1].Value);
- Initializer.DebugText.text = "error : mp3";
- DressRoom = ResourceManager.Get(ResourceLabel.DressRoom, Folder.UI, true, null, true, ObjType.DressRoom);
- DressRoom.SetActive(false);
- DontDestroyOnLoad(DressRoom);
- Initializer.DebugText.text = "error : mp4";
- List<int> dressList = ConfigManager.GetDressList();
- Initializer.DebugText.text = "error : mp5";
- for (int i = 0; i < dressList.Count; i++)
- {
- BoughtCloseIDs.Add(dressList[i]);
- }
- #endregion
- }
- public override void FirstInit()
- {
- Instance = this;
- ResourceManager.Get(ResourceLabel.DressRoom).CreateTweenSr(0, 1, 0.25f, false, true, Curve.EaseOutQuad);
- }
- 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.GardenPivot));
- 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.GardenPlayerPos).position;
- tra.localScale = new Vector3(0.5f, 0.5f, 0.5f);
- ResourceManager.TransformDictionary.Add(tra.name, tra);
- return Player;
- }
- public Player GetRawPlayer()
- {
- Transform trans = ResourceManager.Get(ResourceLabel.Player, Folder.Scene, false, null, false, ObjType.Player);
- var player = trans.GetComponent<Player>();
- if (player == null)
- {
- player = trans.AddScript<Player>();
- player.BuildBlond();
- }
- //BuildPlayer(dressData, player, false);
- return player;
- }
- public static void BuildPlayer(List<string> dressData, Player player = null, bool resetDepth = true)
- {
- if (player == null)
- {
- player = Player;
- }
- player.ChangeClose(BodyPart.Head, dressData[0], resetDepth);
- player.ChangeClose(BodyPart.Dress, dressData[1], resetDepth);
- player.ChangeClose(BodyPart.Shoe, dressData[2], resetDepth);
- player.ChangeClose(BodyPart.Headwear, dressData[3], resetDepth);
- player.ChangeClose(BodyPart.Top, dressData[4], resetDepth);
- player.ChangeClose(BodyPart.Eye, dressData[5], resetDepth);
- player.ChangeClose(BodyPart.Mouse, dressData[6], resetDepth);
- player.ChangeClose(BodyPart.Wing, dressData[7], resetDepth);
- player.ChangeClose(BodyPart.LeftLongSleeve, dressData[8], resetDepth);
- player.ChangeClose(BodyPart.LeftShortSleeve, dressData[9], resetDepth);
- player.ChangeClose(BodyPart.RightLongSleeve, dressData[10], resetDepth);
- player.ChangeClose(BodyPart.RightShortSleeve, dressData[11], resetDepth);
- }
- public static void InitDressRoom()
- {
- List<XmlAttributeCollection> attributeList = ConfigManager.GetDressRoomConfig();
- for (int i = 1; i < attributeList.Count; i++)
- {
- new CloseItem(attributeList[i]);
- }
- for (int i = 0; i < BoughtCloseIDs.Count; i++)
- {
- //Debug.Log(BoughtCloseList[i]);
- CloseItemDictionary[BoughtCloseIDs[i]].Unlock();
- }
- }
- }
|