Player.cs 58 KB

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