Player.cs 60 KB

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