Player.cs 58 KB

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