Player.cs 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007
  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. Type = TypeParse(attribute[2].Value);
  145. Index = Auxiliary.StringToInt(attribute[3].Value, -1);
  146. BuyLevel = Auxiliary.StringToInt(attribute[5].Value, 0);
  147. BuyCurrent = Auxiliary.CurrentParse(attribute[6].Value);
  148. BuyCost = Auxiliary.StringToDouble(attribute[7].Value, 0);
  149. BuyAdvanceCurrent = Auxiliary.CurrentParse(attribute[8].Value);
  150. BuyAdvanceCost = Auxiliary.StringToDouble(attribute[9].Value, 0);
  151. PixelSize = Auxiliary.StringToInt(attribute[10].Value, 100);
  152. IconOffset = Auxiliary.StringToFloat(attribute[11].Value, 0);
  153. IconOffset1 = Auxiliary.StringToVector(',', attribute[12].Value, new Vector3());
  154. IconOffset2 = Auxiliary.StringToVector(',', attribute[13].Value, new Vector3());
  155. Sprites = SpriteParse(attribute[14].Value);
  156. SpriteAlpha = Auxiliary.StringToFloat(attribute[15].Value, 1);
  157. ExtraBodyParts = BodyPartParses(attribute[17].Value);
  158. ExtraArmatureNames = Auxiliary.StringToStrings(',', attribute[18].Value, new List<string>()).ToArray();
  159. IconOffset0 = Auxiliary.StringToVector(',', attribute[20].Value, new Vector3());
  160. desc = attribute[21].Value;
  161. if (Unavailable)
  162. {
  163. return;
  164. }
  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. return CloseType.Shoe;
  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(bool playAudio = true)
  506. {
  507. Unlock();
  508. if (playAudio)
  509. {
  510. AudioManager.PlayClip(AudioLabel.GetCurrent);
  511. }
  512. PlayerManager.BoughtCloseIDs.UniqueAdd(ID);
  513. }
  514. public void NavigateToChargeFromDressroom()
  515. {
  516. TweenRoot tweenRoot = ResourceManager.Get(CanvasLabel.Pa_Info).TweenBacCG();
  517. tweenRoot.AddEventOnetime
  518. (
  519. EventType.BackwardFinish,
  520. () =>
  521. {
  522. PlayerManager.Player.LeaveDressroom();
  523. }
  524. );
  525. ResourceManager.Get(CanvasLabel.B_SignIn0).GetTweenCG().AddEventOnetime
  526. (
  527. EventType.ForwardFinish,
  528. () =>
  529. {
  530. ResourceManager.Get(CanvasLabel.F_Manage0).TweenForVec();
  531. }
  532. );
  533. }
  534. public void ChangeDress(Player player, bool resetDepth = true)
  535. {
  536. player.ChangeClose(BodyPart, ArmatureName, resetDepth);
  537. if (Unavailable)
  538. {
  539. return;
  540. }
  541. if (ExtraBodyParts.Length > 0)
  542. {
  543. player.ChangeClose(BodyPart.LeftLongSleeve, "Empty", resetDepth);
  544. player.ChangeClose(BodyPart.LeftShortSleeve, "Empty", resetDepth);
  545. player.ChangeClose(BodyPart.RightLongSleeve, "Empty", resetDepth);
  546. player.ChangeClose(BodyPart.RightShortSleeve, "Empty", resetDepth);
  547. }
  548. for (int i = 0; i < ExtraArmatureNames.Length; i++)
  549. {
  550. player.ChangeClose(ExtraBodyParts[i], ExtraArmatureNames[i], resetDepth);
  551. }
  552. }
  553. public void SaveDressData() //仅在购买完成时调用
  554. {
  555. SaveDressData(BodyPart);
  556. if (BodyPart == BodyPart.Top)
  557. {
  558. PlayerManager.DressDatas[8] = "Empty";
  559. PlayerManager.DressDatas[9] = "Empty";
  560. PlayerManager.DressDatas[10] = "Empty";
  561. PlayerManager.DressDatas[11] = "Empty";
  562. foreach (var bodyPart in ExtraBodyParts)
  563. {
  564. SaveDressData(bodyPart);
  565. }
  566. }
  567. }
  568. public void SaveDressData(BodyPart bodyPart) //仅在购买完成时调用
  569. {
  570. if (bodyPart == BodyPart.LeftLongSleeve)
  571. {
  572. PlayerManager.DressDatas[8] = PlayerManager.Player.LeftLongSleeve;
  573. }
  574. else if (bodyPart == BodyPart.LeftShortSleeve)
  575. {
  576. PlayerManager.DressDatas[9] = PlayerManager.Player.LeftShortSleeve;
  577. }
  578. else if (bodyPart == BodyPart.RightLongSleeve)
  579. {
  580. PlayerManager.DressDatas[10] = PlayerManager.Player.RightLongSleeve;
  581. }
  582. else if (bodyPart == BodyPart.RightShortSleeve)
  583. {
  584. PlayerManager.DressDatas[11] = PlayerManager.Player.RightShortSleeve;
  585. }
  586. else if (bodyPart == BodyPart.Top)
  587. {
  588. PlayerManager.DressDatas[4] = PlayerManager.Player.Top;
  589. }
  590. else if (bodyPart == BodyPart.Shoe)
  591. {
  592. PlayerManager.DressDatas[2] = PlayerManager.Player.Shoe;
  593. }
  594. else if (bodyPart == BodyPart.Head)
  595. {
  596. PlayerManager.DressDatas[0] = PlayerManager.Player.Head;
  597. }
  598. else if (bodyPart == BodyPart.Wing)
  599. {
  600. PlayerManager.DressDatas[7] = PlayerManager.Player.Wing;
  601. }
  602. else if (bodyPart == BodyPart.Dress)
  603. {
  604. PlayerManager.DressDatas[1] = PlayerManager.Player.Dress;
  605. }
  606. else if (bodyPart == BodyPart.Headwear)
  607. {
  608. PlayerManager.DressDatas[3] = PlayerManager.Player.HeadWear;
  609. }
  610. else
  611. {
  612. throw new Exception();
  613. }
  614. }
  615. public void OnLevelChange()
  616. {
  617. if (Unavailable)
  618. {
  619. return;
  620. }
  621. if (IsBought)
  622. {
  623. return;
  624. }
  625. if (BuyLevel <= Manager.GardenLevel)
  626. {
  627. BuyBtn.interactable = true;
  628. BuyBtn.image.material = null;
  629. }
  630. }
  631. public ExchangeInfo GetExchangeValue(float rate, StaticsManager.ConsumeModule consumeModule)
  632. {
  633. ExchangeInfo info = ExchangeInfo.GetExchangeInfo(BuyCurrent, BuyCost, rate);
  634. ExchangeInfo.GetExchangeValue(info, consumeModule);
  635. return info;
  636. }
  637. public static List<KV<Current, KV<int, double>>> GetTotalBuyCost(bool excludeBought, List<int> closeIDs)
  638. {
  639. int coinAmount = 0;
  640. int diamondAmount = 0;
  641. double totalCoin = 0;
  642. double totalDiamond = 0;
  643. foreach (var closeID in closeIDs)
  644. {
  645. if (PlayerManager.CloseItemDictionary[closeID].Sprites == null) continue;
  646. if (PlayerManager.CloseItemDictionary[closeID].ArmatureName == "Empty") continue;
  647. CloseItem closeItem = PlayerManager.CloseItemDictionary[closeID];
  648. if (closeItem.IsBought && excludeBought) continue;
  649. if (closeItem.BuyCurrent == Current.Coin)
  650. {
  651. totalCoin += closeItem.BuyCost;
  652. coinAmount++;
  653. }
  654. if (closeItem.BuyCurrent == Current.Diamond)
  655. {
  656. totalDiamond += closeItem.BuyCost;
  657. diamondAmount++;
  658. }
  659. }
  660. List<KV<Current, KV<int, double>>> results = new List<KV<Current, KV<int, double>>>();
  661. results.Add(new KV<Current, KV<int, double>>(Current.Coin, new KV<int, double>(coinAmount, totalCoin)));
  662. results.Add(new KV<Current, KV<int, double>>(Current.Diamond, new KV<int, double>(diamondAmount, totalDiamond)));
  663. return results;
  664. }
  665. }
  666. public enum PlayerDirection
  667. {
  668. Left = 0,
  669. Right = 1,
  670. }
  671. public class Player : Regist , IPointerClickHandler
  672. {
  673. #region Config
  674. public static string IdleAnimationName = "newAnimation";
  675. public static string JumpAnimationName = "newAnimation1";
  676. public static string WalkAnimationName = "newAnimation2";
  677. public static string RunAnimationName = "newAnimation3";
  678. public static bool InDressRoom;
  679. public static float InDressRoomJumpFrequency;
  680. public float JumpTime;
  681. public float JumpTimer;
  682. public PlayerDirection PlayerDirection
  683. {
  684. get { return playerDirection; }
  685. set
  686. {
  687. playerDirection = value;
  688. Flip(playerDirection);
  689. }
  690. }
  691. public PlayerDirection playerDirection = PlayerDirection.Left;
  692. public Vector3 PosInGarden;
  693. public bool IsDisplayInUGUI;
  694. public float UGUIScale;
  695. public bool PlayAnimFlag1;
  696. public bool PlayAnimFlag2;
  697. public string CurrentAnimationName;
  698. public Material Material;
  699. public MeshFilter ExpressionMeshFilter;
  700. public Dictionary<string, Transform> ChildDic = new Dictionary<string, Transform>();
  701. private string ExpressionName;
  702. private Coroutine ResetExpressionCoroutine;
  703. public static Dictionary<string, Vector3> LeftExpressionPositionDictionary = new Dictionary<string, Vector3>
  704. {
  705. {"郁闷", new Vector3(0, -0.22f, -0.00001f)},
  706. {"汗颜", new Vector3(0.35f, 0.91f, -0.00001f)},
  707. {"惊讶", new Vector3(0.09f, -0.07f, -0.00001f)},
  708. {"开心", new Vector3(0.1f, -0.22f, -0.00001f)},
  709. {"哭", new Vector3(0.07f, -0.64f, -0.00001f)},
  710. {"期待", new Vector3(0.04f, -0.20f, -0.00001f)},
  711. {"色咪咪", new Vector3(0.03f, -0.09f, -0.00001f)},
  712. {"委屈", new Vector3(0f, -0.27f, -0.00001f)},
  713. };
  714. public static Dictionary<string, Vector3> RightExpressionPositionDictionary = new Dictionary<string, Vector3>
  715. {
  716. {"郁闷", new Vector3(0, -0.22f, -0.00001f)},
  717. {"汗颜", new Vector3(-0.22f, 0.91f, -0.00001f)},
  718. {"惊讶", new Vector3(-0.09f, -0.07f, -0.00001f)},
  719. {"开心", new Vector3(-0.1f, -0.22f, -0.00001f)},
  720. {"哭", new Vector3(-0.07f, -0.64f, -0.00001f)},
  721. {"期待", new Vector3(-0.04f, -0.20f, -0.00001f)},
  722. {"色咪咪", new Vector3(-0.03f, -0.09f, -0.00001f)},
  723. {"委屈", new Vector3(0f, -0.27f, -0.00001f)},
  724. };
  725. #region 换装
  726. public Transform Shadow;
  727. private Transform Pivot
  728. {
  729. get
  730. {
  731. if (pivot == null)
  732. {
  733. pivot = UAC.transform.Find(PlayerLabel.Pivot);
  734. }
  735. return pivot;
  736. }
  737. }
  738. private Transform pivot;
  739. public string Eye;
  740. public string Top;
  741. public string Shoe;
  742. public string Head;
  743. public string Wing;
  744. public string Dress;
  745. public string Mouse;
  746. public string HeadWear;
  747. public string LeftLongSleeve;
  748. public string LeftShortSleeve;
  749. public string RightLongSleeve;
  750. public string RightShortSleeve;
  751. private string TempClose;
  752. public DragonBones.Slot NeckSlot;
  753. public DragonBones.Slot LeftHandSlot;
  754. public DragonBones.Slot RightHandSlot;
  755. public DragonBones.Slot LeftLegSlot;
  756. public DragonBones.Slot RightLegSlot;
  757. public DragonBones.Slot LeftShortSleeveSlot;
  758. public DragonBones.Slot RightShortSleeveSlot;
  759. public DragonBones.Slot EyeSlot;
  760. public DragonBones.Slot TopSlot;
  761. public DragonBones.Slot HeadSlot;
  762. public DragonBones.Slot DressSlot;
  763. public DragonBones.Slot WingSlot;
  764. public DragonBones.Slot MouseSlot;
  765. public DragonBones.Slot LeftShoeSlot;
  766. public DragonBones.Slot RightShoeSlot;
  767. public DragonBones.Slot HeadWearSlot;
  768. public string leftShoeDisplayName = "鞋子1";
  769. public string rightShoeDisplayName = "鞋子1";
  770. public UnityArmatureComponent UAC;
  771. //public UnityArmatureComponent LeftShortSleeveUAC;
  772. //public UnityArmatureComponent RightShortSleeveUAC;
  773. public UnityArmatureComponent LeftLongSleeveUAC;
  774. public UnityArmatureComponent RightLongSleeveUAC;
  775. #endregion
  776. #endregion
  777. public override bool InitAtOnce()
  778. {
  779. if (base.InitAtOnce())
  780. {
  781. return true;
  782. }
  783. enabled = true;
  784. Auxiliary.CompileDic(transform, ChildDic);
  785. Vector3 bigShadowScale = new Vector3(1.820952f, 2.418199f, 1.820952f);
  786. Vector3 smallShadowScale = new Vector3(1.081191f, 1.435807f, 1.081191f);
  787. Shadow = ChildDic[PlayerLabel.Shadow];
  788. Shadow.CreateStreamScale
  789. (
  790. new List<float>() {0, 0, 0},
  791. new List<float>() {0.33f, 0.33f, 0.33f, 0.33f},
  792. new List<VecPair>() {new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale), new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale)},
  793. true,
  794. true,
  795. Curve.EaseOutQuad
  796. );
  797. MeshFilter meshFilter = Shadow.GetComponent<MeshFilter>();
  798. meshFilter.mesh = SpriteUtility.CreateMesh(ResourceManager.LoadSprite(ResourceLabel.FlowerShadow, Folder.Scene));
  799. meshFilter.mesh.SetUVs(1, Enumerable.Repeat(new Vector2(0, 1), meshFilter.mesh.vertices.Length).ToList());
  800. return false;
  801. }
  802. public void Update()
  803. {
  804. if (InDressRoom)
  805. {
  806. JumpTimer += Time.deltaTime;
  807. if (JumpTimer > JumpTime)
  808. {
  809. if (!PlayAnimFlag1 && !PlayAnimFlag2)
  810. {
  811. PlayAnim(JumpAnimationName);
  812. }
  813. PlayAnimFlag2 = true;
  814. }
  815. if (JumpTimer > InDressRoomJumpFrequency)
  816. {
  817. PlayAnimFlag2 = false;
  818. JumpTime = Mathf.Lerp(0, InDressRoomJumpFrequency, Random.Range(0f, 1f));
  819. JumpTimer = 0;
  820. }
  821. }
  822. if (SFSManager.GardenSmartFox.PlazaRoomController.InPlazaRoom)
  823. {
  824. ResetDepth();
  825. }
  826. }
  827. public void OnAnimStart(string str, EventObject eventObject)
  828. {
  829. if (eventObject.animationState.name == JumpAnimationName)
  830. {
  831. Shadow.StreamReForScale();
  832. PlayAnimFlag1 = true;
  833. TempClose = Eye;
  834. ChangeClose(BodyPart.Eye, "眼睛表情1");
  835. }
  836. else if (eventObject.animationState.name == IdleAnimationName)
  837. {
  838. PlayAnimFlag1 = false;
  839. if (TempClose != null)
  840. {
  841. ChangeClose(BodyPart.Eye, TempClose);
  842. }
  843. }
  844. if (IsDisplayInUGUI)
  845. {
  846. DisplayInUI(UGUIScale, false);
  847. }
  848. }
  849. public void PlayAnim(string animName)
  850. {
  851. if (PlayAnimFlag1)
  852. {
  853. return;
  854. }
  855. if (UAC.anim.lastAnimationName == animName)
  856. {
  857. return;
  858. }
  859. if (SFSManager.GardenSmartFox.PlazaRoomController.JoinedPlazaRoom)
  860. {
  861. CurrentAnimationName = animName;
  862. }
  863. UAC.anim.FadeIn(animName, GetFadeInTime(UAC.anim.lastAnimationName, animName));
  864. }
  865. public float GetFadeInTime(string lastAnimation, string targetAnimation)
  866. {
  867. if (lastAnimation == JumpAnimationName && targetAnimation == IdleAnimationName)
  868. return -1f;
  869. else
  870. return 0.1f;
  871. //throw new Exception();
  872. }
  873. public void SetAllCollider(bool enable)
  874. {
  875. BoxCollider2D[] colliders = GetComponentsInChildren<BoxCollider2D>();
  876. for (int i = 0; i < colliders.Length; i++)
  877. {
  878. colliders[i].enabled = enable;
  879. }
  880. }
  881. public Action onClick;
  882. public void OnPointerClick(PointerEventData eventData)
  883. {
  884. //AudioManager.PlayClip(AudioLabel.GetCurrent);
  885. //PlayAnim(JumpAnimationName);
  886. if (Manager.GardenLevel >= TutorialManager.ChangeMouseTutorialLevel)
  887. {
  888. ChangeMousePanel.Open();
  889. }
  890. onClick.SafeInvoke();
  891. }
  892. public void ResetExpression()
  893. {
  894. ExpressionMeshFilter.SetActive(false);
  895. EyeSlot.UnityTransform.GetChild(0).SetActive(true);
  896. MouseSlot.UnityTransform.GetChild(0).SetActive(true);
  897. }
  898. public void ChangeExpression(string expressionName, float duration)
  899. {
  900. ExpressionName = expressionName;
  901. Sprite sprite = ResourceManager.LoadSprite(expressionName, Folder.Scene);
  902. Texture2D texture = sprite.texture;
  903. ExpressionMeshFilter.GetComponent<MeshRenderer>().material.SetTexture("_MainTex", texture);
  904. ExpressionMeshFilter.sharedMesh = SpriteUtility.CreateMesh(sprite);
  905. ExpressionMeshFilter.mesh.SetUVs(1, Enumerable.Repeat(new Vector2(0, 1), ExpressionMeshFilter.mesh.vertices.Length).ToList());
  906. ExpressionMeshFilter.transform.parent = EyeSlot.UnityTransform;
  907. ExpressionMeshFilter.SetActive(true);
  908. EyeSlot.UnityTransform.GetChild(0).SetActive(false);
  909. MouseSlot.UnityTransform.GetChild(0).SetActive(false);
  910. FlipExpression(expressionName, PlayerDirection);
  911. if (ResetExpressionCoroutine != null)
  912. Auxiliary.Instance.StopCoroutine(ResetExpressionCoroutine);
  913. ResetExpressionCoroutine = Auxiliary.Instance.DelayCall
  914. (
  915. () =>
  916. {
  917. ResetExpression();
  918. },
  919. duration
  920. );
  921. }
  922. public void Flip(PlayerDirection direction)
  923. {
  924. FlipExpression(ExpressionName, direction);
  925. if (direction == PlayerDirection.Left)
  926. {
  927. UAC.armature.flipX = false;
  928. playerDirection = PlayerDirection.Left;
  929. }
  930. else if (direction == PlayerDirection.Right)
  931. {
  932. UAC.armature.flipX = true;
  933. playerDirection = PlayerDirection.Right;
  934. }
  935. else
  936. {
  937. throw new Exception();
  938. }
  939. ResetDepth();
  940. DelayCall.Call(1, () => Shadow.SetX(Pivot.position.x));
  941. }
  942. public void FlipExpression(string expressionName, PlayerDirection direction)
  943. {
  944. if (string.IsNullOrEmpty(ExpressionName))
  945. {
  946. return;
  947. }
  948. if (direction == PlayerDirection.Left)
  949. {
  950. ExpressionMeshFilter.transform.eulerAngles = new Vector3();
  951. ExpressionMeshFilter.transform.localPosition = LeftExpressionPositionDictionary[ExpressionName];
  952. }
  953. else if (direction == PlayerDirection.Right)
  954. {
  955. UAC.armature.flipX = true;
  956. ExpressionMeshFilter.transform.eulerAngles = new Vector3(0, 180, 0);
  957. ExpressionMeshFilter.transform.localPosition = RightExpressionPositionDictionary[ExpressionName];
  958. playerDirection = PlayerDirection.Right;
  959. }
  960. else
  961. {
  962. throw new Exception();
  963. }
  964. }
  965. public void SaveDressDatas(bool showNavigate)
  966. {
  967. AudioManager.PlayClip(AudioLabel.ClickButton);
  968. List<CloseItem> closeUnitList = new List<CloseItem>();
  969. closeUnitList.Add(PlayerManager.CloseItemDictionary[PlayerManager.CloseIDDictionary[Head]]);
  970. closeUnitList.Add(PlayerManager.CloseItemDictionary[PlayerManager.CloseIDDictionary[Dress]]);
  971. closeUnitList.Add(PlayerManager.CloseItemDictionary[PlayerManager.CloseIDDictionary[Shoe]]);
  972. closeUnitList.Add(PlayerManager.CloseItemDictionary[PlayerManager.CloseIDDictionary[HeadWear]]);
  973. closeUnitList.Add(PlayerManager.CloseItemDictionary[PlayerManager.CloseIDDictionary[Top]]);
  974. if (Wing != "Empty")
  975. {
  976. closeUnitList.Add(PlayerManager.CloseItemDictionary[PlayerManager.CloseIDDictionary[Wing]]);
  977. }
  978. for (int i = 0; i < closeUnitList.Count; i++)
  979. {
  980. if (!closeUnitList[i].IsBought)
  981. {
  982. if (showNavigate)
  983. {
  984. BuyDressNavigate(closeUnitList);
  985. }
  986. return;
  987. }
  988. }
  989. PlayerManager.DressDatas[0] = Head;
  990. PlayerManager.DressDatas[1] = Dress;
  991. PlayerManager.DressDatas[2] = Shoe;
  992. PlayerManager.DressDatas[3] = HeadWear;
  993. PlayerManager.DressDatas[4] = Top;
  994. PlayerManager.DressDatas[7] = Wing;
  995. PlayerManager.DressDatas[8] = LeftLongSleeve;
  996. PlayerManager.DressDatas[9] = LeftShortSleeve;
  997. PlayerManager.DressDatas[10] = RightLongSleeve;
  998. PlayerManager.DressDatas[11] = RightShortSleeve;
  999. Toast.Show(1.5f, Language.GetStr(LanguageLabel.UI__P_SaveSucceed));
  1000. }
  1001. public void ResetDressDatas()
  1002. {
  1003. AudioManager.PlayClip(AudioLabel.ClickButton);
  1004. List<string> dressData = new List<string>(PlayerManager.DressDatas);
  1005. dressData[5] = Eye;
  1006. PlayerManager.BuildPlayer(dressData);
  1007. }
  1008. public List<int> GetCurrentChangableDressIDs()
  1009. {
  1010. List<int> ids = new List<int>();
  1011. ids.Add(PlayerManager.CloseIDDictionary[Head]);
  1012. ids.Add(PlayerManager.CloseIDDictionary[Dress]);
  1013. ids.Add(PlayerManager.CloseIDDictionary[Shoe]);
  1014. ids.Add(PlayerManager.CloseIDDictionary[HeadWear]);
  1015. ids.Add(PlayerManager.CloseIDDictionary[Top]);
  1016. ids.Add(PlayAnimFlag1 ? PlayerManager.CloseIDDictionary[TempClose] : PlayerManager.CloseIDDictionary[Eye]);
  1017. ids.Add(PlayerManager.CloseIDDictionary[Mouse]);
  1018. ids.Add(PlayerManager.CloseIDDictionary[Wing]);
  1019. return ids;
  1020. }
  1021. public static List<string> DressIDToDressName(List<int> ids)
  1022. {
  1023. List<string> names = new List<string>();
  1024. foreach (var id in ids)
  1025. {
  1026. names.Add(PlayerManager.CloseItemDictionary[id].ArmatureName);
  1027. }
  1028. return names;
  1029. }
  1030. public List<string> GetCurrentDressNames()
  1031. {
  1032. List<string> names = new List<string>();
  1033. return names;
  1034. }
  1035. public List<string> GetCurrentChangableDressNames()
  1036. {
  1037. List<string> names = new List<string>();
  1038. names.Add(Head);
  1039. names.Add(Dress);
  1040. names.Add(Shoe);
  1041. names.Add(HeadWear);
  1042. names.Add(Top);
  1043. names.Add(Wing);
  1044. if (PlayAnimFlag1) names.Add(TempClose);
  1045. else names.Add(Eye);
  1046. names.Add(Mouse);
  1047. names.Add(Wing);
  1048. return names;
  1049. }
  1050. public List<string> GetAllDressNames()
  1051. {
  1052. List<string> names = new List<string>();
  1053. names.Add(Head);
  1054. names.Add(Dress);
  1055. names.Add(Shoe);
  1056. names.Add(HeadWear);
  1057. names.Add(Top);
  1058. if (PlayAnimFlag1) names.Add(TempClose);
  1059. else names.Add(Eye);
  1060. names.Add(Mouse);
  1061. names.Add(Wing);
  1062. names.Add(LeftLongSleeve);
  1063. names.Add(LeftShortSleeve);
  1064. names.Add(RightLongSleeve);
  1065. names.Add(RightShortSleeve);
  1066. return names;
  1067. }
  1068. public void BuyDressNavigate(List<CloseItem> closeUnitList)
  1069. {
  1070. for (int i = 0; i < closeUnitList.Count; i++)
  1071. {
  1072. if (closeUnitList[i].IsBought)
  1073. {
  1074. closeUnitList.RemoveAt(i--);
  1075. }
  1076. else
  1077. {
  1078. closeUnitList[i].BuyBtn.onClick.Invoke();
  1079. closeUnitList.RemoveAt(i--);
  1080. ResourceManager.Get(CanvasLabel.Pa_Info).GetTweenCG().AddEventOnetime
  1081. (
  1082. EventType.BackwardFinish,
  1083. () =>
  1084. {
  1085. if (closeUnitList.Count == 0)
  1086. {
  1087. SaveDressDatas(false);
  1088. }
  1089. else
  1090. {
  1091. BuyDressNavigate(closeUnitList);
  1092. }
  1093. }
  1094. );
  1095. return;
  1096. }
  1097. }
  1098. }
  1099. public void LeaveDressroom()
  1100. {
  1101. bool allSave = true;
  1102. bool allBought = true;
  1103. List<string> currentDerssData = new List<string>() { Head, Dress, Shoe, HeadWear, Top, Wing };
  1104. if (currentDerssData[0] != PlayerManager.DressDatas[0]) allSave = false;
  1105. if (currentDerssData[1] != PlayerManager.DressDatas[1]) allSave = false;
  1106. if (currentDerssData[2] != PlayerManager.DressDatas[2]) allSave = false;
  1107. if (currentDerssData[3] != PlayerManager.DressDatas[3]) allSave = false;
  1108. if (currentDerssData[4] != PlayerManager.DressDatas[4]) allSave = false;
  1109. if (currentDerssData[5] != PlayerManager.DressDatas[7]) allSave = false;
  1110. for (int i = 0; i < currentDerssData.Count; i++)
  1111. {
  1112. if (!PlayerManager.CloseIDDictionary.ContainsKey(currentDerssData[i]))
  1113. {
  1114. continue;
  1115. }
  1116. int id = PlayerManager.CloseIDDictionary[currentDerssData[i]];
  1117. allBought = allBought && PlayerManager.CloseItemDictionary[id].IsBought;
  1118. //Debug.Log(ManaPlayer.CloseUnitDic[id].Name + " " + ManaPlayer.CloseUnitDic[id].Bought);
  1119. //allSave = allSave && currentDerssData[i] == PlayerManager.DressDatas[i];
  1120. //Debug.Log(currentDerssData[i] + " " + PlayerManager.DressDatas[i]);
  1121. }
  1122. //Debug.Log(allBought);
  1123. //Debug.Log(allSave);
  1124. if (allBought)
  1125. {
  1126. if (allSave)
  1127. {
  1128. ExitDressRoom();
  1129. }
  1130. else
  1131. {
  1132. ResetDressDatas();
  1133. ExitDressRoom();
  1134. }
  1135. }
  1136. else
  1137. {
  1138. Bubble.Show
  1139. (
  1140. null, Language.GetStr(LanguageLabel.UI__P_Return), null, null,
  1141. () =>
  1142. {
  1143. ResetDressDatas();
  1144. ResourceManager.Get(CanvasLabel.K_Bubble).GetTweenGra().AddEventOnetime(EventType.BackwardFinish, () => { ExitDressRoom(); });
  1145. }
  1146. );
  1147. }
  1148. }
  1149. public TweenRoot ExitDressRoom()
  1150. {
  1151. Manager.SceneSwitchFlag = false;
  1152. TweenRoot tweenRoot = ResourceManager.Get(CanvasLabel.I_BlackMask).TweenBacCG();
  1153. tweenRoot.AddEventOnetime
  1154. (
  1155. EventType.BackwardFinish,
  1156. () =>
  1157. {
  1158. transform.SetParent(ResourceManager.Get(GardenLabel.GardenPivot));
  1159. transform.position = PosInGarden;
  1160. //transform.position = ResourceManager.Get(GardenLabel.GardenPlayerPos).position;
  1161. transform.localScale = ResourceManager.Get(GardenLabel.GardenPlayerPos).lossyScale;
  1162. ResourceManager.Get(ResourceLabel.Garden).TweenForSr();
  1163. ResourceManager.Get(DressroomLabel.DressRoom).TweenBacSr();
  1164. ResourceManager.Get(CanvasLabel.C_Main).TweenForCG();
  1165. ResourceManager.Get(CanvasLabel.P_DressRoom).TweenBacCG();
  1166. }
  1167. );
  1168. tweenRoot = ResourceManager.Get(CanvasLabel.P_DressRoom).GetTweenCG();
  1169. tweenRoot.AddEventOnetime
  1170. (
  1171. EventType.BackwardFinish,
  1172. () =>
  1173. {
  1174. SetAllCollider(true);
  1175. InDressRoom = false;
  1176. JumpTimer = 0;
  1177. PlayAnim(IdleAnimationName);
  1178. DeactiveShadow();
  1179. ResourceManager.Get(CanvasLabel.B_SignIn0).TweenForCG();
  1180. ResourceManager.Get(CanvasLabel.I_BlackMask).TweenForCG();
  1181. }
  1182. );
  1183. return ResourceManager.Get(CanvasLabel.I_BlackMask).TweenBacCG();
  1184. }
  1185. public void EnterDressRoom()
  1186. {
  1187. if (Manager.SceneSwitchFlag)
  1188. {
  1189. return;
  1190. }
  1191. ResourceManager.Get(CanvasLabel.B_SignIn0).TweenBacCG();
  1192. InDressRoom = true;
  1193. JumpTime = Mathf.Lerp(0, 10, Random.Range(0.5f, 1f));
  1194. Manager.SceneSwitchFlag = true;
  1195. ResourceManager.Get(CanvasLabel.C_Main).TweenBacCG();
  1196. SetAllCollider(false);
  1197. TweenRoot tweenRoot = ResourceManager.Get(CanvasLabel.I_BlackMask).TweenBacCG();
  1198. tweenRoot.AddEventOnetime
  1199. (
  1200. EventType.BackwardFinish,
  1201. () =>
  1202. {
  1203. GardenManager.RetrieveAllElf();
  1204. IAPManager.RetrieveADChest();
  1205. ActiveShadow();
  1206. transform.SetParent(ResourceManager.Get(DressroomLabel.DressRoom));
  1207. PosInGarden = transform.position;
  1208. transform.position = ResourceManager.Get(DressroomLabel.DressRoomPos).position;
  1209. transform.localScale = ResourceManager.Get(DressroomLabel.DressRoomPos).lossyScale;
  1210. ResourceManager.Get(ResourceLabel.Garden).TweenBacSr();
  1211. ResourceManager.Get(DressroomLabel.DressRoom).TweenForSr();
  1212. ResourceManager.Get(CanvasLabel.P_DressRoom).TweenForCG();
  1213. }
  1214. );
  1215. tweenRoot = ResourceManager.Get(CanvasLabel.P_DressRoom).GetTweenCG();
  1216. tweenRoot.AddEventOnetime
  1217. (
  1218. EventType.ForwardFinish,
  1219. () =>
  1220. {
  1221. ResourceManager.Get(CanvasLabel.I_BlackMask).TweenForCG();
  1222. }
  1223. );
  1224. }
  1225. public void ActiveShadow()
  1226. {
  1227. ChildDic[PlayerLabel.ShadowParent].SetActive(true);
  1228. ChildDic[PlayerLabel.ShadowParent].SetLZ(3);
  1229. }
  1230. public void DeactiveShadow()
  1231. {
  1232. Shadow.GetStreamScale().Pause();
  1233. Shadow.GetStreamScale().InOrigin = true;
  1234. ChildDic[PlayerLabel.ShadowParent].SetActive(false);
  1235. }
  1236. private List<TweenRenderer> fadeAnims = new List<TweenRenderer>();
  1237. public void PlayFadeOutAnim()
  1238. {
  1239. fadeAnims = new List<TweenRenderer>();
  1240. if (fadeAnims.Count == 0)
  1241. {
  1242. Renderer[] renderers = PlayerManager.Player.UAC.transform.GetComponentsInChildren<Renderer>(true);
  1243. foreach (var renderer in renderers)
  1244. {
  1245. if (renderer.sharedMaterial == null)
  1246. {
  1247. continue;
  1248. }
  1249. TweenRenderer fadeAnim = AnimManager.CreateTweenRenderer(renderer, 0, 1, 0.25f, true, true, Curve.EaseOutQuad);
  1250. fadeAnim.UseSharedMaterial = true;
  1251. fadeAnims.Add(fadeAnim);
  1252. }
  1253. }
  1254. foreach (var fadeAnim in fadeAnims)
  1255. {
  1256. fadeAnim.StartBackward();
  1257. }
  1258. }
  1259. public void PlayFadeInAnim()
  1260. {
  1261. foreach (var fadeAnim in fadeAnims)
  1262. {
  1263. if (fadeAnim.Target == null)
  1264. {
  1265. continue;
  1266. }
  1267. fadeAnim.StartForward();
  1268. }
  1269. }
  1270. public List<UnityUGUIDisplay> uguiDisplays;
  1271. public void DisplayInUI(float scale, bool adjustScale)
  1272. {
  1273. uguiDisplays = new List<UnityUGUIDisplay>();
  1274. if (adjustScale)
  1275. {
  1276. scale *= ResourceManager.Get<Canvas>(CanvasLabel.Canvas).scaleFactor;
  1277. }
  1278. UGUIScale = scale;
  1279. MeshFilter[] meshFilters = UAC.GetComponentsInChildren<MeshFilter>(true);
  1280. MeshRenderer[] meshRenderers = UAC.GetComponentsInChildren<MeshRenderer>(true);
  1281. for (int i = 0; i < meshRenderers.Length; i++)
  1282. {
  1283. MeshFilter meshFilter = meshFilters[i];
  1284. MeshRenderer meshRenderer = meshRenderers[i];
  1285. UnityUGUIDisplay unityUGUIDisplay = meshRenderer.GetComponent<UnityUGUIDisplay>();
  1286. if (unityUGUIDisplay == null) unityUGUIDisplay = meshRenderer.AddComponent<UnityUGUIDisplay>();
  1287. unityUGUIDisplay.Enable(UAC.transform, meshRenderer.transform, meshFilter, meshRenderer);
  1288. unityUGUIDisplay.raycastTarget = false;
  1289. uguiDisplays.Add(unityUGUIDisplay);
  1290. meshRenderer.enabled = false;
  1291. UAC.transform.localScale = new Vector3(scale, scale, 1);
  1292. SetAllCollider(false);
  1293. DeactiveShadow();
  1294. }
  1295. IsDisplayInUGUI = true;
  1296. ResetDepth();
  1297. }
  1298. public void DisplayInScene()
  1299. {
  1300. MeshRenderer[] meshRenderers = UAC.GetComponentsInChildren<MeshRenderer>(true);
  1301. foreach (var meshRenderer in meshRenderers)
  1302. {
  1303. UnityUGUIDisplay unityUGUIDisplay = meshRenderer.GetComponent<UnityUGUIDisplay>();
  1304. if (unityUGUIDisplay == null) continue;
  1305. unityUGUIDisplay.Disable();
  1306. meshRenderer.enabled = true;
  1307. UAC.transform.localScale = Vector3.one;
  1308. SetAllCollider(true);
  1309. ActiveShadow();
  1310. }
  1311. IsDisplayInUGUI = false;
  1312. ResetDepth();
  1313. }
  1314. #region 换装
  1315. public void CorrectPivot()
  1316. {
  1317. List<Transform> children = new List<Transform>();
  1318. while (transform.childCount > 0)
  1319. {
  1320. children.Add(transform.GetChild(0));
  1321. children.Back(0).parent = null;
  1322. }
  1323. Vector3 offset = Pivot.position - transform.position;
  1324. children[0].position += offset;
  1325. children[1].position += offset;
  1326. transform.position += offset;
  1327. foreach (var collider in GetComponents<BoxCollider2D>())
  1328. {
  1329. collider.offset -= new Vector2(offset.x, offset.y);
  1330. }
  1331. for (int i = 0; i < children.Count; i++)
  1332. {
  1333. children[i].parent = transform;
  1334. }
  1335. }
  1336. public UnityArmatureComponent Build()
  1337. {
  1338. if (!PlayerManager.Inited)
  1339. {
  1340. //UnityFactory.factory.LoadDragonBonesData(ResourceManager.Load<TextAsset>(ResourceLabel.StandSke, Folder.Config));
  1341. //Initializer.DebugText.text = "error : mp0-2";
  1342. //UnityFactory.factory.LoadTextureAtlasData(ResourceManager.Load<TextAsset>(ResourceLabel.StandTex0, Folder.Config), ResourceLabel.StandTexture0);
  1343. //Initializer.DebugText.text = "error : mp0-3";
  1344. //UnityFactory.factory.LoadTextureAtlasData(ResourceManager.Load<TextAsset>(ResourceLabel.StandTex1, Folder.Config), ResourceLabel.StandTexture1);
  1345. PlayerManager.Inited = true;
  1346. }
  1347. UAC = UnityFactory.factory.BuildArmatureComponent("Armature");
  1348. UAC.transform.parent = transform;
  1349. UAC.transform.localScale = new Vector3(1, 1, 1);
  1350. UAC.transform.localPosition = new Vector3();
  1351. UAC.anim.Play(IdleAnimationName);
  1352. UAC.AddEventListener(EventObject.START, OnAnimStart);
  1353. Eye = "眼睛1";
  1354. Top = "上衣1";
  1355. Shoe = "鞋子1";
  1356. Head = "脑壳1";
  1357. Wing = "Empty";
  1358. Dress = "裙子1";
  1359. Mouse = "嘴巴1";
  1360. HeadWear = "头饰品1";
  1361. NeckSlot = UAC.armature.GetSlot("脖子");
  1362. LeftHandSlot = UAC.armature.GetSlot("左手");
  1363. RightHandSlot = UAC.armature.GetSlot("右手");
  1364. LeftLegSlot = UAC.armature.GetSlot("左腿");
  1365. RightLegSlot = UAC.armature.GetSlot("右腿");
  1366. LeftLongSleeveUAC = UAC.transform.Find("长袖9左 (长袖9左)").GetComponent<UnityArmatureComponent>();
  1367. RightLongSleeveUAC = UAC.transform.Find("长袖9右 (长袖9右)").GetComponent<UnityArmatureComponent>();
  1368. LeftShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子左");
  1369. RightShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子右");
  1370. EyeSlot = UAC.armature.GetSlot("眼睛");
  1371. TopSlot = UAC.armature.GetSlot("上衣");
  1372. HeadSlot = UAC.armature.GetSlot("脑壳");
  1373. WingSlot = UAC.armature.GetSlot("翅膀");
  1374. DressSlot = UAC.armature.GetSlot("裙子");
  1375. MouseSlot = UAC.armature.GetSlot("嘴巴");
  1376. LeftShoeSlot = UAC.armature.GetSlot("鞋子左");
  1377. RightShoeSlot = UAC.armature.GetSlot("鞋子右");
  1378. HeadWearSlot = UAC.armature.GetSlot("头饰品");
  1379. ChangeClose(BodyPart.Eye, "眼睛1", false);
  1380. ChangeClose(BodyPart.Top, "上衣1", false);
  1381. ChangeClose(BodyPart.Shoe, "鞋子1", false);
  1382. ChangeClose(BodyPart.Head, "脑壳1", false);
  1383. ChangeClose(BodyPart.Dress, "裙子1", false);
  1384. ChangeClose(BodyPart.Mouse, "嘴巴1", false);
  1385. ChangeClose(BodyPart.Headwear, "头饰品1", false);
  1386. ChangeClose(BodyPart.LeftLongSleeve, "Empty", false);
  1387. ChangeClose(BodyPart.RightLongSleeve, "Empty", false);
  1388. ChangeClose(BodyPart.LeftShortSleeve, "短袖2左", false);
  1389. ChangeClose(BodyPart.RightShortSleeve, "短袖2右", false);
  1390. CorrectPivot();
  1391. Material = UAC.GetComponentInChildren<MeshRenderer>().sharedMaterial;
  1392. Shadow.GetComponent<MeshRenderer>().sharedMaterial = Material;
  1393. ExpressionMeshFilter = ChildDic[PlayerLabel.ExpressionMeshFilter].GetComponent<MeshFilter>();
  1394. ExpressionMeshFilter.GetComponent<MeshRenderer>().sharedMaterial = Material;
  1395. return UAC;
  1396. }
  1397. public UnityArmatureComponent BuildPink()
  1398. {
  1399. Build();
  1400. ChangeClose(BodyPart.Eye, "眼睛3", false);
  1401. ChangeClose(BodyPart.Top, "上衣3", false);
  1402. ChangeClose(BodyPart.Shoe, "鞋子3", false);
  1403. ChangeClose(BodyPart.Head, "脑壳3", false);
  1404. ChangeClose(BodyPart.Wing, "Empty", false);
  1405. ChangeClose(BodyPart.Dress, "裙子3", false);
  1406. ChangeClose(BodyPart.Mouse, "嘴巴3", false);
  1407. ChangeClose(BodyPart.Headwear, "头饰品3", false);
  1408. ResetDepth();
  1409. return UAC;
  1410. }
  1411. public UnityArmatureComponent BuildBlond()
  1412. {
  1413. Build();
  1414. ChangeClose(BodyPart.Wing, "Empty", false);
  1415. ResetDepth();
  1416. return UAC;
  1417. }
  1418. public UnityArmatureComponent BuildBrown()
  1419. {
  1420. Build();
  1421. ChangeClose(BodyPart.Eye, "眼睛2", false);
  1422. ChangeClose(BodyPart.Top, "上衣2", false);
  1423. ChangeClose(BodyPart.Shoe, "鞋子2", false);
  1424. ChangeClose(BodyPart.Head, "脑壳2", false);
  1425. ChangeClose(BodyPart.Wing, "Empty", false);
  1426. ChangeClose(BodyPart.Dress, "裙子2", false);
  1427. ChangeClose(BodyPart.Mouse, "嘴巴2", false);
  1428. ChangeClose(BodyPart.Headwear, "头饰品2", false);
  1429. ResetDepth();
  1430. return UAC;
  1431. }
  1432. public void ResetDepth()
  1433. {
  1434. UAC.transform.SetLZ(0.7f);
  1435. SetSlotLocalZ(WingSlot, 0.00003f);
  1436. SetSlotLocalZ(EyeSlot, -0.00007f);
  1437. SetSlotLocalZ(TopSlot, -0.00003f);
  1438. SetSlotLocalZ(MouseSlot, -0.00007f);
  1439. SetSlotLocalZ(HeadWearSlot, -0.00008f);
  1440. SetSlotLocalZ(LeftShoeSlot, -0.00001f);
  1441. SetSlotLocalZ(RightShoeSlot, -0.00001f);
  1442. SetSlotLocalZ(LeftLegSlot, 0);
  1443. SetSlotLocalZ(RightLegSlot, 0);
  1444. SetSlotLocalZ(NeckSlot, 0.00001f);
  1445. SetSlotLocalZ(LeftHandSlot, -0.00001f);
  1446. SetSlotLocalZ(RightHandSlot, -0.00001f);
  1447. SetSlotLocalZ(LeftShortSleeveSlot, -0.000015f);
  1448. SetSlotLocalZ(RightShortSleeveSlot, -0.000015f);
  1449. SetSlotLocalZ(HeadSlot, 0);
  1450. if (HeadSlot.UnityTransform != null && HeadSlot.UnityTransform.childCount > 1)
  1451. {
  1452. HeadSlot.UnityTransform.GetChild(0).SetLZ(0.00002f);
  1453. HeadSlot.UnityTransform.GetChild(1).SetLZ(-0.00006f);
  1454. }
  1455. SetSlotLocalZ(DressSlot, -0.00002f);
  1456. if (DressSlot.UnityTransform != null && DressSlot.UnityTransform.childCount > 1)
  1457. {
  1458. DressSlot.UnityTransform.GetChild(0).SetLZ(0.00002f);
  1459. DressSlot.UnityTransform.GetChild(1).SetLZ(0);
  1460. }
  1461. LeftLongSleeveUAC.transform.SetLZ(-0.000015f);
  1462. RightLongSleeveUAC.transform.SetLZ(-0.000015f);
  1463. if (IsDisplayInUGUI)
  1464. {
  1465. uguiDisplays.MySort((display1, display0) =>
  1466. display1.transform.position.z < display0.transform.position.z);
  1467. foreach (var display in uguiDisplays)
  1468. {
  1469. if (display.dbGraphic == null)
  1470. {
  1471. continue;
  1472. }
  1473. display.dbGraphic.transform.SetParent(transform.parent);
  1474. }
  1475. foreach (var display in uguiDisplays)
  1476. {
  1477. if (display.dbGraphic == null)
  1478. {
  1479. continue;
  1480. }
  1481. display.dbGraphic.transform.SetParent(UAC.transform);
  1482. display.dbGraphic.transform.SetAsLastSibling();
  1483. }
  1484. }
  1485. }
  1486. private void SetSlotLocalZ(DragonBones.Slot slot, float z)
  1487. {
  1488. if (slot.UnityTransform == null)
  1489. {
  1490. UAC.transform.Find(slot.name).SetLZ(z);
  1491. }
  1492. else
  1493. {
  1494. slot.UnityTransform.SetLZ(z);
  1495. }
  1496. }
  1497. private void SetSlotAsFirstChild(DragonBones.Slot slot)
  1498. {
  1499. if (slot.UnityTransform == null)
  1500. {
  1501. UAC.transform.Find(slot.name).SetAsFirstSibling();
  1502. }
  1503. else
  1504. {
  1505. slot.UnityTransform.SetAsFirstSibling();
  1506. }
  1507. }
  1508. public void ChangeClose(BodyPart bodyPart, string armatureName, bool setDepth = true)
  1509. {
  1510. // Debug.Log (bodyPart + " " + armatureName);
  1511. List<DragonBones.Slot> slotList = new List<DragonBones.Slot>();
  1512. if (bodyPart == BodyPart.Eye)
  1513. {
  1514. Eye = armatureName;
  1515. slotList.Add(EyeSlot);
  1516. }
  1517. else if (bodyPart == BodyPart.Top)
  1518. {
  1519. Top = armatureName;
  1520. slotList.Add(TopSlot);
  1521. }
  1522. else if (bodyPart == BodyPart.Shoe)
  1523. {
  1524. //Shoe = armatureName;
  1525. //slotList.Add(LeftShoeSlot);
  1526. //slotList.Add(RightShoeSlot);
  1527. Shoe = armatureName;
  1528. int id = PlayerManager.CloseIDDictionary[armatureName];
  1529. CloseItem closeItem = PlayerManager.CloseItemDictionary[id];
  1530. Texture2D leftTexture = PlayerManager.GetCloseTexture(closeItem.Sprites[0].name);
  1531. Texture2D rightTexture;
  1532. leftShoeDisplayName = closeItem.Sprites[0].name;
  1533. if (closeItem.Sprites.Length == 1)
  1534. {
  1535. rightTexture = leftTexture;
  1536. }
  1537. else
  1538. {
  1539. rightTexture = PlayerManager.GetCloseTexture(closeItem.Sprites[1].name);
  1540. }
  1541. UnityFactory.factory.ReplaceSlotDisplay("stand_ske", "Armature", "鞋子左", "鞋子15-2_1", LeftShoeSlot,
  1542. leftTexture, new Material(Shader.Find("Sprites/Default")));
  1543. UnityFactory.factory.ReplaceSlotDisplay("stand_ske", "Armature", "鞋子右", "鞋子15-1_2", RightShoeSlot,
  1544. rightTexture, new Material(Shader.Find("Sprites/Default")));
  1545. leftShoeDisplayName = closeItem.Sprites[0].name;
  1546. if (closeItem.Sprites.Length == 1)
  1547. {
  1548. rightShoeDisplayName = closeItem.Sprites[0].name;
  1549. }
  1550. else
  1551. {
  1552. rightShoeDisplayName = closeItem.Sprites[1].name;
  1553. }
  1554. }
  1555. else if (bodyPart == BodyPart.Head)
  1556. {
  1557. Head = armatureName;
  1558. slotList.Add(HeadSlot);
  1559. }
  1560. else if (bodyPart == BodyPart.Wing)
  1561. {
  1562. if (Wing == armatureName)
  1563. {
  1564. return;
  1565. }
  1566. else
  1567. {
  1568. Wing = armatureName;
  1569. slotList.Add(WingSlot);
  1570. }
  1571. }
  1572. else if (bodyPart == BodyPart.Dress)
  1573. {
  1574. Dress = armatureName;
  1575. slotList.Add(DressSlot);
  1576. }
  1577. else if (bodyPart == BodyPart.Mouse)
  1578. {
  1579. Mouse = armatureName;
  1580. slotList.Add(MouseSlot);
  1581. }
  1582. else if (bodyPart == BodyPart.Headwear)
  1583. {
  1584. HeadWear = armatureName;
  1585. slotList.Add(HeadWearSlot);
  1586. }
  1587. else if (bodyPart == BodyPart.Leg)
  1588. {
  1589. slotList.Add(LeftLegSlot);
  1590. slotList.Add(RightLegSlot);
  1591. }
  1592. else if (bodyPart == BodyPart.LeftHand)
  1593. {
  1594. slotList.Add(LeftHandSlot);
  1595. }
  1596. else if (bodyPart == BodyPart.RightHand)
  1597. {
  1598. slotList.Add(RightHandSlot);
  1599. }
  1600. else if (bodyPart == BodyPart.Neck)
  1601. {
  1602. slotList.Add(NeckSlot);
  1603. }
  1604. else if (bodyPart == BodyPart.LeftLongSleeve)
  1605. {
  1606. LeftLongSleeve = armatureName;
  1607. ChangeClose(LeftLongSleeveUAC, armatureName);
  1608. return;
  1609. }
  1610. else if (bodyPart == BodyPart.LeftShortSleeve)
  1611. {
  1612. LeftShortSleeve = armatureName;
  1613. slotList.Add(LeftShortSleeveSlot);
  1614. }
  1615. else if (bodyPart == BodyPart.RightLongSleeve)
  1616. {
  1617. RightLongSleeve = armatureName;
  1618. ChangeClose(RightLongSleeveUAC, armatureName);
  1619. return;
  1620. }
  1621. else if (bodyPart == BodyPart.RightShortSleeve)
  1622. {
  1623. RightShortSleeve = armatureName;
  1624. slotList.Add(RightShortSleeveSlot);
  1625. }
  1626. else
  1627. {
  1628. throw new Exception();
  1629. }
  1630. ChangeClose(slotList, armatureName, setDepth);
  1631. if (bodyPart == BodyPart.Wing)
  1632. {
  1633. TweenRoot tweenRoot = transform.Find("Armature/" + Wing).GetChild(0).CreateTweenScale(new Vector3(1, 1, 1), new Vector3(0.6f, 1, 1), 0.75f, true, true, Curve.Linear);
  1634. tweenRoot.PingPong = true;
  1635. tweenRoot.StartForward();
  1636. }
  1637. }
  1638. public void ChangeClose(List<DragonBones.Slot> slotList, string armatureName, bool setDepth = true)
  1639. {
  1640. for (int i = 0; i < slotList.Count; i++)
  1641. {
  1642. slotList[i].childArmature = UnityFactory.factory.BuildArmature(armatureName, null, null, null, true);
  1643. slotList[i].UnityTransform = slotList[i].childArmature.UnityTransform.parent;
  1644. }
  1645. if (setDepth)
  1646. {
  1647. DelayCall.Call
  1648. (
  1649. 1,
  1650. () =>
  1651. {
  1652. ResetDepth();
  1653. if (IsDisplayInUGUI) DisplayInUI(UGUIScale, false);
  1654. }
  1655. );
  1656. }
  1657. }
  1658. public void ChangeClose(UnityArmatureComponent uac, string armatureName, bool setDepth = true)
  1659. {
  1660. if (armatureName == "Empty")
  1661. {
  1662. uac.SetActive(false);
  1663. }
  1664. else
  1665. {
  1666. uac.SetActive(true);
  1667. }
  1668. if (setDepth)
  1669. {
  1670. DelayCall.Call
  1671. (
  1672. 1,
  1673. () =>
  1674. {
  1675. ResetDepth();
  1676. if (IsDisplayInUGUI) DisplayInUI(UGUIScale, false);
  1677. }
  1678. );
  1679. }
  1680. }
  1681. #endregion
  1682. }