Player.cs 60 KB

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