123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- 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 string SelePlayer = "PlayerBlond";
- 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 Dictionary<string, Sprite> CloseDic = 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)
- {
- SelePlayer = ManaData.GetPlayerString("Player");
- GetPlayer();
- }
- else
- {
- PlayerPink = ManaReso.Get("Player", Folder.Scene, false, ManaReso.Get("PlayerPos3"), false, ObjType.PlayerPink);
- PlayerBlond = ManaReso.Get("Player", Folder.Scene, false, ManaReso.Get("PlayerPos2"), false, ObjType.PlayerBlond);
- PlayerBrown = ManaReso.Get("Player", Folder.Scene, false, ManaReso.Get("PlayerPos1"), false, ObjType.PlayerBrown);
- 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);
- SelePlayer = "PlayerBlond";
- 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;
- CloseDic.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]);
- }
- #endregion
- }
- public override void RegistValueA()
- {
- Instance = this;
- ManaReso.Get("DressRoom").CreateTweenSr(0, 1, 0.25f, false, true, Curve.EaseOutQuad);
- }
- public void GetPlayer(string type = null)
- {
- string player;
- if (type == null)
- {
- player = ManaData.GetPlayerString("Player");
- }
- else
- {
- player = type;
- }
- Transform tra = ManaReso.Get("Player", Folder.Scene, false, transform, ManaReso.Get("PlayerPosTra").position, player.ToEnum<ObjType>());
- Player = tra.GetComponent<Player>();
- if (Player == null)
- {
- Player = tra.AddScript<Player>();
- if (player == "PlayerPink")
- {
- Player.BuildPink();
- }
- else if (player == "PlayerBlond")
- {
- Player.BuildBlond();
- }
- else if (player == "PlayerBrown")
- {
- Player.BuildBrown();
- }
- }
- Player.SetAllCollider(true);
- tra.localScale = new Vector3(0.5f, 0.5f, 0.5f);
- ManaReso.TraDic.Add(tra.name, tra);
- }
- }
|