using DragonBones; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; using System; using System.Xml; using System.Linq; using System.Collections; using System.Collections.Generic; using Slot = DragonBones.Slot; using Random = UnityEngine.Random; using Transform = UnityEngine.Transform; public enum BodyPart { Eye, Top, Shoe, Head, Dress, Mouse, Headwear, } public class CloseUnit { public enum CloseType { Top, Hair, Wing, Dress, Decarator, } #region Var public string Description { get { return Language.GetStr("DressRoom", CloseName); } } public int ID; public int Index; public int BuyLevel; public int PixelSize; public bool Bought; public string CloseName; public Text BuyBtnLab; public Sprite Sprite; public Image Icon; public Button BuyBtn; public Button DressBtn; public BodyPart BodyPart; public Transform Transform; public CloseType Type; public double BuyAmt; public double BuyAdvanceAmt; public Current BuyCurrent; public Current BuyAdvanceCurrent; public Dictionary ChildDic = new Dictionary(); #endregion public CloseUnit(XmlAttributeCollection attribute) { ID = Auxiliary.IntParse(attribute[0].Value, -1); CloseName = attribute[2].Value; Sprite = SpriteParse(attribute[2].Value); Type = TypeParse(attribute[3].Value); Index = Auxiliary.IntParse(attribute[4].Value, -1); BodyPart = BodyPartParse(attribute[5].Value); BuyLevel = Auxiliary.IntParse(attribute[6].Value, 0); BuyCurrent = Auxiliary.CurrentParse(attribute[7].Value); BuyAmt = Auxiliary.DoubleParse(attribute[8].Value, 0); BuyAdvanceCurrent = Auxiliary.CurrentParse(attribute[9].Value); BuyAdvanceAmt = Auxiliary.DoubleParse(attribute[10].Value, 0); PixelSize = Auxiliary.IntParse(attribute[11].Value, 100); ManaPlayer.CloseIDDic.Add(CloseName, ID); ManaPlayer.CloseUnitDic.Add(ID, this); CreateItem(); } protected void CreateItem() { Transform = ManaReso.Get("CloseItem", Folder.UI, false, ManaReso.Get("Canvas"), false); if (Type == CloseType.Top) { Transform.SetParent(ManaReso.Get("Pb_TopGrid")); } else if (Type == CloseType.Hair) { Transform.SetParent(ManaReso.Get("Pa_HairGrid")); } else if (Type == CloseType.Dress) { Transform.SetParent(ManaReso.Get("Pc_DressGrid")); } else if (Type == CloseType.Wing) { Transform.SetParent(ManaReso.Get("Pe_WingGrid")); } else if (Type == CloseType.Decarator) { Transform.SetParent(ManaReso.Get("Pd_DecaratorGrid")); } else { throw new Exception(); } Transform.SetSiblingIndex(Index); Auxiliary.CompileDic(Transform, ChildDic); Icon = ChildDic["Icon"].GetComponent(); DressBtn = ChildDic["CloseItem"].GetComponent