Player.cs 58 KB

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