Player.cs 58 KB

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