Player.cs 58 KB

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