Player.cs 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900
  1. using DragonBones;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using UnityEngine.EventSystems;
  5. using System;
  6. using System.Xml;
  7. using System.Linq;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using Animation = DragonBones.Animation;
  11. using Slot = DragonBones.Slot;
  12. using Random = UnityEngine.Random;
  13. using Transform = UnityEngine.Transform;
  14. public class PlayerLabel
  15. {
  16. public static string MessageBox = "MessageBox";
  17. public static string NickName = "NickName";
  18. public static string Pivot = "Pivot";
  19. public static string Shadow = "Shadow";
  20. public static string ExpressionMeshFilter = "ExpressionMeshFilter";
  21. public static string ShadowParent = "ShadowParent";
  22. public static string Player = "Player";
  23. public static string RightPos = "RightPos";
  24. public static string LeftPos = "LeftPos";
  25. public static string EnterGameTra = "EnterGameTra";
  26. }
  27. public enum BodyPart
  28. {
  29. Leg = 0,
  30. LeftHand = 1,
  31. RightHand = 2,
  32. LeftLongSleeve = 3,
  33. LeftShortSleeve = 4,
  34. RightLongSleeve = 5,
  35. RightShortSleeve = 6,
  36. Neck = 7,
  37. Eye = 8,
  38. Top = 9,
  39. Shoe = 10,
  40. Head = 11,
  41. Wing = 12,
  42. Dress = 13,
  43. Mouse = 14,
  44. Headwear = 15,
  45. }
  46. public class ExchangeInfo
  47. {
  48. public float ExchangeRate;
  49. public double Value;
  50. public Current Current;
  51. public static void GetExchangeValue(ExchangeInfo info, StaticsManager.ConsumeModule consumeModule)
  52. {
  53. if (info.Current == Current.Coin)
  54. {
  55. Manager.AddCoin(info.Value, StaticsManager.ItemID.获得金币, consumeModule);
  56. }
  57. else if (info.Current == Current.Diamond)
  58. {
  59. Manager.AddDiamond(info.Value, StaticsManager.ItemID.获得钻石, consumeModule);
  60. }
  61. }
  62. public static ExchangeInfo GetExchangeInfo(Current current, double amt, float rate)
  63. {
  64. ExchangeInfo info = new ExchangeInfo();
  65. info.ExchangeRate = rate;
  66. info.Value = amt * rate;
  67. info.Current = current;
  68. return info;
  69. }
  70. }
  71. public class CloseItemLabel
  72. {
  73. public static string Icon1 = "Icon1";
  74. public static string Icon2 = "Icon2";
  75. public static string Icon3 = "Icon3";
  76. public static string CloseItem = "CloseItem";
  77. public static string BuyBtn = "BuyBtn";
  78. public static string BuyBtnLab = "BuyBtnLab";
  79. }
  80. public class CloseItem
  81. {
  82. public enum CloseType
  83. {
  84. Top,
  85. Hair,
  86. Wing,
  87. Dress,
  88. Decarator,
  89. Shoe,
  90. }
  91. #region Config
  92. public string Name
  93. {
  94. get { return Language.GetStr(LanguageLabel.CombineLanguageLabel(LanguageLabel.DressRoom, FullID)); }
  95. }
  96. public static string IDPrefix = "Armature";
  97. public string FullID
  98. {
  99. get { return IDPrefix + ID; }
  100. }
  101. public int ID;
  102. public int Index;
  103. public int BuyLevel;
  104. public int PixelSize;
  105. public bool IsBought;
  106. public string ArmatureName;
  107. public string[] ExtraArmatureNames;
  108. public BodyPart[] ExtraBodyParts;
  109. public float SpriteAlpha;
  110. public float IconOffset;
  111. public TextPlus BuyBtnLab;
  112. public Sprite[] Sprites;
  113. public Image Icon1;
  114. public Image Icon2;
  115. public Image Icon3;
  116. public Button BuyBtn;
  117. public Button DressBtn;
  118. public Vector2 IconOffset1;
  119. public Vector2 IconOffset2;
  120. public BodyPart BodyPart;
  121. public Transform Transform;
  122. public CloseType Type;
  123. public bool Unavailable; //True-不显示
  124. public double BuyCost;
  125. public double BuyAdvanceCost;
  126. public Current BuyCurrent;
  127. public Current BuyAdvanceCurrent;
  128. public Dictionary<string, Transform> ChildDic = new Dictionary<string, Transform>();
  129. #endregion
  130. public CloseItem(XmlAttributeCollection attribute)
  131. {
  132. Unavailable = Auxiliary.StringToBool(attribute[19].Value, false);
  133. ID = Auxiliary.StringToInt(attribute[0].Value, -1);
  134. BodyPart = BodyPartParse(attribute[4].Value);
  135. ArmatureName = attribute[16].Value;
  136. PlayerManager.CloseIDDictionary.Add(ArmatureName, ID);
  137. PlayerManager.CloseItemDictionary.Add(ID, this);
  138. if (Unavailable)
  139. {
  140. return;
  141. }
  142. Type = TypeParse(attribute[2].Value);
  143. Index = Auxiliary.StringToInt(attribute[3].Value, -1);
  144. BuyLevel = Auxiliary.StringToInt(attribute[5].Value, 0);
  145. BuyCurrent = Auxiliary.CurrentParse(attribute[6].Value);
  146. BuyCost = Auxiliary.StringToDouble(attribute[7].Value, 0);
  147. BuyAdvanceCurrent = Auxiliary.CurrentParse(attribute[8].Value);
  148. BuyAdvanceCost = Auxiliary.StringToDouble(attribute[9].Value, 0);
  149. PixelSize = Auxiliary.StringToInt(attribute[10].Value, 100);
  150. IconOffset = Auxiliary.StringToFloat(attribute[11].Value, 0);
  151. IconOffset1 = Auxiliary.StringToVector(',', attribute[12].Value, new Vector3());
  152. IconOffset2 = Auxiliary.StringToVector(',', attribute[13].Value, new Vector3());
  153. Sprites = SpriteParse(attribute[14].Value);
  154. SpriteAlpha = Auxiliary.StringToFloat(attribute[15].Value, 1);
  155. ExtraBodyParts = BodyPartParses(attribute[17].Value);
  156. ExtraArmatureNames = Auxiliary.StringToStrings(',', attribute[18].Value, new List<string>()).ToArray();
  157. CreateItem();
  158. }
  159. protected void CreateItem()
  160. {
  161. Transform = ResourceManager.Get(ResourceLabel.CloseItem, Folder.UI, false, ResourceManager.Get(CanvasLabel.Canvas), false);
  162. if (Type == CloseType.Top)
  163. {
  164. Transform.SetParent(ResourceManager.Get(CanvasLabel.Pb_TopGrid));
  165. }
  166. else if (Type == CloseType.Hair)
  167. {
  168. Transform.SetParent(ResourceManager.Get(CanvasLabel.Pa_HairGrid));
  169. }
  170. else if (Type == CloseType.Dress)
  171. {
  172. Transform.SetParent(ResourceManager.Get(CanvasLabel.Pc_DressGrid));
  173. }
  174. else if (Type == CloseType.Wing)
  175. {
  176. Transform.SetParent(ResourceManager.Get(CanvasLabel.Pe_WingGrid));
  177. }
  178. else if (Type == CloseType.Decarator)
  179. {
  180. Transform.SetParent(ResourceManager.Get(CanvasLabel.Pd_DecaratorGrid));
  181. }
  182. else if (Type == CloseType.Shoe)
  183. {
  184. Transform.SetParent(ResourceManager.Get(CanvasLabel.Pf_ShoeGrid));
  185. }
  186. else
  187. {
  188. throw new Exception();
  189. }
  190. Transform.SetSiblingIndex(Index);
  191. Auxiliary.CompileDic(Transform, ChildDic);
  192. Icon1 = ChildDic[CloseItemLabel.Icon1].GetComponent<Image>();
  193. Icon2 = ChildDic[CloseItemLabel.Icon2].GetComponent<Image>();
  194. Icon3 = ChildDic[CloseItemLabel.Icon3].GetComponent<Image>();
  195. DressBtn = ChildDic[CloseItemLabel.CloseItem].GetComponent<Button>();
  196. BuyBtn = ChildDic[CloseItemLabel.BuyBtn].GetComponent<Button>();
  197. BuyBtnLab = ChildDic[CloseItemLabel.BuyBtnLab].GetComponent<TextPlus>();
  198. SetupStandardItem(Icon1, Icon2, Icon3, BuyBtn, BuyBtnLab);
  199. //BuyBtnLab.GetComponent<TextPlus>().SetY = true;
  200. //float newSize = PixelSize / Sprites[0].rect.width;
  201. //SetupUI(newSize, new Vector2(), Icon1, Icon2, Icon3);
  202. //if (BuyCurrent != Current.Free)
  203. //{
  204. // BuyBtnLab.text = Auxiliary.ImageParse(BuyCurrent) + Auxiliary.ShrinkNumberStr(BuyCost);
  205. //}
  206. //if (BuyLevel > Manager.GardenLevel)
  207. //{
  208. // BuyBtn.interactable = false;
  209. // BuyBtn.image.material = Lib.GrayMat;
  210. //}
  211. BuyBtn.onClick.AddListener
  212. (
  213. () =>
  214. {
  215. AudioManager.PlayClip(AudioLabel.ClickButton);
  216. OpenBuyPanel(null, NavigateToChargeFromDressroom);
  217. //ResourceManager.Get(CanvasLabel.Pa_Info).TweenForCG();
  218. //float newSize = PixelSize / Sprites[0].rect.width;
  219. //SetupUI(newSize, new Vector2(0, 22), ResourceManager.Get<Image>(CanvasLabel.Pa_Icon1), ResourceManager.Get<Image>(CanvasLabel.Pa_Icon3), ResourceManager.Get<Image>(CanvasLabel.Pa_Icon2));
  220. //ResourceManager.SetText(CanvasLabel.Pa_Lab, Name);
  221. //ResourceManager.SetText(CanvasLabel.Pa_BtnLab, Language.GetStr(LanguageLabel.UI__Pa_BtnLab) + Auxiliary.ImageParse(BuyCurrent) + BuyCost);
  222. //ResourceManager.SetButtonEvent
  223. //(
  224. // CanvasLabel.Pa_Btn,
  225. // () => OnBuy
  226. //);
  227. }
  228. );
  229. DressBtn.onClick.AddListener
  230. (
  231. () =>
  232. {
  233. AudioManager.PlayClip(AudioLabel.ClickButton);
  234. if (BuyLevel > Manager.GardenLevel)
  235. {
  236. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__P_Unlock));
  237. return;
  238. }
  239. ChangeDress(PlayerManager.Player);
  240. }
  241. );
  242. }
  243. protected Sprite[] SpriteParse(string str)
  244. {
  245. string[] spriteNames = str.Split(',');
  246. Sprite[] sprites = new Sprite[spriteNames.Length];
  247. for (int i = 0; i < spriteNames.Length; i++)
  248. {
  249. if (!PlayerManager.CloseSpriteDictionary.ContainsKey(spriteNames[i]))
  250. {
  251. Debug.Log(spriteNames[i]);
  252. }
  253. sprites[i] = PlayerManager.CloseSpriteDictionary[spriteNames[i]];
  254. }
  255. return sprites;
  256. }
  257. protected BodyPart BodyPartParse(string str)
  258. {
  259. int type = Auxiliary.StringToInt(str, -1);
  260. if (type == 1)
  261. {
  262. return BodyPart.Head;
  263. }
  264. else if (type == 2)
  265. {
  266. return BodyPart.Dress;
  267. }
  268. else if (type == 3)
  269. {
  270. return BodyPart.Shoe;
  271. }
  272. else if (type == 4)
  273. {
  274. return BodyPart.Headwear;
  275. }
  276. else if (type == 5)
  277. {
  278. return BodyPart.Top;
  279. }
  280. else if (type == 6)
  281. {
  282. return BodyPart.Wing;
  283. }
  284. else if (type == 7)
  285. {
  286. return BodyPart.LeftLongSleeve;
  287. }
  288. else if (type == 8)
  289. {
  290. return BodyPart.RightLongSleeve;
  291. }
  292. else if (type == 9)
  293. {
  294. return BodyPart.LeftShortSleeve;
  295. }
  296. else if (type == 10)
  297. {
  298. return BodyPart.RightShortSleeve;
  299. }
  300. else if (type == 11)
  301. {
  302. return BodyPart.Eye;
  303. }
  304. else if (type == 12)
  305. {
  306. return BodyPart.Mouse;
  307. }
  308. else
  309. {
  310. throw new Exception();
  311. }
  312. }
  313. protected BodyPart[] BodyPartParses(string str)
  314. {
  315. List<string> typeIDs = Auxiliary.StringToStrings(',', str, new List<string>());
  316. BodyPart[] bodyParts = new BodyPart[typeIDs.Count];
  317. for (int i = 0; i < typeIDs.Count; i++)
  318. {
  319. bodyParts[i] = BodyPartParse(typeIDs[i]);
  320. }
  321. return bodyParts;
  322. }
  323. protected CloseType TypeParse(string str)
  324. {
  325. int type = Auxiliary.StringToInt(str, -1);
  326. if (type == 1)
  327. {
  328. return CloseType.Hair;
  329. }
  330. else if (type == 2)
  331. {
  332. return CloseType.Top;
  333. }
  334. else if (type == 3)
  335. {
  336. return CloseType.Dress;
  337. }
  338. else if (type == 4)
  339. {
  340. return CloseType.Decarator;
  341. }
  342. else if (type == 5)
  343. {
  344. return CloseType.Wing;
  345. }
  346. else if (type == 6)
  347. {
  348. return CloseType.Shoe;
  349. }
  350. else
  351. {
  352. throw new Exception();
  353. }
  354. }
  355. public void SetupUI(float newSize, Vector2 offset, Image icon1, Image icon2, Image icon3)
  356. {
  357. icon1.SetActive(false);
  358. icon3.SetActive(false);
  359. icon2.SetActive(true);
  360. icon2.sprite = Sprites[0];
  361. icon2.Resize(true, new Vector2(newSize, newSize));
  362. icon2.SetAlpha(SpriteAlpha);
  363. icon2.transform.localPosition = offset + new Vector2(0, IconOffset);
  364. if (Sprites.Length >= 2)
  365. {
  366. icon1.SetActive(true);
  367. icon1.sprite = Sprites[1];
  368. icon1.Resize(true, new Vector2(newSize, newSize));
  369. icon1.SetAlpha(SpriteAlpha);
  370. icon1.transform.localPosition = IconOffset1 * newSize + offset + new Vector2(0, IconOffset);
  371. }
  372. if (Sprites.Length >= 3)
  373. {
  374. icon3.SetActive(true);
  375. icon3.sprite = Sprites[2];
  376. icon3.Resize(true, new Vector2(newSize, newSize));
  377. icon3.SetAlpha(SpriteAlpha);
  378. icon3.transform.localPosition = IconOffset2 * newSize + offset + new Vector2(0, IconOffset);
  379. }
  380. }
  381. public void SetupStandardItem(Image icon1, Image icon2, Image icon3, Button buyButton, TextPlus buyButtonText)
  382. {
  383. buyButtonText.GetComponent<TextPlus>().SetY = true;
  384. float newSize = PixelSize / Sprites[0].rect.width;
  385. SetupUI(newSize, new Vector2(), icon1, icon2, icon3);
  386. if (BuyCurrent != Current.Free)
  387. {
  388. buyButtonText.text = Auxiliary.ImageParse(BuyCurrent) + Auxiliary.ShrinkBigNumberStr(BuyCost);
  389. buyButton.interactable = true;
  390. }
  391. if (BuyLevel > Manager.GardenLevel)
  392. {
  393. buyButton.interactable = false;
  394. buyButton.image.material = Lib.GrayMat;
  395. }
  396. }
  397. public void OpenBuyPanel(Action buySucceedCallback, Action navigateAction)
  398. {
  399. ResourceManager.Get(CanvasLabel.Pa_Info).TweenForCG();
  400. float newSize = PixelSize / Sprites[0].rect.width;
  401. SetupUI(newSize, new Vector2(0, 22), ResourceManager.Get<Image>(CanvasLabel.Pa_Icon1), ResourceManager.Get<Image>(CanvasLabel.Pa_Icon3), ResourceManager.Get<Image>(CanvasLabel.Pa_Icon2));
  402. ResourceManager.SetText(CanvasLabel.Pa_Lab, Name);
  403. ResourceManager.SetText(CanvasLabel.Pa_BtnLab, Language.GetStr(LanguageLabel.UI__Pa_BtnLab) + Auxiliary.ImageParse(BuyCurrent) + BuyCost);
  404. ResourceManager.SetButtonEvent
  405. (
  406. CanvasLabel.Pa_Btn,
  407. () => OnBuy(buySucceedCallback, navigateAction)
  408. );
  409. }
  410. public void Unlock()
  411. {
  412. if (Unavailable)
  413. {
  414. return;
  415. }
  416. IsBought = true;
  417. BuyBtn.interactable = false;
  418. BuyBtn.image.material = Lib.GrayMat;
  419. BuyBtnLab.text = Language.GetStr(LanguageLabel.UI__P_BtnLab2);
  420. Manager.CloseAmt++;
  421. }
  422. public void OnBuy(Action buySucceedCallback, Action navigateAction)
  423. {
  424. bool navigate = navigateAction != null;
  425. Manager.Pay
  426. (
  427. "",
  428. BuyCost,
  429. BuyCurrent,
  430. () =>
  431. {
  432. OnBuySucceed();
  433. ResourceManager.Get(CanvasLabel.Pa_Info).TweenBacCG();
  434. ChangeDress(PlayerManager.Player);
  435. SaveDressData();
  436. buySucceedCallback.SafeInvoke();
  437. ConfigManager.SaveConfigDocument();
  438. ConfigManager.SaveConfigDocumentToDisk();
  439. },
  440. StaticsManager.ItemID.解锁服装,
  441. StaticsManager.ConsumeModule.Shop,
  442. navigate,
  443. false,
  444. () =>
  445. {
  446. PlayerManager.Player.ResetDressDatas();
  447. navigateAction.SafeInvoke();
  448. }
  449. );
  450. }
  451. public void OnBuySucceed()
  452. {
  453. Unlock();
  454. AudioManager.PlayClip(AudioLabel.GetCurrent);
  455. PlayerManager.BoughtCloseIDs.UniqueAdd(ID);
  456. }
  457. public void NavigateToChargeFromDressroom()
  458. {
  459. TweenRoot tweenRoot = ResourceManager.Get(CanvasLabel.Pa_Info).TweenBacCG();
  460. tweenRoot.AddEventOnetime
  461. (
  462. EventType.BackwardFinish,
  463. () =>
  464. {
  465. PlayerManager.Player.LeaveDressroom();
  466. }
  467. );
  468. ResourceManager.Get(CanvasLabel.B_SignIn0).GetTweenCG().AddEventOnetime
  469. (
  470. EventType.ForwardFinish,
  471. () =>
  472. {
  473. ResourceManager.Get(CanvasLabel.F_Manage0).TweenForVec();
  474. }
  475. );
  476. }
  477. public void ChangeDress(Player player, bool resetDepth = true)
  478. {
  479. player.ChangeClose(BodyPart, ArmatureName, resetDepth);
  480. if (Unavailable)
  481. {
  482. return;
  483. }
  484. if (ExtraBodyParts.Length > 0)
  485. {
  486. player.ChangeClose(BodyPart.LeftLongSleeve, "Empty", resetDepth);
  487. player.ChangeClose(BodyPart.LeftShortSleeve, "Empty", resetDepth);
  488. player.ChangeClose(BodyPart.RightLongSleeve, "Empty", resetDepth);
  489. player.ChangeClose(BodyPart.RightShortSleeve, "Empty", resetDepth);
  490. }
  491. for (int i = 0; i < ExtraArmatureNames.Length; i++)
  492. {
  493. player.ChangeClose(ExtraBodyParts[i], ExtraArmatureNames[i], resetDepth);
  494. }
  495. }
  496. public void SaveDressData() //仅在购买完成时调用
  497. {
  498. SaveDressData(BodyPart);
  499. if (BodyPart == BodyPart.Top)
  500. {
  501. PlayerManager.DressDatas[8] = "Empty";
  502. PlayerManager.DressDatas[9] = "Empty";
  503. PlayerManager.DressDatas[10] = "Empty";
  504. PlayerManager.DressDatas[11] = "Empty";
  505. foreach (var bodyPart in ExtraBodyParts)
  506. {
  507. SaveDressData(bodyPart);
  508. }
  509. }
  510. }
  511. public void SaveDressData(BodyPart bodyPart) //仅在购买完成时调用
  512. {
  513. if (bodyPart == BodyPart.LeftLongSleeve)
  514. {
  515. PlayerManager.DressDatas[8] = PlayerManager.Player.LeftLongSleeve;
  516. }
  517. else if (bodyPart == BodyPart.LeftShortSleeve)
  518. {
  519. PlayerManager.DressDatas[9] = PlayerManager.Player.LeftShortSleeve;
  520. }
  521. else if (bodyPart == BodyPart.RightLongSleeve)
  522. {
  523. PlayerManager.DressDatas[10] = PlayerManager.Player.RightLongSleeve;
  524. }
  525. else if (bodyPart == BodyPart.RightShortSleeve)
  526. {
  527. PlayerManager.DressDatas[11] = PlayerManager.Player.RightShortSleeve;
  528. }
  529. else if (bodyPart == BodyPart.Top)
  530. {
  531. PlayerManager.DressDatas[4] = PlayerManager.Player.Top;
  532. }
  533. else if (bodyPart == BodyPart.Shoe)
  534. {
  535. PlayerManager.DressDatas[2] = PlayerManager.Player.Shoe;
  536. }
  537. else if (bodyPart == BodyPart.Head)
  538. {
  539. PlayerManager.DressDatas[0] = PlayerManager.Player.Head;
  540. }
  541. else if (bodyPart == BodyPart.Wing)
  542. {
  543. PlayerManager.DressDatas[7] = PlayerManager.Player.Wing;
  544. }
  545. else if (bodyPart == BodyPart.Dress)
  546. {
  547. PlayerManager.DressDatas[1] = PlayerManager.Player.Dress;
  548. }
  549. else if (bodyPart == BodyPart.Headwear)
  550. {
  551. PlayerManager.DressDatas[3] = PlayerManager.Player.HeadWear;
  552. }
  553. else
  554. {
  555. throw new Exception();
  556. }
  557. }
  558. public void OnLevelChange()
  559. {
  560. if (Unavailable)
  561. {
  562. return;
  563. }
  564. if (IsBought)
  565. {
  566. return;
  567. }
  568. if (BuyLevel <= Manager.GardenLevel)
  569. {
  570. BuyBtn.interactable = true;
  571. BuyBtn.image.material = null;
  572. }
  573. }
  574. public ExchangeInfo GetExchangeValue(float rate, StaticsManager.ConsumeModule consumeModule)
  575. {
  576. ExchangeInfo info = ExchangeInfo.GetExchangeInfo(BuyCurrent, BuyCost, rate);
  577. ExchangeInfo.GetExchangeValue(info, consumeModule);
  578. return info;
  579. }
  580. public static List<KV<Current, KV<int, double>>> GetTotalBuyCost(bool excludeBought, List<int> closeIDs)
  581. {
  582. int coinAmount = 0;
  583. int diamondAmount = 0;
  584. double totalCoin = 0;
  585. double totalDiamond = 0;
  586. foreach (var closeID in closeIDs)
  587. {
  588. if (PlayerManager.CloseItemDictionary[closeID].Sprites == null) continue;
  589. if (PlayerManager.CloseItemDictionary[closeID].ArmatureName == "Empty") continue;
  590. CloseItem closeItem = PlayerManager.CloseItemDictionary[closeID];
  591. if (closeItem.IsBought && excludeBought) continue;
  592. if (closeItem.BuyCurrent == Current.Coin)
  593. {
  594. totalCoin += closeItem.BuyCost;
  595. coinAmount++;
  596. }
  597. if (closeItem.BuyCurrent == Current.Diamond)
  598. {
  599. totalDiamond += closeItem.BuyCost;
  600. diamondAmount++;
  601. }
  602. }
  603. List<KV<Current, KV<int, double>>> results = new List<KV<Current, KV<int, double>>>();
  604. results.Add(new KV<Current, KV<int, double>>(Current.Coin, new KV<int, double>(coinAmount, totalCoin)));
  605. results.Add(new KV<Current, KV<int, double>>(Current.Diamond, new KV<int, double>(diamondAmount, totalDiamond)));
  606. return results;
  607. }
  608. }
  609. public enum PlayerDirection
  610. {
  611. Left = 0,
  612. Right = 1,
  613. }
  614. public class Player : Regist , IPointerClickHandler
  615. {
  616. #region Config
  617. public static string IdleAnimationName = "newAnimation";
  618. public static string JumpAnimationName = "newAnimation1";
  619. public static string WalkAnimationName = "newAnimation2";
  620. public static string RunAnimationName = "newAnimation3";
  621. public static bool InDressRoom;
  622. public static float InDressRoomJumpFrequency;
  623. public float JumpTime;
  624. public float JumpTimer;
  625. public PlayerDirection PlayerDirection
  626. {
  627. get { return playerDirection; }
  628. set
  629. {
  630. playerDirection = value;
  631. Flip(playerDirection);
  632. }
  633. }
  634. public PlayerDirection playerDirection = PlayerDirection.Left;
  635. public Vector3 PosInGarden;
  636. public bool IsDisplayInUGUI;
  637. public float UGUIScale;
  638. public bool PlayAnimFlag1;
  639. public bool PlayAnimFlag2;
  640. public string CurrentAnimationName;
  641. public Material Material;
  642. public MeshFilter ExpressionMeshFilter;
  643. public Dictionary<string, Transform> ChildDic = new Dictionary<string, Transform>();
  644. private string ExpressionName;
  645. private Coroutine ResetExpressionCoroutine;
  646. public static Dictionary<string, Vector3> LeftExpressionPositionDictionary = new Dictionary<string, Vector3>
  647. {
  648. {"郁闷", new Vector3(0, -0.22f, -0.00001f)},
  649. {"汗颜", new Vector3(0.35f, 0.91f, -0.00001f)},
  650. {"惊讶", new Vector3(0.09f, -0.07f, -0.00001f)},
  651. {"开心", new Vector3(0.1f, -0.22f, -0.00001f)},
  652. {"哭", new Vector3(0.07f, -0.64f, -0.00001f)},
  653. {"期待", new Vector3(0.04f, -0.20f, -0.00001f)},
  654. {"色咪咪", new Vector3(0.03f, -0.09f, -0.00001f)},
  655. {"委屈", new Vector3(0f, -0.27f, -0.00001f)},
  656. };
  657. public static Dictionary<string, Vector3> RightExpressionPositionDictionary = new Dictionary<string, Vector3>
  658. {
  659. {"郁闷", new Vector3(0, -0.22f, -0.00001f)},
  660. {"汗颜", new Vector3(-0.22f, 0.91f, -0.00001f)},
  661. {"惊讶", new Vector3(-0.09f, -0.07f, -0.00001f)},
  662. {"开心", new Vector3(-0.1f, -0.22f, -0.00001f)},
  663. {"哭", new Vector3(-0.07f, -0.64f, -0.00001f)},
  664. {"期待", new Vector3(-0.04f, -0.20f, -0.00001f)},
  665. {"色咪咪", new Vector3(-0.03f, -0.09f, -0.00001f)},
  666. {"委屈", new Vector3(0f, -0.27f, -0.00001f)},
  667. };
  668. #region 换装
  669. public Transform Shadow;
  670. private Transform Pivot
  671. {
  672. get
  673. {
  674. if (pivot == null)
  675. {
  676. pivot = UAC.transform.FindChild(PlayerLabel.Pivot);
  677. }
  678. return pivot;
  679. }
  680. }
  681. private Transform pivot;
  682. public string Eye;
  683. public string Top;
  684. public string Shoe;
  685. public string Head;
  686. public string Wing;
  687. public string Dress;
  688. public string Mouse;
  689. public string HeadWear;
  690. public string LeftLongSleeve;
  691. public string LeftShortSleeve;
  692. public string RightLongSleeve;
  693. public string RightShortSleeve;
  694. private string TempClose;
  695. public DragonBones.Slot NeckSlot;
  696. public DragonBones.Slot LeftHandSlot;
  697. public DragonBones.Slot RightHandSlot;
  698. public DragonBones.Slot LeftLegSlot;
  699. public DragonBones.Slot RightLegSlot;
  700. public DragonBones.Slot LeftShortSleeveSlot;
  701. public DragonBones.Slot RightShortSleeveSlot;
  702. public DragonBones.Slot EyeSlot;
  703. public DragonBones.Slot TopSlot;
  704. public DragonBones.Slot HeadSlot;
  705. public DragonBones.Slot DressSlot;
  706. public DragonBones.Slot WingSlot;
  707. public DragonBones.Slot MouseSlot;
  708. public DragonBones.Slot LeftShoeSlot;
  709. public DragonBones.Slot RightShoeSlot;
  710. public DragonBones.Slot HeadWearSlot;
  711. public UnityArmatureComponent UAC;
  712. //public UnityArmatureComponent LeftShortSleeveUAC;
  713. //public UnityArmatureComponent RightShortSleeveUAC;
  714. public UnityArmatureComponent LeftLongSleeveUAC;
  715. public UnityArmatureComponent RightLongSleeveUAC;
  716. #endregion
  717. #endregion
  718. public override bool InitAtOnce()
  719. {
  720. if (base.InitAtOnce())
  721. {
  722. return true;
  723. }
  724. enabled = true;
  725. Auxiliary.CompileDic(transform, ChildDic);
  726. Vector3 bigShadowScale = new Vector3(1.820952f, 2.418199f, 1.820952f);
  727. Vector3 smallShadowScale = new Vector3(1.081191f, 1.435807f, 1.081191f);
  728. Shadow = ChildDic[PlayerLabel.Shadow];
  729. Shadow.CreateStreamScale
  730. (
  731. new List<float>() {0, 0, 0},
  732. new List<float>() {0.33f, 0.33f, 0.33f, 0.33f},
  733. new List<VecPair>() {new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale), new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale)},
  734. true,
  735. true,
  736. Curve.EaseOutQuad
  737. );
  738. MeshFilter meshFilter = Shadow.GetComponent<MeshFilter>();
  739. meshFilter.mesh = SpriteUtility.CreateMesh(ResourceManager.LoadSprite(ResourceLabel.FlowerShadow, Folder.Scene));
  740. meshFilter.mesh.SetUVs(1, Enumerable.Repeat(new Vector2(0, 1), meshFilter.mesh.vertices.Length).ToList());
  741. return false;
  742. }
  743. public void Update()
  744. {
  745. if (InDressRoom)
  746. {
  747. JumpTimer += Time.deltaTime;
  748. if (JumpTimer > JumpTime)
  749. {
  750. if (!PlayAnimFlag1 && !PlayAnimFlag2)
  751. {
  752. PlayAnim(JumpAnimationName);
  753. }
  754. PlayAnimFlag2 = true;
  755. }
  756. if (JumpTimer > InDressRoomJumpFrequency)
  757. {
  758. PlayAnimFlag2 = false;
  759. JumpTime = Mathf.Lerp(0, InDressRoomJumpFrequency, Random.Range(0f, 1f));
  760. JumpTimer = 0;
  761. }
  762. }
  763. //if (GardenSmartFoxManager.GardenSmartFox.PlazaRoomManager.InPlazaRoom)
  764. //{
  765. // MoveThread();
  766. //}
  767. }
  768. public void OnAnimStart(string str, EventObject eventObject)
  769. {
  770. if (eventObject.animationState.name == JumpAnimationName)
  771. {
  772. Shadow.StreamReForScale();
  773. PlayAnimFlag1 = true;
  774. TempClose = Eye;
  775. ChangeClose(BodyPart.Eye, "眼睛表情1");
  776. }
  777. else if (eventObject.animationState.name == IdleAnimationName)
  778. {
  779. PlayAnimFlag1 = false;
  780. if (TempClose != null)
  781. {
  782. ChangeClose(BodyPart.Eye, TempClose);
  783. }
  784. }
  785. }
  786. public void PlayAnim(string animName)
  787. {
  788. if (PlayAnimFlag1)
  789. {
  790. return;
  791. }
  792. if (UAC.anim.lastAnimationName == animName)
  793. {
  794. return;
  795. }
  796. if (SFSManager.GardenSmartFox.PlazaRoomController.JoinedPlazaRoom)
  797. {
  798. CurrentAnimationName = animName;
  799. }
  800. UAC.anim.FadeIn(animName, GetFadeInTime(UAC.anim.lastAnimationName, animName));
  801. }
  802. public float GetFadeInTime(string lastAnimation, string targetAnimation)
  803. {
  804. if (lastAnimation == JumpAnimationName && targetAnimation == IdleAnimationName)
  805. return -1f;
  806. else
  807. return 0.1f;
  808. //throw new Exception();
  809. }
  810. public void SetAllCollider(bool enable)
  811. {
  812. BoxCollider2D[] colliders = GetComponentsInChildren<BoxCollider2D>();
  813. for (int i = 0; i < colliders.Length; i++)
  814. {
  815. colliders[i].enabled = enable;
  816. }
  817. }
  818. public void OnPointerClick(PointerEventData eventData)
  819. {
  820. AudioManager.PlayClip(AudioLabel.GetCurrent);
  821. PlayAnim(JumpAnimationName);
  822. }
  823. public void ResetExpression()
  824. {
  825. ExpressionMeshFilter.SetActive(false);
  826. EyeSlot.UnityTransform.GetChild(0).SetActive(true);
  827. MouseSlot.UnityTransform.GetChild(0).SetActive(true);
  828. }
  829. public void ChangeExpression(string expressionName, float duration)
  830. {
  831. ExpressionName = expressionName;
  832. ExpressionMeshFilter.sharedMesh = SpriteUtility.CreateMesh(ResourceManager.LoadSprite(expressionName, Folder.Scene));
  833. ExpressionMeshFilter.mesh.SetUVs(1, Enumerable.Repeat(new Vector2(0, 1), ExpressionMeshFilter.mesh.vertices.Length).ToList());
  834. ExpressionMeshFilter.transform.parent = EyeSlot.UnityTransform;
  835. ExpressionMeshFilter.SetActive(true);
  836. EyeSlot.UnityTransform.GetChild(0).SetActive(false);
  837. MouseSlot.UnityTransform.GetChild(0).SetActive(false);
  838. FlipExpression(expressionName, PlayerDirection);
  839. if (ResetExpressionCoroutine != null)
  840. Auxiliary.Instance.StopCoroutine(ResetExpressionCoroutine);
  841. ResetExpressionCoroutine = Auxiliary.Instance.DelayCall
  842. (
  843. () =>
  844. {
  845. ResetExpression();
  846. },
  847. duration
  848. );
  849. }
  850. public void Flip(PlayerDirection direction)
  851. {
  852. FlipExpression(ExpressionName, direction);
  853. if (direction == PlayerDirection.Left)
  854. {
  855. UAC.armature.flipX = false;
  856. playerDirection = PlayerDirection.Left;
  857. }
  858. else if (direction == PlayerDirection.Right)
  859. {
  860. UAC.armature.flipX = true;
  861. playerDirection = PlayerDirection.Right;
  862. }
  863. else
  864. {
  865. throw new Exception();
  866. }
  867. DelayCall.Call(1, () => Shadow.SetX(Pivot.position.x));
  868. }
  869. public void FlipExpression(string expressionName, PlayerDirection direction)
  870. {
  871. if (string.IsNullOrEmpty(ExpressionName))
  872. {
  873. return;
  874. }
  875. if (direction == PlayerDirection.Left)
  876. {
  877. ExpressionMeshFilter.transform.eulerAngles = new Vector3();
  878. ExpressionMeshFilter.transform.localPosition = LeftExpressionPositionDictionary[ExpressionName];
  879. }
  880. else if (direction == PlayerDirection.Right)
  881. {
  882. UAC.armature.flipX = true;
  883. ExpressionMeshFilter.transform.eulerAngles = new Vector3(0, 180, 0);
  884. ExpressionMeshFilter.transform.localPosition = RightExpressionPositionDictionary[ExpressionName];
  885. playerDirection = PlayerDirection.Right;
  886. }
  887. else
  888. {
  889. throw new Exception();
  890. }
  891. }
  892. public void SaveDressDatas(bool showNavigate)
  893. {
  894. AudioManager.PlayClip(AudioLabel.ClickButton);
  895. List<CloseItem> closeUnitList = new List<CloseItem>();
  896. closeUnitList.Add(PlayerManager.CloseItemDictionary[PlayerManager.CloseIDDictionary[Head]]);
  897. closeUnitList.Add(PlayerManager.CloseItemDictionary[PlayerManager.CloseIDDictionary[Dress]]);
  898. closeUnitList.Add(PlayerManager.CloseItemDictionary[PlayerManager.CloseIDDictionary[Shoe]]);
  899. closeUnitList.Add(PlayerManager.CloseItemDictionary[PlayerManager.CloseIDDictionary[HeadWear]]);
  900. closeUnitList.Add(PlayerManager.CloseItemDictionary[PlayerManager.CloseIDDictionary[Top]]);
  901. if (Wing != "Empty")
  902. {
  903. closeUnitList.Add(PlayerManager.CloseItemDictionary[PlayerManager.CloseIDDictionary[Wing]]);
  904. }
  905. for (int i = 0; i < closeUnitList.Count; i++)
  906. {
  907. if (!closeUnitList[i].IsBought)
  908. {
  909. if (showNavigate)
  910. {
  911. BuyDressNavigate(closeUnitList);
  912. }
  913. return;
  914. }
  915. }
  916. PlayerManager.DressDatas[0] = Head;
  917. PlayerManager.DressDatas[1] = Dress;
  918. PlayerManager.DressDatas[2] = Shoe;
  919. PlayerManager.DressDatas[3] = HeadWear;
  920. PlayerManager.DressDatas[4] = Top;
  921. PlayerManager.DressDatas[7] = Wing;
  922. PlayerManager.DressDatas[8] = LeftLongSleeve;
  923. PlayerManager.DressDatas[9] = LeftShortSleeve;
  924. PlayerManager.DressDatas[10] = RightLongSleeve;
  925. PlayerManager.DressDatas[11] = RightShortSleeve;
  926. Toast.Show(1.5f, Language.GetStr(LanguageLabel.UI__P_SaveSucceed));
  927. }
  928. public void ResetDressDatas()
  929. {
  930. AudioManager.PlayClip(AudioLabel.ClickButton);
  931. List<string> dressData = new List<string>(PlayerManager.DressDatas);
  932. dressData[5] = Eye;
  933. PlayerManager.BuildPlayer(dressData);
  934. }
  935. public List<int> GetCurrentChangableDressIDs()
  936. {
  937. List<int> ids = new List<int>();
  938. ids.Add(PlayerManager.CloseIDDictionary[Head]);
  939. ids.Add(PlayerManager.CloseIDDictionary[Dress]);
  940. ids.Add(PlayerManager.CloseIDDictionary[Shoe]);
  941. ids.Add(PlayerManager.CloseIDDictionary[HeadWear]);
  942. ids.Add(PlayerManager.CloseIDDictionary[Top]);
  943. ids.Add(PlayerManager.CloseIDDictionary[Wing]);
  944. ids.Add(PlayAnimFlag1 ? PlayerManager.CloseIDDictionary[TempClose] : PlayerManager.CloseIDDictionary[Eye]);
  945. ids.Add(PlayerManager.CloseIDDictionary[Mouse]);
  946. ids.Add(PlayerManager.CloseIDDictionary[Wing]);
  947. return ids;
  948. }
  949. public static List<string> DressIDToDressName(List<int> ids)
  950. {
  951. List<string> names = new List<string>();
  952. foreach (var id in ids)
  953. {
  954. names.Add(PlayerManager.CloseItemDictionary[id].ArmatureName);
  955. }
  956. return names;
  957. }
  958. public List<string> GetCurrentDressNames()
  959. {
  960. List<string> names = new List<string>();
  961. return names;
  962. }
  963. public List<string> GetCurrentChangableDressNames()
  964. {
  965. List<string> names = new List<string>();
  966. names.Add(Head);
  967. names.Add(Dress);
  968. names.Add(Shoe);
  969. names.Add(HeadWear);
  970. names.Add(Top);
  971. names.Add(Wing);
  972. if (PlayAnimFlag1) names.Add(TempClose);
  973. else names.Add(Eye);
  974. names.Add(Mouse);
  975. names.Add(Wing);
  976. return names;
  977. }
  978. public void BuyDressNavigate(List<CloseItem> closeUnitList)
  979. {
  980. for (int i = 0; i < closeUnitList.Count; i++)
  981. {
  982. if (closeUnitList[i].IsBought)
  983. {
  984. closeUnitList.RemoveAt(i--);
  985. }
  986. else
  987. {
  988. closeUnitList[i].BuyBtn.onClick.Invoke();
  989. closeUnitList.RemoveAt(i--);
  990. ResourceManager.Get(CanvasLabel.Pa_Info).GetTweenCG().AddEventOnetime
  991. (
  992. EventType.BackwardFinish,
  993. () =>
  994. {
  995. if (closeUnitList.Count == 0)
  996. {
  997. SaveDressDatas(false);
  998. }
  999. else
  1000. {
  1001. BuyDressNavigate(closeUnitList);
  1002. }
  1003. }
  1004. );
  1005. return;
  1006. }
  1007. }
  1008. }
  1009. public void LeaveDressroom()
  1010. {
  1011. bool allSave = true;
  1012. bool allBought = true;
  1013. List<string> currentDerssData = new List<string>() { Head, Dress, Shoe, HeadWear, Top, Wing };
  1014. if (currentDerssData[0] != PlayerManager.DressDatas[0]) allSave = false;
  1015. if (currentDerssData[1] != PlayerManager.DressDatas[1]) allSave = false;
  1016. if (currentDerssData[2] != PlayerManager.DressDatas[2]) allSave = false;
  1017. if (currentDerssData[3] != PlayerManager.DressDatas[3]) allSave = false;
  1018. if (currentDerssData[4] != PlayerManager.DressDatas[4]) allSave = false;
  1019. if (currentDerssData[5] != PlayerManager.DressDatas[7]) allSave = false;
  1020. for (int i = 0; i < currentDerssData.Count; i++)
  1021. {
  1022. if (!PlayerManager.CloseIDDictionary.ContainsKey(currentDerssData[i]))
  1023. {
  1024. continue;
  1025. }
  1026. int id = PlayerManager.CloseIDDictionary[currentDerssData[i]];
  1027. allBought = allBought && PlayerManager.CloseItemDictionary[id].IsBought;
  1028. //Debug.Log(ManaPlayer.CloseUnitDic[id].Name + " " + ManaPlayer.CloseUnitDic[id].Bought);
  1029. //allSave = allSave && currentDerssData[i] == PlayerManager.DressDatas[i];
  1030. //Debug.Log(currentDerssData[i] + " " + PlayerManager.DressDatas[i]);
  1031. }
  1032. //Debug.Log(allBought);
  1033. //Debug.Log(allSave);
  1034. if (allBought)
  1035. {
  1036. if (allSave)
  1037. {
  1038. ExitDressRoom();
  1039. }
  1040. else
  1041. {
  1042. ResetDressDatas();
  1043. ExitDressRoom();
  1044. }
  1045. }
  1046. else
  1047. {
  1048. Bubble.Show
  1049. (
  1050. null, Language.GetStr(LanguageLabel.UI__P_Return), null, null,
  1051. () =>
  1052. {
  1053. ResetDressDatas();
  1054. ResourceManager.Get(CanvasLabel.K_Bubble).GetTweenGra().AddEventOnetime(EventType.BackwardFinish, () => { ExitDressRoom(); });
  1055. }
  1056. );
  1057. }
  1058. }
  1059. public void ExitDressRoom()
  1060. {
  1061. Manager.SceneSwitchFlag = false;
  1062. TweenRoot tweenRoot = ResourceManager.Get(CanvasLabel.I_BlackMask).TweenBacCG();
  1063. tweenRoot.AddEventOnetime
  1064. (
  1065. EventType.BackwardFinish,
  1066. () =>
  1067. {
  1068. transform.SetParent(ResourceManager.Get(GardenLabel.GardenPivot));
  1069. transform.position = PosInGarden;
  1070. //transform.position = ResourceManager.Get(GardenLabel.GardenPlayerPos).position;
  1071. transform.localScale = ResourceManager.Get(GardenLabel.GardenPlayerPos).lossyScale;
  1072. ResourceManager.Get(ResourceLabel.Garden).TweenForSr();
  1073. ResourceManager.Get(DressroomLabel.DressRoom).TweenBacSr();
  1074. ResourceManager.Get(CanvasLabel.C_Main).TweenForCG();
  1075. ResourceManager.Get(CanvasLabel.P_DressRoom).TweenBacCG();
  1076. }
  1077. );
  1078. tweenRoot = ResourceManager.Get(CanvasLabel.P_DressRoom).GetTweenCG();
  1079. tweenRoot.AddEventOnetime
  1080. (
  1081. EventType.BackwardFinish,
  1082. () =>
  1083. {
  1084. SetAllCollider(true);
  1085. InDressRoom = false;
  1086. JumpTimer = 0;
  1087. PlayAnim(IdleAnimationName);
  1088. DeactiveShadow();
  1089. ResourceManager.Get(CanvasLabel.B_SignIn0).TweenForCG();
  1090. ResourceManager.Get(CanvasLabel.I_BlackMask).TweenForCG();
  1091. }
  1092. );
  1093. }
  1094. public void EnterDressRoom()
  1095. {
  1096. if (Manager.SceneSwitchFlag)
  1097. {
  1098. return;
  1099. }
  1100. ResourceManager.Get(CanvasLabel.B_SignIn0).TweenBacCG();
  1101. InDressRoom = true;
  1102. JumpTime = Mathf.Lerp(0, 10, Random.Range(0.5f, 1f));
  1103. Manager.SceneSwitchFlag = true;
  1104. ResourceManager.Get(CanvasLabel.C_Main).TweenBacCG();
  1105. SetAllCollider(false);
  1106. TweenRoot tweenRoot = ResourceManager.Get(CanvasLabel.I_BlackMask).TweenBacCG();
  1107. tweenRoot.AddEventOnetime
  1108. (
  1109. EventType.BackwardFinish,
  1110. () =>
  1111. {
  1112. GardenManager.RetrieveAllElf();
  1113. IAPManager.RetrieveADChest();
  1114. ActiveShadow();
  1115. transform.SetParent(ResourceManager.Get(DressroomLabel.DressRoom));
  1116. PosInGarden = transform.position;
  1117. transform.position = ResourceManager.Get(DressroomLabel.DressRoomPos).position;
  1118. transform.localScale = ResourceManager.Get(DressroomLabel.DressRoomPos).lossyScale;
  1119. ResourceManager.Get(ResourceLabel.Garden).TweenBacSr();
  1120. ResourceManager.Get(DressroomLabel.DressRoom).TweenForSr();
  1121. ResourceManager.Get(CanvasLabel.P_DressRoom).TweenForCG();
  1122. }
  1123. );
  1124. tweenRoot = ResourceManager.Get(CanvasLabel.P_DressRoom).GetTweenCG();
  1125. tweenRoot.AddEventOnetime
  1126. (
  1127. EventType.ForwardFinish,
  1128. () =>
  1129. {
  1130. ResourceManager.Get(CanvasLabel.I_BlackMask).TweenForCG();
  1131. }
  1132. );
  1133. }
  1134. public void ActiveShadow()
  1135. {
  1136. ChildDic[PlayerLabel.ShadowParent].SetActive(true);
  1137. ChildDic[PlayerLabel.ShadowParent].SetLZ(3);
  1138. }
  1139. public void DeactiveShadow()
  1140. {
  1141. Shadow.GetStreamScale().Pause();
  1142. Shadow.GetStreamScale().InOrigin = true;
  1143. ChildDic[PlayerLabel.ShadowParent].SetActive(false);
  1144. }
  1145. public void DisplayInUI(float scale)
  1146. {
  1147. UGUIScale = scale;
  1148. scale *= ResourceManager.Get<Canvas>(CanvasLabel.Canvas).scaleFactor;
  1149. MeshFilter[] meshFilters = UAC.GetComponentsInChildren<MeshFilter>(true);
  1150. MeshRenderer[] meshRenderers = UAC.GetComponentsInChildren<MeshRenderer>(true);
  1151. for (int i = 0; i < meshRenderers.Length; i++)
  1152. {
  1153. MeshFilter meshFilter = meshFilters[i];
  1154. MeshRenderer meshRenderer = meshRenderers[i];
  1155. UnityUGUIDisplay unityUGUIDisplay = meshRenderer.GetComponent<UnityUGUIDisplay>();
  1156. if (unityUGUIDisplay == null) unityUGUIDisplay = meshRenderer.AddComponent<UnityUGUIDisplay>();
  1157. unityUGUIDisplay.Enable(meshFilter, meshRenderer);
  1158. unityUGUIDisplay.raycastTarget = false;
  1159. meshRenderer.enabled = false;
  1160. UAC.transform.localScale = new Vector3(scale, scale, 1);
  1161. SetAllCollider(false);
  1162. DeactiveShadow();
  1163. }
  1164. IsDisplayInUGUI = true;
  1165. ResetDepth();
  1166. }
  1167. public void DisplayInScene()
  1168. {
  1169. MeshRenderer[] meshRenderers = UAC.GetComponentsInChildren<MeshRenderer>(true);
  1170. foreach (var meshRenderer in meshRenderers)
  1171. {
  1172. UnityUGUIDisplay unityUGUIDisplay = meshRenderer.GetComponent<UnityUGUIDisplay>();
  1173. if (unityUGUIDisplay == null) continue;
  1174. unityUGUIDisplay.Disable();
  1175. meshRenderer.enabled = true;
  1176. UAC.transform.localScale = Vector3.one;
  1177. SetAllCollider(true);
  1178. ActiveShadow();
  1179. }
  1180. IsDisplayInUGUI = false;
  1181. ResetDepth();
  1182. }
  1183. #region 换装
  1184. public void CorrectPivot()
  1185. {
  1186. List<Transform> children = new List<Transform>();
  1187. while (transform.childCount > 0)
  1188. {
  1189. children.Add(transform.GetChild(0));
  1190. children.Back(0).parent = null;
  1191. }
  1192. Vector3 offset = Pivot.position - transform.position;
  1193. children[0].position += offset;
  1194. children[1].position += offset;
  1195. transform.position += offset;
  1196. foreach (var collider in GetComponents<BoxCollider2D>())
  1197. {
  1198. collider.offset -= new Vector2(offset.x, offset.y);
  1199. }
  1200. for (int i = 0; i < children.Count; i++)
  1201. {
  1202. children[i].parent = transform;
  1203. }
  1204. }
  1205. public UnityArmatureComponent Build()
  1206. {
  1207. if (!PlayerManager.Inited)
  1208. {
  1209. UnityFactory.factory.LoadDragonBonesData(ResourceManager.Load<TextAsset>(ResourceLabel.StandSke, Folder.Config));
  1210. UnityFactory.factory.LoadTextureAtlasData(ResourceManager.Load<TextAsset>(ResourceLabel.StandTex, Folder.Config), ResourceLabel.StandTexture);
  1211. PlayerManager.Inited = true;
  1212. }
  1213. UAC = UnityFactory.factory.BuildArmatureComponent("Armature");
  1214. UAC.transform.parent = transform;
  1215. UAC.transform.localScale = new Vector3(1, 1, 1);
  1216. UAC.transform.localPosition = new Vector3();
  1217. UAC.anim.Play(IdleAnimationName);
  1218. UAC.AddEventListener(EventObject.START, OnAnimStart);
  1219. Eye = "眼睛1";
  1220. Top = "上衣1";
  1221. Shoe = "鞋子1";
  1222. Head = "脑壳1";
  1223. Wing = "Empty";
  1224. Dress = "裙子1";
  1225. Mouse = "嘴巴1";
  1226. HeadWear = "头饰品1";
  1227. NeckSlot = UAC.armature.GetSlot("脖子");
  1228. LeftHandSlot = UAC.armature.GetSlot("左手");
  1229. RightHandSlot = UAC.armature.GetSlot("右手");
  1230. LeftLegSlot = UAC.armature.GetSlot("左腿");
  1231. RightLegSlot = UAC.armature.GetSlot("右腿");
  1232. LeftLongSleeveUAC = UAC.transform.FindChild("长袖9左 (长袖9左)").GetComponent<UnityArmatureComponent>();
  1233. RightLongSleeveUAC = UAC.transform.FindChild("长袖9右 (长袖9右)").GetComponent<UnityArmatureComponent>();
  1234. LeftShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子左");
  1235. RightShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子右");
  1236. EyeSlot = UAC.armature.GetSlot("眼睛");
  1237. TopSlot = UAC.armature.GetSlot("上衣");
  1238. HeadSlot = UAC.armature.GetSlot("脑壳");
  1239. WingSlot = UAC.armature.GetSlot("翅膀");
  1240. DressSlot = UAC.armature.GetSlot("裙子");
  1241. MouseSlot = UAC.armature.GetSlot("嘴巴");
  1242. LeftShoeSlot = UAC.armature.GetSlot("鞋子左");
  1243. RightShoeSlot = UAC.armature.GetSlot("鞋子右");
  1244. HeadWearSlot = UAC.armature.GetSlot("头饰品");
  1245. ChangeClose(BodyPart.Eye, "眼睛1", false);
  1246. ChangeClose(BodyPart.Top, "上衣1", false);
  1247. ChangeClose(BodyPart.Shoe, "鞋子1", false);
  1248. ChangeClose(BodyPart.Head, "脑壳1", false);
  1249. ChangeClose(BodyPart.Dress, "裙子1", false);
  1250. ChangeClose(BodyPart.Mouse, "嘴巴1", false);
  1251. ChangeClose(BodyPart.Headwear, "头饰品1", false);
  1252. ChangeClose(BodyPart.LeftLongSleeve, "Empty", false);
  1253. ChangeClose(BodyPart.RightLongSleeve, "Empty", false);
  1254. ChangeClose(BodyPart.LeftShortSleeve, "短袖2左", false);
  1255. ChangeClose(BodyPart.RightShortSleeve, "短袖2右", false);
  1256. CorrectPivot();
  1257. Material = UAC.GetComponentInChildren<MeshRenderer>().sharedMaterial;
  1258. Shadow.GetComponent<MeshRenderer>().sharedMaterial = Material;
  1259. ExpressionMeshFilter = ChildDic[PlayerLabel.ExpressionMeshFilter].GetComponent<MeshFilter>();
  1260. ExpressionMeshFilter.GetComponent<MeshRenderer>().sharedMaterial = Material;
  1261. return UAC;
  1262. }
  1263. public UnityArmatureComponent BuildPink()
  1264. {
  1265. Build();
  1266. ChangeClose(BodyPart.Eye, "眼睛3", false);
  1267. ChangeClose(BodyPart.Top, "上衣3", false);
  1268. ChangeClose(BodyPart.Shoe, "鞋子3", false);
  1269. ChangeClose(BodyPart.Head, "脑壳3", false);
  1270. ChangeClose(BodyPart.Wing, "Empty", false);
  1271. ChangeClose(BodyPart.Dress, "裙子3", false);
  1272. ChangeClose(BodyPart.Mouse, "嘴巴3", false);
  1273. ChangeClose(BodyPart.Headwear, "头饰品3", false);
  1274. ResetDepth();
  1275. return UAC;
  1276. }
  1277. public UnityArmatureComponent BuildBlond()
  1278. {
  1279. Build();
  1280. ChangeClose(BodyPart.Wing, "Empty", false);
  1281. ResetDepth();
  1282. return UAC;
  1283. }
  1284. public UnityArmatureComponent BuildBrown()
  1285. {
  1286. Build();
  1287. ChangeClose(BodyPart.Eye, "眼睛2", false);
  1288. ChangeClose(BodyPart.Top, "上衣2", false);
  1289. ChangeClose(BodyPart.Shoe, "鞋子2", false);
  1290. ChangeClose(BodyPart.Head, "脑壳2", false);
  1291. ChangeClose(BodyPart.Wing, "Empty", false);
  1292. ChangeClose(BodyPart.Dress, "裙子2", false);
  1293. ChangeClose(BodyPart.Mouse, "嘴巴2", false);
  1294. ChangeClose(BodyPart.Headwear, "头饰品2", false);
  1295. ResetDepth();
  1296. return UAC;
  1297. }
  1298. public void ResetDepth()
  1299. {
  1300. if (IsDisplayInUGUI)
  1301. {
  1302. SetSlotAsFirstChild(TopSlot);
  1303. SetSlotAsFirstChild(DressSlot);
  1304. SetSlotAsFirstChild(LeftShortSleeveSlot);
  1305. SetSlotAsFirstChild(RightShortSleeveSlot);
  1306. LeftLongSleeveUAC.transform.SetAsFirstSibling();
  1307. RightLongSleeveUAC.transform.SetAsFirstSibling();
  1308. SetSlotAsFirstChild(EyeSlot);
  1309. SetSlotAsFirstChild(MouseSlot);
  1310. SetSlotAsFirstChild(LeftShoeSlot);
  1311. SetSlotAsFirstChild(RightShoeSlot);
  1312. SetSlotAsFirstChild(HeadWearSlot);
  1313. SetSlotAsFirstChild(LeftHandSlot);
  1314. SetSlotAsFirstChild(RightHandSlot);
  1315. SetSlotAsFirstChild(HeadSlot);
  1316. SetSlotAsFirstChild(LeftLegSlot);
  1317. SetSlotAsFirstChild(RightLegSlot);
  1318. SetSlotAsFirstChild(NeckSlot);
  1319. SetSlotAsFirstChild(WingSlot);
  1320. }
  1321. else
  1322. {
  1323. //UAC.transform.SetLZ(2.5f);
  1324. UAC.transform.SetLZ(0.7f);
  1325. SetSlotLocalZ(WingSlot, 0.00003f);
  1326. SetSlotLocalZ(EyeSlot, -0.00001f);
  1327. SetSlotLocalZ(TopSlot, -0.00003f);
  1328. SetSlotLocalZ(MouseSlot, -0.00001f);
  1329. SetSlotLocalZ(HeadWearSlot, -0.00001f);
  1330. SetSlotLocalZ(LeftShoeSlot, -0.00001f);
  1331. SetSlotLocalZ(RightShoeSlot, -0.00001f);
  1332. SetSlotLocalZ(LeftLegSlot, 0);
  1333. SetSlotLocalZ(RightLegSlot, 0);
  1334. SetSlotLocalZ(NeckSlot, 0.00001f);
  1335. SetSlotLocalZ(LeftHandSlot, -0.00001f);
  1336. SetSlotLocalZ(RightHandSlot, -0.00001f);
  1337. SetSlotLocalZ(LeftShortSleeveSlot, -0.000015f);
  1338. SetSlotLocalZ(RightShortSleeveSlot, -0.000015f);
  1339. SetSlotLocalZ(HeadSlot, 0);
  1340. if (HeadSlot.UnityTransform != null && HeadSlot.UnityTransform.childCount > 1)
  1341. {
  1342. HeadSlot.UnityTransform.GetChild(0).SetLZ(0.00002f);
  1343. HeadSlot.UnityTransform.GetChild(1).SetLZ(0f);
  1344. }
  1345. SetSlotLocalZ(DressSlot, -0.00002f);
  1346. if (DressSlot.UnityTransform != null && DressSlot.UnityTransform.childCount > 1)
  1347. {
  1348. DressSlot.UnityTransform.GetChild(0).SetLZ(0.00002f);
  1349. DressSlot.UnityTransform.GetChild(1).SetLZ(0f);
  1350. }
  1351. LeftLongSleeveUAC.transform.SetLZ(-0.000015f);
  1352. RightLongSleeveUAC.transform.SetLZ(-0.000015f);
  1353. //UAC.transform.SetLZ(2.5f);
  1354. //WingSlot.UnityTransform.SetLZ(0);
  1355. //EyeSlot.UnityTransform.SetLZ(0);
  1356. //TopSlot.UnityTransform.SetLZ(0);
  1357. //MouseSlot.UnityTransform.SetLZ(0);
  1358. //HeadWearSlot.UnityTransform.SetLZ(0);
  1359. //LeftShoeSlot.UnityTransform.SetLZ(0);
  1360. //RightShoeSlot.UnityTransform.SetLZ(0);
  1361. //LeftLegSlot.UnityTransform.SetLZ(0);
  1362. //RightLegSlot.UnityTransform.SetLZ(0);
  1363. //NeckSlot.UnityTransform.SetLZ(0);
  1364. //LeftHandSlot.UnityTransform.SetLZ(0);
  1365. //RightHandSlot.UnityTransform.SetLZ(0);
  1366. //LeftShortSleeveSlot.UnityTransform.SetLZ(0);
  1367. //RightShortSleeveSlot.UnityTransform.SetLZ(0);
  1368. //WingSlot.SetLZ(0.00003f);
  1369. //EyeSlot.SetLZ(-0.00001f);
  1370. //TopSlot.SetLZ(-0.00003f);
  1371. //MouseSlot.SetLZ(-0.00001f);
  1372. //HeadWearSlot.SetLZ(-0.00001f);
  1373. //HeadSlot.UnityTransform.SetLZ(0);
  1374. //if (HeadSlot.UnityTransform.childCount > 1)
  1375. //{
  1376. // HeadSlot.UnityTransform.GetChild(0).SetLZ(0.00002f);
  1377. // HeadSlot.UnityTransform.GetChild(1).SetLZ(0f);
  1378. //}
  1379. //DressSlot.UnityTransform.SetLZ(-0.00002f);
  1380. //if (DressSlot.UnityTransform.childCount > 1)
  1381. //{
  1382. // DressSlot.UnityTransform.GetChild(0).SetLZ(0.00002f);
  1383. // DressSlot.UnityTransform.GetChild(1).SetLZ(0f);
  1384. //}
  1385. //LeftShoeSlot.SetLZ(-0.00001f);
  1386. //RightShoeSlot.SetLZ(-0.00001f);
  1387. //LeftLegSlot.SetLZ(0);
  1388. //RightLegSlot.SetLZ(0);
  1389. //NeckSlot.SetLZ(0.00001f);
  1390. //LeftHandSlot.SetLZ(-0.00001f);
  1391. //RightHandSlot.SetLZ(-0.00001f);
  1392. //LeftShortSleeveSlot.SetLZ(-0.000015f);
  1393. //RightShortSleeveSlot.SetLZ(-0.000015f);
  1394. //LeftLongSleeveUAC.transform.SetLZ(-0.000015f);
  1395. //RightLongSleeveUAC.transform.SetLZ(-0.000015f);
  1396. }
  1397. }
  1398. private void SetSlotLocalZ(DragonBones.Slot slot, float z)
  1399. {
  1400. if (slot.UnityTransform == null)
  1401. {
  1402. UAC.transform.FindChild(slot.name).SetLZ(z);
  1403. }
  1404. else
  1405. {
  1406. slot.UnityTransform.SetLZ(z);
  1407. }
  1408. }
  1409. private void SetSlotAsFirstChild(DragonBones.Slot slot)
  1410. {
  1411. if (slot.UnityTransform == null)
  1412. {
  1413. UAC.transform.FindChild(slot.name).SetAsFirstSibling();
  1414. }
  1415. else
  1416. {
  1417. slot.UnityTransform.SetAsFirstSibling();
  1418. }
  1419. }
  1420. public void ChangeClose(BodyPart bodyPart, string armatureName, bool setDepth = true)
  1421. {
  1422. // Debug.Log (bodyPart + " " + armatureName);
  1423. List<DragonBones.Slot> slotList = new List<DragonBones.Slot>();
  1424. if (bodyPart == BodyPart.Eye)
  1425. {
  1426. Eye = armatureName;
  1427. slotList.Add(EyeSlot);
  1428. }
  1429. else if (bodyPart == BodyPart.Top)
  1430. {
  1431. Top = armatureName;
  1432. slotList.Add(TopSlot);
  1433. }
  1434. else if (bodyPart == BodyPart.Shoe)
  1435. {
  1436. //Shoe = armatureName;
  1437. //slotList.Add(LeftShoeSlot);
  1438. //slotList.Add(RightShoeSlot);
  1439. Shoe = armatureName;
  1440. int id = PlayerManager.CloseIDDictionary[armatureName];
  1441. CloseItem closeItem = PlayerManager.CloseItemDictionary[id];
  1442. Texture2D leftTexture = PlayerManager.GetCloseTexture(closeItem.Sprites[0].name);
  1443. Texture2D rightTexture;
  1444. if (closeItem.Sprites.Length == 1)
  1445. {
  1446. rightTexture = leftTexture;
  1447. }
  1448. else
  1449. {
  1450. rightTexture = PlayerManager.GetCloseTexture(closeItem.Sprites[1].name);
  1451. }
  1452. UnityFactory.factory.ReplaceSlotDisplay("stand", "Armature", "鞋子左", "鞋子1", LeftShoeSlot,
  1453. leftTexture, new Material(Shader.Find("Sprites/Default")));
  1454. UnityFactory.factory.ReplaceSlotDisplay("stand", "Armature", "鞋子右", "鞋子1", RightShoeSlot,
  1455. rightTexture, new Material(Shader.Find("Sprites/Default")));
  1456. }
  1457. else if (bodyPart == BodyPart.Head)
  1458. {
  1459. Head = armatureName;
  1460. slotList.Add(HeadSlot);
  1461. }
  1462. else if (bodyPart == BodyPart.Wing)
  1463. {
  1464. if (Wing == armatureName)
  1465. {
  1466. return;
  1467. }
  1468. else
  1469. {
  1470. Wing = armatureName;
  1471. slotList.Add(WingSlot);
  1472. }
  1473. }
  1474. else if (bodyPart == BodyPart.Dress)
  1475. {
  1476. Dress = armatureName;
  1477. slotList.Add(DressSlot);
  1478. }
  1479. else if (bodyPart == BodyPart.Mouse)
  1480. {
  1481. Mouse = armatureName;
  1482. slotList.Add(MouseSlot);
  1483. }
  1484. else if (bodyPart == BodyPart.Headwear)
  1485. {
  1486. HeadWear = armatureName;
  1487. slotList.Add(HeadWearSlot);
  1488. }
  1489. else if (bodyPart == BodyPart.Leg)
  1490. {
  1491. slotList.Add(LeftLegSlot);
  1492. slotList.Add(RightLegSlot);
  1493. }
  1494. else if (bodyPart == BodyPart.LeftHand)
  1495. {
  1496. slotList.Add(LeftHandSlot);
  1497. }
  1498. else if (bodyPart == BodyPart.RightHand)
  1499. {
  1500. slotList.Add(RightHandSlot);
  1501. }
  1502. else if (bodyPart == BodyPart.Neck)
  1503. {
  1504. slotList.Add(NeckSlot);
  1505. }
  1506. else if (bodyPart == BodyPart.LeftLongSleeve)
  1507. {
  1508. LeftLongSleeve = armatureName;
  1509. ChangeClose(LeftLongSleeveUAC, armatureName);
  1510. return;
  1511. }
  1512. else if (bodyPart == BodyPart.LeftShortSleeve)
  1513. {
  1514. LeftShortSleeve = armatureName;
  1515. slotList.Add(LeftShortSleeveSlot);
  1516. }
  1517. else if (bodyPart == BodyPart.RightLongSleeve)
  1518. {
  1519. RightLongSleeve = armatureName;
  1520. ChangeClose(RightLongSleeveUAC, armatureName);
  1521. return;
  1522. }
  1523. else if (bodyPart == BodyPart.RightShortSleeve)
  1524. {
  1525. RightShortSleeve = armatureName;
  1526. slotList.Add(RightShortSleeveSlot);
  1527. }
  1528. else
  1529. {
  1530. throw new Exception();
  1531. }
  1532. ChangeClose(slotList, armatureName, setDepth);
  1533. if (bodyPart == BodyPart.Wing)
  1534. {
  1535. TweenRoot tweenRoot = transform.FindChild("Armature/" + Wing).GetChild(0).CreateTweenScale(new Vector3(1, 1, 1), new Vector3(0.6f, 1, 1), 0.75f, true, true, Curve.Linear);
  1536. tweenRoot.PingPong = true;
  1537. tweenRoot.StartForward();
  1538. }
  1539. }
  1540. public void ChangeClose(List<DragonBones.Slot> slotList, string armatureName, bool setDepth = true)
  1541. {
  1542. for (int i = 0; i < slotList.Count; i++)
  1543. {
  1544. slotList[i].childArmature = UnityFactory.factory.BuildArmature(armatureName, null, null, null, true);
  1545. slotList[i].UnityTransform = slotList[i].childArmature.UnityTransform.parent;
  1546. }
  1547. if (setDepth)
  1548. {
  1549. DelayCall.Call
  1550. (
  1551. 1,
  1552. () =>
  1553. {
  1554. ResetDepth();
  1555. if (IsDisplayInUGUI) DisplayInUI(UGUIScale);
  1556. }
  1557. );
  1558. }
  1559. }
  1560. public void ChangeClose(UnityArmatureComponent uac, string armatureName, bool setDepth = true)
  1561. {
  1562. if (armatureName == "Empty")
  1563. {
  1564. uac.SetActive(false);
  1565. }
  1566. else
  1567. {
  1568. uac.SetActive(true);
  1569. }
  1570. if (setDepth)
  1571. {
  1572. DelayCall.Call
  1573. (
  1574. 1,
  1575. () =>
  1576. {
  1577. ResetDepth();
  1578. if (IsDisplayInUGUI) DisplayInUI(UGUIScale);
  1579. }
  1580. );
  1581. }
  1582. }
  1583. #endregion
  1584. }