123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- using DragonBones;
- 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 Transform = UnityEngine.Transform;
- public class ManaPlayer : Regist
- {
- #region 变量
- 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 ManaPlayer Instance;
- public static List<int>BoughtCloseList = new List<int>();
- public static List<string> DressData = new List<string>();
- public static Dictionary<int, CloseUnit> CloseUnitDic = new Dictionary<int, CloseUnit>();
- public static Dictionary<string, int> CloseIDDic = new Dictionary<string, int>();
- public static Dictionary<string, Sprite> CloseSpriteDic = new Dictionary<string, Sprite>();
- #endregion
- public override void Instantiate()
- {
- #region Player
- if (!Complete)
- {
- UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("stand_ske", Folder.Config));
- UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("Closet_ske", Folder.Config));
- UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("stand_tex", Folder.Config), "stand_texture");
- UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("Closet_tex", Folder.Config), "Closet_texture");
- Complete = true;
- }
- if (!ManaTutorial.TutorialA || ManaTutorial.TutorialIndexA != 1)
- {
- GetPlayer();
- DressData = ManaData.GetDressData();
- }
- else
- {
- PlayerPink = ManaReso.Get("Player", Folder.Scene, false, ManaReso.Get("PlayerPos3"), false, ObjType.Player);
- PlayerBlond = ManaReso.Get("Player", Folder.Scene, false, ManaReso.Get("PlayerPos2"), false, ObjType.Player);
- PlayerBrown = ManaReso.Get("Player", Folder.Scene, false, ManaReso.Get("PlayerPos1"), 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();
- }
- 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
- #region Close
- List<List<TextureAtlasData>> textureAtlasDatalist = UnityFactory.factory.GetAllTextureAtlasData().Values.ToList();
- for (int i = 0; i < textureAtlasDatalist.Count; i++)
- {
- for (int j = 0; j < textureAtlasDatalist[i].Count; j++)
- {
- TextureAtlasData textureAtlasData = textureAtlasDatalist[i][j];
- string textureName = textureAtlasData.imagePath.Split('.')[0] + "ture";
- foreach (var kv in textureAtlasData.textures)
- {
- Texture2D texture2D = UnityFactory.AtlasDictionary[textureName];
- Rect rect = new Rect(kv.Value.region.x, texture2D.height - kv.Value.region.y - kv.Value.region.height, kv.Value.region.width, kv.Value.region.height);
- Sprite sprite = Sprite.Create(texture2D, rect, new Vector2(0.5f, 0.5f));
- sprite.name = kv.Value.name;
- CloseSpriteDic.Add(sprite.name, sprite);
- }
- }
- }
- #endregion
- DressRoom = ManaReso.Get("DressRoom", Folder.Discard, true, null, true, ObjType.DressRoom);
- List<XmlAttributeCollection> attributeList = ManaData.GetDressRoomConfig();
- Player.JumpFrequency = float.Parse(attributeList[0][1].Value);
- for (int i = 1; i < attributeList.Count; i++)
- {
- new CloseUnit(attributeList[i]);
- }
- List<int> dressList = ManaData.GetDressList();
- for (int i = 0; i < dressList.Count; i++)
- {
- BoughtCloseList.Add(dressList[i]);
- CloseUnitDic[dressList[i]].Unlock();
- }
- #endregion
- }
- public override void RegistValueA()
- {
- Instance = this;
- ManaReso.Get("DressRoom").CreateTweenSr(0, 1, 0.25f, false, true, Curve.EaseOutQuad);
- }
- public Player GetPlayer(string type = null, XmlNode xmlNode = null)
- {
- List<string> DressData = new List<string>();
- if (type == null && xmlNode == null)
- {
- DressData = ManaData.GetDressData();
- }
- else
- {
- if (type == null)
- {
- DressData = ManaData.GetDressData(xmlNode);
- }
- else
- {
- if (type == "PlayerBlond")
- {
- DressData.Add("脑壳1");
- DressData.Add("裙子1");
- DressData.Add("鞋子1");
- DressData.Add("头饰品1");
- DressData.Add("上衣1");
- DressData.Add("眼睛1");
- DressData.Add("嘴巴1");
- }
- else if (type == "PlayerBrown")
- {
- DressData.Add("脑壳2");
- DressData.Add("裙子2");
- DressData.Add("鞋子2");
- DressData.Add("头饰品2");
- DressData.Add("上衣2");
- DressData.Add("眼睛2");
- DressData.Add("嘴巴2");
- }
- else if (type == "PlayerPink")
- {
- DressData.Add("脑壳3");
- DressData.Add("裙子3");
- DressData.Add("鞋子3");
- DressData.Add("头饰品3");
- DressData.Add("上衣3");
- DressData.Add("眼睛3");
- DressData.Add("嘴巴3");
- }
- }
- }
- Transform tra = ManaReso.Get("Player", Folder.Scene, false, transform, ManaReso.Get("PlayerPosTra").position, ObjType.Player);
- Player = tra.GetComponent<Player>();
- if (Player == null)
- {
- Player = tra.AddScript<Player>();
- Player.BuildBlond();
- }
-
- BuildPlayer(DressData);
- Player.SetAllCollider(true);
- tra.localScale = new Vector3(0.5f, 0.5f, 0.5f);
- ManaReso.TraDic.Add(tra.name, tra);
- return Player;
- }
- public static void BuildPlayer(List<string> dressData)
- {
- 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]);
- }
- }
|