Player.cs 58 KB

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