Player.cs 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466
  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 enum BodyPart
  15. {
  16. Leg = 0,
  17. LeftHand = 1,
  18. RightHand = 2,
  19. LeftLongSleeve = 3,
  20. LeftShortSleeve = 4,
  21. RightLongSleeve = 5,
  22. RightShortSleeve = 6,
  23. Neck = 7,
  24. Eye = 8,
  25. Top = 9,
  26. Shoe = 10,
  27. Head = 11,
  28. Wing = 12,
  29. Dress = 13,
  30. Mouse = 14,
  31. Headwear = 15,
  32. }
  33. public class CloseUnit
  34. {
  35. public enum CloseType
  36. {
  37. Top,
  38. Hair,
  39. Wing,
  40. Dress,
  41. Decarator,
  42. Shoe,
  43. }
  44. #region Var
  45. public string Name
  46. {
  47. get { return Language.GetStr("DressRoom", "Armature" + ID); }
  48. }
  49. public int ID;
  50. public int Index;
  51. public int BuyLevel;
  52. public int PixelSize;
  53. public bool Bought;
  54. public string ArmatureName;
  55. public string[] ExtraArmatureNames;
  56. public BodyPart[] ExtraBodyParts;
  57. public float SpriteAlpha;
  58. public float IconOffset;
  59. public Text BuyBtnLab;
  60. public Sprite[] Sprites;
  61. public Image Icon1;
  62. public Image Icon2;
  63. public Image Icon3;
  64. public Button BuyBtn;
  65. public Button DressBtn;
  66. public Vector2 IconOffset1;
  67. public Vector2 IconOffset2;
  68. public BodyPart BodyPart;
  69. public Transform Transform;
  70. public CloseType Type;
  71. public bool Ignore;
  72. public double BuyAmt;
  73. public double BuyAdvanceAmt;
  74. public Current BuyCurrent;
  75. public Current BuyAdvanceCurrent;
  76. public Dictionary<string, Transform> ChildDic = new Dictionary<string, Transform>();
  77. #endregion
  78. public CloseUnit(XmlAttributeCollection attribute)
  79. {
  80. Ignore = Auxiliary.BoolParse(attribute[19].Value, false);
  81. ID = Auxiliary.IntParse(attribute[0].Value, -1);
  82. BodyPart = BodyPartParse(attribute[4].Value);
  83. ArmatureName = attribute[16].Value;
  84. ManaPlayer.CloseIDDic.Add(ArmatureName, ID);
  85. ManaPlayer.CloseUnitDic.Add(ID, this);
  86. if (Ignore)
  87. {
  88. return;
  89. }
  90. Type = TypeParse(attribute[2].Value);
  91. Index = Auxiliary.IntParse(attribute[3].Value, -1);
  92. BuyLevel = Auxiliary.IntParse(attribute[5].Value, 0);
  93. BuyCurrent = Auxiliary.CurrentParse(attribute[6].Value);
  94. BuyAmt = Auxiliary.DoubleParse(attribute[7].Value, 0);
  95. BuyAdvanceCurrent = Auxiliary.CurrentParse(attribute[8].Value);
  96. BuyAdvanceAmt = Auxiliary.DoubleParse(attribute[9].Value, 0);
  97. PixelSize = Auxiliary.IntParse(attribute[10].Value, 100);
  98. IconOffset = Auxiliary.FloatParse(attribute[11].Value, 0);
  99. IconOffset1 = Auxiliary.VectorParse(',', attribute[12].Value, new Vector3());
  100. IconOffset2 = Auxiliary.VectorParse(',', attribute[13].Value, new Vector3());
  101. Sprites = SpriteParse(attribute[14].Value);
  102. SpriteAlpha = Auxiliary.FloatParse(attribute[15].Value, 1);
  103. ExtraBodyParts = BodyPartParses(attribute[17].Value);
  104. ExtraArmatureNames = Auxiliary.StringListParse(',', attribute[18].Value, new List<string>()).ToArray();
  105. CreateItem();
  106. }
  107. protected void CreateItem()
  108. {
  109. Transform = ManaReso.Get("CloseItem", Folder.UI, false, ManaReso.Get("Canvas"), false);
  110. if (Type == CloseType.Top)
  111. {
  112. Transform.SetParent(ManaReso.Get("Pb_TopGrid"));
  113. }
  114. else if (Type == CloseType.Hair)
  115. {
  116. Transform.SetParent(ManaReso.Get("Pa_HairGrid"));
  117. }
  118. else if (Type == CloseType.Dress)
  119. {
  120. Transform.SetParent(ManaReso.Get("Pc_DressGrid"));
  121. }
  122. else if (Type == CloseType.Wing)
  123. {
  124. Transform.SetParent(ManaReso.Get("Pe_WingGrid"));
  125. }
  126. else if (Type == CloseType.Decarator)
  127. {
  128. Transform.SetParent(ManaReso.Get("Pd_DecaratorGrid"));
  129. }
  130. else if (Type == CloseType.Shoe)
  131. {
  132. Transform.SetParent(ManaReso.Get("Pf_ShoeGrid"));
  133. }
  134. else
  135. {
  136. throw new Exception();
  137. }
  138. Transform.SetSiblingIndex(Index);
  139. Auxiliary.CompileDic(Transform, ChildDic);
  140. Icon1 = ChildDic["Icon1"].GetComponent<Image>();
  141. Icon2 = ChildDic["Icon2"].GetComponent<Image>();
  142. Icon3 = ChildDic["Icon3"].GetComponent<Image>();
  143. DressBtn = ChildDic["CloseItem"].GetComponent<Button>();
  144. BuyBtn = ChildDic["BuyBtn"].GetComponent<Button>();
  145. BuyBtnLab = ChildDic["BuyBtnLab"].GetComponent<Text>();
  146. BuyBtnLab.GetComponent<TextPlus>().SetY = true;
  147. float newSize = PixelSize / Sprites[0].rect.width;
  148. SetUpUI(newSize, new Vector2(), Icon1, Icon2, Icon3);
  149. if (BuyCurrent != Current.Free)
  150. {
  151. BuyBtnLab.text = Auxiliary.ImageParse(BuyCurrent) + Auxiliary.ShrinkNumberStr(BuyAmt);
  152. }
  153. if (BuyLevel > ManaCenter.Level)
  154. {
  155. BuyBtn.interactable = false;
  156. BuyBtn.image.material = Lib.GrayMat;
  157. }
  158. BuyBtn.onClick.AddListener
  159. (
  160. () =>
  161. {
  162. ManaAudio.PlayClip(Clip.BtnClip);
  163. ManaReso.Get("Pa_Info").TweenForCG();
  164. SetUpUI(newSize, new Vector2(0, 22), ManaReso.Get<Image>("Pa_Icon1"), ManaReso.Get<Image>("Pa_Icon3"), ManaReso.Get<Image>("Pa_Icon2"));
  165. ManaReso.SetText("Pa_Lab", Name);
  166. ManaReso.SetText("Pa_BtnLab", Language.GetStr("UI", "Pa_BtnLab") + Auxiliary.ImageParse(BuyCurrent) + BuyAmt);
  167. ManaReso.SetButtonEvent
  168. (
  169. "Pa_Btn",
  170. OnBuy
  171. );
  172. }
  173. );
  174. DressBtn.onClick.AddListener
  175. (
  176. () =>
  177. {
  178. ManaAudio.PlayClip(Clip.BtnClip);
  179. if (BuyLevel > ManaCenter.Level)
  180. {
  181. Bubble.Show(null, Language.GetStr("UI", "P_Unlock"));
  182. return;
  183. }
  184. ChangeDress(ManaPlayer.Player);
  185. }
  186. );
  187. }
  188. protected Sprite[] SpriteParse(string str)
  189. {
  190. string[] spriteNames = str.Split(',');
  191. Sprite[] sprites = new Sprite[spriteNames.Length];
  192. for (int i = 0; i < spriteNames.Length; i++)
  193. {
  194. if (!ManaPlayer.CloseSpriteDic.ContainsKey(spriteNames[i]))
  195. {
  196. Debug.Log(spriteNames[i]);
  197. }
  198. sprites[i] = ManaPlayer.CloseSpriteDic[spriteNames[i]];
  199. }
  200. return sprites;
  201. }
  202. protected BodyPart BodyPartParse(string str)
  203. {
  204. int type = Auxiliary.IntParse(str, -1);
  205. if (type == 1)
  206. {
  207. return BodyPart.Head;
  208. }
  209. else if (type == 2)
  210. {
  211. return BodyPart.Dress;
  212. }
  213. else if (type == 3)
  214. {
  215. return BodyPart.Shoe;
  216. }
  217. else if (type == 4)
  218. {
  219. return BodyPart.Headwear;
  220. }
  221. else if (type == 5)
  222. {
  223. return BodyPart.Top;
  224. }
  225. else if (type == 6)
  226. {
  227. return BodyPart.Wing;
  228. }
  229. else if (type == 7)
  230. {
  231. return BodyPart.LeftLongSleeve;
  232. }
  233. else if (type == 8)
  234. {
  235. return BodyPart.RightLongSleeve;
  236. }
  237. else if (type == 9)
  238. {
  239. return BodyPart.LeftShortSleeve;
  240. }
  241. else if (type == 10)
  242. {
  243. return BodyPart.RightShortSleeve;
  244. }
  245. else if (type == 11)
  246. {
  247. return BodyPart.Eye;
  248. }
  249. else if (type == 12)
  250. {
  251. return BodyPart.Mouse;
  252. }
  253. else
  254. {
  255. throw new Exception();
  256. }
  257. }
  258. protected BodyPart[] BodyPartParses(string str)
  259. {
  260. List<string> typeIDs = Auxiliary.StringListParse(',', str, new List<string>());
  261. BodyPart[] bodyParts = new BodyPart[typeIDs.Count];
  262. for (int i = 0; i < typeIDs.Count; i++)
  263. {
  264. bodyParts[i] = BodyPartParse(typeIDs[i]);
  265. }
  266. return bodyParts;
  267. }
  268. protected CloseType TypeParse(string str)
  269. {
  270. int type = Auxiliary.IntParse(str, -1);
  271. if (type == 1)
  272. {
  273. return CloseType.Hair;
  274. }
  275. else if (type == 2)
  276. {
  277. return CloseType.Top;
  278. }
  279. else if (type == 3)
  280. {
  281. return CloseType.Dress;
  282. }
  283. else if (type == 4)
  284. {
  285. return CloseType.Decarator;
  286. }
  287. else if (type == 5)
  288. {
  289. return CloseType.Wing;
  290. }
  291. else if (type == 6)
  292. {
  293. return CloseType.Shoe;
  294. }
  295. else
  296. {
  297. throw new Exception();
  298. }
  299. }
  300. public void SetUpUI(float newSize, Vector2 offset, Image icon1, Image icon2, Image icon3)
  301. {
  302. icon1.SetActive(false);
  303. icon3.SetActive(false);
  304. icon2.SetActive(true);
  305. icon2.sprite = Sprites[0];
  306. icon2.Resize(true, new Vector2(newSize, newSize));
  307. icon2.SetAlpha(SpriteAlpha);
  308. icon2.transform.localPosition = offset + new Vector2(0, IconOffset);
  309. if (Sprites.Length >= 2)
  310. {
  311. icon1.SetActive(true);
  312. icon1.sprite = Sprites[1];
  313. icon1.Resize(true, new Vector2(newSize, newSize));
  314. icon1.SetAlpha(SpriteAlpha);
  315. icon1.transform.localPosition = IconOffset1 * newSize + offset + new Vector2(0, IconOffset);
  316. }
  317. if (Sprites.Length >= 3)
  318. {
  319. icon3.SetActive(true);
  320. icon3.sprite = Sprites[2];
  321. icon3.Resize(true, new Vector2(newSize, newSize));
  322. icon3.SetAlpha(SpriteAlpha);
  323. icon3.transform.localPosition = IconOffset2 * newSize + offset + new Vector2(0, IconOffset);
  324. }
  325. }
  326. public void Unlock()
  327. {
  328. if (Ignore)
  329. {
  330. return;
  331. }
  332. Bought = true;
  333. BuyBtn.interactable = false;
  334. BuyBtn.image.material = Lib.GrayMat;
  335. BuyBtnLab.text = Language.GetStr("UI", "P_BtnLab2");
  336. ManaCenter.CloseAmt++;
  337. }
  338. public void OnBuy()
  339. {
  340. ManaCenter.Pay
  341. (
  342. "",
  343. BuyAmt,
  344. BuyCurrent,
  345. () =>
  346. {
  347. Unlock();
  348. ManaAudio.PlayClip(Clip.CurrentClip);
  349. ManaPlayer.BoughtCloseList.UniqueAdd(ID);
  350. ManaReso.Get("Pa_Info").TweenBacCG();
  351. ManaServer.Save();
  352. },
  353. StaticsManager.ItemID.解锁服装,
  354. StaticsManager.ConsumeModule.Shop,
  355. true,
  356. false,
  357. () =>
  358. {
  359. ManaPlayer.Player.Reset();
  360. TweenRoot tweenRoot = ManaReso.Get("Pa_Info").TweenBacCG();
  361. tweenRoot.AddEventOnetime
  362. (
  363. EventType.BackwardFinish,
  364. () =>
  365. {
  366. ManaPlayer.Player.Return();
  367. }
  368. );
  369. ManaReso.Get("B_SignIn0").GetTweenCG().AddEventOnetime
  370. (
  371. EventType.ForwardFinish,
  372. () =>
  373. {
  374. ManaReso.Get("F_Manage0").TweenForVec();
  375. }
  376. );
  377. }
  378. );
  379. }
  380. public void ChangeDress(Player player)
  381. {
  382. player.ChangeClose(BodyPart, ArmatureName);
  383. if (Ignore)
  384. {
  385. return;
  386. }
  387. if (ExtraBodyParts.Length > 0)
  388. {
  389. player.ChangeClose(BodyPart.LeftLongSleeve, "Empty");
  390. player.ChangeClose(BodyPart.LeftShortSleeve, "Empty");
  391. player.ChangeClose(BodyPart.RightLongSleeve, "Empty");
  392. player.ChangeClose(BodyPart.RightShortSleeve, "Empty");
  393. }
  394. for (int i = 0; i < ExtraArmatureNames.Length; i++)
  395. {
  396. player.ChangeClose(ExtraBodyParts[i], ExtraArmatureNames[i]);
  397. }
  398. }
  399. public void OnLevelChange()
  400. {
  401. if (Ignore)
  402. {
  403. return;
  404. }
  405. if (Bought)
  406. {
  407. return;
  408. }
  409. if (BuyLevel < ManaCenter.Level)
  410. {
  411. BuyBtn.interactable = true;
  412. BuyBtn.image.material = null;
  413. }
  414. }
  415. }
  416. public enum PlayerDirection
  417. {
  418. Left = 0,
  419. Right = 1,
  420. }
  421. public class Player : Regist , IPointerClickHandler
  422. {
  423. #region 变量
  424. public static string IdleAnimationName = "newAnimation";
  425. public static string JumpAnimationName = "newAnimation1";
  426. public static string WalkAnimationName = "newAnimation2";
  427. public static string RunAnimationName = "newAnimation3";
  428. public static bool InDressRoom;
  429. public static float JumpFrequency;
  430. public PlayerDirection PlayerDirection
  431. {
  432. get { return playerDirection; }
  433. set
  434. {
  435. playerDirection = value;
  436. Flip(playerDirection);
  437. }
  438. }
  439. private PlayerDirection playerDirection = PlayerDirection.Left;
  440. public bool AnimLock1;
  441. public bool AnimLock2;
  442. public float JumpTime;
  443. public float JumpTimer;
  444. public MeshFilter ExpressionMeshFilter;
  445. public Dictionary<string, Transform> ChildDic = new Dictionary<string, Transform>();
  446. public static Dictionary<string, Vector3> LeftExpressionPositionDictionary = new Dictionary<string, Vector3>
  447. {
  448. {"郁闷", new Vector3(0, -0.22f, -0.001f)},
  449. {"汗颜", new Vector3(0.35f, 0.91f, -0.001f)},
  450. {"惊讶", new Vector3(0.09f, -0.07f, -0.001f)},
  451. {"开心", new Vector3(0.1f, -0.22f, -0.001f)},
  452. {"哭", new Vector3(0.07f, -0.64f, -0.001f)},
  453. {"期待", new Vector3(0.04f, -0.20f, -0.001f)},
  454. {"色咪咪", new Vector3(0.03f, -0.09f, -0.001f)},
  455. {"委屈", new Vector3(0f, -0.27f, -0.001f)},
  456. };
  457. public static Dictionary<string, Vector3> RightExpressionPositionDictionary = new Dictionary<string, Vector3>
  458. {
  459. {"郁闷", new Vector3(0, -0.22f, -0.001f)},
  460. {"汗颜", new Vector3(-0.22f, 0.91f, -0.001f)},
  461. {"惊讶", new Vector3(-0.09f, -0.07f, -0.001f)},
  462. {"开心", new Vector3(-0.1f, -0.22f, -0.001f)},
  463. {"哭", new Vector3(-0.07f, -0.64f, -0.001f)},
  464. {"期待", new Vector3(-0.04f, -0.20f, -0.001f)},
  465. {"色咪咪", new Vector3(-0.03f, -0.09f, -0.001f)},
  466. {"委屈", new Vector3(0f, -0.27f, -0.001f)},
  467. };
  468. #region 换装
  469. public Transform Shadow;
  470. private Transform Pivot
  471. {
  472. get
  473. {
  474. if (pivot == null)
  475. {
  476. pivot = UAC.transform.FindChild("Pivot");
  477. }
  478. return pivot;
  479. }
  480. }
  481. private Transform pivot;
  482. public string Eye;
  483. public string Top;
  484. public string Shoe;
  485. public string Head;
  486. public string Wing;
  487. public string Dress;
  488. public string Mouse;
  489. public string HeadWear;
  490. public string LeftLongSleeve;
  491. public string LeftShortSleeve;
  492. public string RightLongSleeve;
  493. public string RightShortSleeve;
  494. private string TempClose;
  495. public DragonBones.Slot NeckSlot;
  496. public DragonBones.Slot LeftHandSlot;
  497. public DragonBones.Slot RightHandSlot;
  498. public DragonBones.Slot LeftLegSlot;
  499. public DragonBones.Slot RightLegSlot;
  500. public DragonBones.Slot LeftShortSleeveSlot;
  501. public DragonBones.Slot RightShortSleeveSlot;
  502. public DragonBones.Slot EyeSlot;
  503. public DragonBones.Slot TopSlot;
  504. public DragonBones.Slot HeadSlot;
  505. public DragonBones.Slot DressSlot;
  506. public DragonBones.Slot WingSlot;
  507. public DragonBones.Slot MouseSlot;
  508. public DragonBones.Slot LeftShoeSlot;
  509. public DragonBones.Slot RightShoeSlot;
  510. public DragonBones.Slot HeadWearSlot;
  511. public UnityArmatureComponent UAC;
  512. public UnityArmatureComponent LeftLongSleeveUAC;
  513. public UnityArmatureComponent RightLongSleeveUAC;
  514. #endregion
  515. #endregion
  516. public override bool RegistImmed()
  517. {
  518. if (base.RegistImmed())
  519. {
  520. return true;
  521. }
  522. enabled = true;
  523. Auxiliary.CompileDic(transform, ChildDic);
  524. Vector3 bigShadowScale = new Vector3(1.820952f, 2.418199f, 1.820952f);
  525. Vector3 smallShadowScale = new Vector3(1.081191f, 1.435807f, 1.081191f);
  526. Shadow = ChildDic["Shadow"];
  527. Shadow.CreateStreamScale
  528. (
  529. new List<float>() {0, 0, 0},
  530. new List<float>() {0.33f, 0.33f, 0.33f, 0.33f},
  531. new List<VecPair>() {new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale), new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale)},
  532. true,
  533. true,
  534. Curve.EaseOutQuad
  535. );
  536. MeshFilter meshFilter = Shadow.GetComponent<MeshFilter>();
  537. meshFilter.mesh = SpriteUtility.CreateMesh(ManaReso.LoadSprite("花影子", Folder.Scene));
  538. meshFilter.mesh.SetUVs(1, Enumerable.Repeat(new Vector2(0, 1), meshFilter.mesh.vertices.Length).ToList());
  539. Shadow.GetComponent<MeshRenderer>().sharedMaterial = UnityFactory.Materials[0];
  540. ExpressionMeshFilter = ChildDic["ExpressionMeshFilter"].GetComponent<MeshFilter>();
  541. ExpressionMeshFilter.GetComponent<MeshRenderer>().sharedMaterial = UnityFactory.Materials[0];
  542. return false;
  543. }
  544. public void Update()
  545. {
  546. if (InDressRoom)
  547. {
  548. JumpTimer += Time.deltaTime;
  549. if (JumpTimer > JumpTime)
  550. {
  551. if (!AnimLock1 && !AnimLock2)
  552. {
  553. PlayAnim(JumpAnimationName);
  554. }
  555. AnimLock2 = true;
  556. }
  557. if (JumpTimer > JumpFrequency)
  558. {
  559. AnimLock2 = false;
  560. JumpTime = Mathf.Lerp(0, JumpFrequency, Random.Range(0f, 1f));
  561. JumpTimer = 0;
  562. }
  563. }
  564. //if (GardenSmartFoxManager.GardenSmartFox.PlazaRoomManager.InPlazaRoom)
  565. //{
  566. // MoveThread();
  567. //}
  568. }
  569. public void OnStart(string str, EventObject eventObject)
  570. {
  571. if (eventObject.animationState.name == JumpAnimationName)
  572. {
  573. Shadow.StreamReForScale();
  574. AnimLock1 = true;
  575. TempClose = Eye;
  576. ChangeClose(BodyPart.Eye, "眼睛表情1");
  577. }
  578. else if (eventObject.animationState.name == IdleAnimationName)
  579. {
  580. AnimLock1 = false;
  581. if (TempClose != null)
  582. {
  583. ChangeClose(BodyPart.Eye, TempClose);
  584. }
  585. }
  586. }
  587. public string CurrentAnimationName;
  588. public void PlayAnim(string animName)
  589. {
  590. if (AnimLock1)
  591. {
  592. return;
  593. }
  594. if (UAC.anim.lastAnimationName == animName)
  595. {
  596. return;
  597. }
  598. if (SFSManager.GardenSmartFox.PlazaRoomManager.JoinedPlazaRoom)
  599. {
  600. CurrentAnimationName = animName;
  601. }
  602. UAC.anim.FadeIn(animName, GetFadeInTime(UAC.anim.lastAnimationName, animName));
  603. }
  604. public float GetFadeInTime(string lastAnimation, string targetAnimation)
  605. {
  606. if (lastAnimation == JumpAnimationName && targetAnimation == IdleAnimationName)
  607. return -1f;
  608. else
  609. return 0.1f;
  610. //throw new Exception();
  611. }
  612. public void SetAllCollider(bool enable)
  613. {
  614. BoxCollider2D[] colliders = GetComponentsInChildren<BoxCollider2D>();
  615. for (int i = 0; i < colliders.Length; i++)
  616. {
  617. colliders[i].enabled = enable;
  618. }
  619. }
  620. public void OnPointerClick(PointerEventData eventData)
  621. {
  622. ManaAudio.PlayClip(Clip.CurrentClip);
  623. PlayAnim(JumpAnimationName);
  624. }
  625. public void ResetExpression()
  626. {
  627. ExpressionMeshFilter.SetActive(false);
  628. EyeSlot.UnityTransform.GetChild(0).SetActive(true);
  629. MouseSlot.UnityTransform.GetChild(0).SetActive(true);
  630. }
  631. private string ExpressionName;
  632. private Coroutine ResetExpressionCoroutine;
  633. public void ChangeExpression(string expressionName, float duration)
  634. {
  635. ExpressionName = expressionName;
  636. ExpressionMeshFilter.sharedMesh = SpriteUtility.CreateMesh(ManaReso.LoadSprite(expressionName, Folder.Scene));
  637. ExpressionMeshFilter.mesh.SetUVs(1, Enumerable.Repeat(new Vector2(0, 1), ExpressionMeshFilter.mesh.vertices.Length).ToList());
  638. ExpressionMeshFilter.transform.parent = EyeSlot.UnityTransform;
  639. ExpressionMeshFilter.SetActive(true);
  640. EyeSlot.UnityTransform.GetChild(0).SetActive(false);
  641. MouseSlot.UnityTransform.GetChild(0).SetActive(false);
  642. FlipExpression(expressionName, PlayerDirection);
  643. if (ResetExpressionCoroutine != null)
  644. Auxiliary.Instance.StopCoroutine(ResetExpressionCoroutine);
  645. ResetExpressionCoroutine = Auxiliary.Instance.DelayCall
  646. (
  647. () =>
  648. {
  649. ResetExpression();
  650. },
  651. duration
  652. );
  653. }
  654. public void Flip(PlayerDirection direction)
  655. {
  656. FlipExpression(ExpressionName, direction);
  657. if (direction == PlayerDirection.Left)
  658. {
  659. UAC.armature.flipX = false;
  660. playerDirection = PlayerDirection.Left;
  661. }
  662. else if (direction == PlayerDirection.Right)
  663. {
  664. UAC.armature.flipX = true;
  665. playerDirection = PlayerDirection.Right;
  666. }
  667. else
  668. {
  669. throw new Exception();
  670. }
  671. DelayCall.Call(1, () => Shadow.SetX(Pivot.position.x));
  672. }
  673. public void FlipExpression(string expressionName, PlayerDirection direction)
  674. {
  675. if (string.IsNullOrEmpty(ExpressionName))
  676. {
  677. return;
  678. }
  679. if (direction == PlayerDirection.Left)
  680. {
  681. ExpressionMeshFilter.transform.eulerAngles = new Vector3();
  682. ExpressionMeshFilter.transform.localPosition = LeftExpressionPositionDictionary[ExpressionName];
  683. }
  684. else if (direction == PlayerDirection.Right)
  685. {
  686. UAC.armature.flipX = true;
  687. ExpressionMeshFilter.transform.eulerAngles = new Vector3(0, 180, 0);
  688. ExpressionMeshFilter.transform.localPosition = RightExpressionPositionDictionary[ExpressionName];
  689. playerDirection = PlayerDirection.Right;
  690. }
  691. else
  692. {
  693. throw new Exception();
  694. }
  695. }
  696. public void Save(bool showNavigate)
  697. {
  698. ManaAudio.PlayClip(Clip.BtnClip);
  699. List<CloseUnit> closeUnitList = new List<CloseUnit>();
  700. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Head]]);
  701. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Dress]]);
  702. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Shoe]]);
  703. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[HeadWear]]);
  704. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Top]]);
  705. if (Wing != "Empty")
  706. {
  707. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Wing]]);
  708. }
  709. for (int i = 0; i < closeUnitList.Count; i++)
  710. {
  711. if (!closeUnitList[i].Bought)
  712. {
  713. if (showNavigate)
  714. {
  715. BuyNavigate(closeUnitList);
  716. }
  717. return;
  718. }
  719. }
  720. ManaPlayer.DressData[0] = Head;
  721. ManaPlayer.DressData[1] = Dress;
  722. ManaPlayer.DressData[2] = Shoe;
  723. ManaPlayer.DressData[3] = HeadWear;
  724. ManaPlayer.DressData[4] = Top;
  725. ManaPlayer.DressData[7] = Wing;
  726. ManaPlayer.DressData[8] = LeftLongSleeve;
  727. ManaPlayer.DressData[9] = LeftShortSleeve;
  728. ManaPlayer.DressData[10] = RightLongSleeve;
  729. ManaPlayer.DressData[11] = RightShortSleeve;
  730. //GardenSmartFoxManager.GardenSmartFox.PlazaRoomManager.SyncClose();
  731. }
  732. public void Reset()
  733. {
  734. ManaAudio.PlayClip(Clip.BtnClip);
  735. List<string> dressData = new List<string>(ManaPlayer.DressData);
  736. dressData[5] = Eye;
  737. ManaPlayer.BuildPlayer(dressData);
  738. }
  739. public void Return()
  740. {
  741. bool allSave = true;
  742. bool allBought = true;
  743. List<string> currentDerssData = new List<string>() {Head, Dress, Shoe, HeadWear, Top, Wing};
  744. for (int i = 0; i < currentDerssData.Count; i++)
  745. {
  746. if (!ManaPlayer.CloseIDDic.ContainsKey(currentDerssData[i]))
  747. {
  748. continue;
  749. }
  750. int id = ManaPlayer.CloseIDDic[currentDerssData[i]];
  751. allBought = allBought && ManaPlayer.CloseUnitDic[id].Bought;
  752. //Debug.Log(ManaPlayer.CloseUnitDic[id].Name + " " + ManaPlayer.CloseUnitDic[id].Bought);
  753. allSave = allSave && currentDerssData[i] == ManaPlayer.DressData[i];
  754. }
  755. if (allBought)
  756. {
  757. if (allSave)
  758. {
  759. ExitDressRoom();
  760. }
  761. else
  762. {
  763. Reset();
  764. ExitDressRoom();
  765. }
  766. }
  767. else
  768. {
  769. Bubble.Show
  770. (
  771. null, Language.GetStr("UI", "P_Return"), null, null,
  772. () =>
  773. {
  774. Reset();
  775. ManaReso.Get("K_Bubble").GetTweenGra().AddEventOnetime(EventType.BackwardFinish, () => { ExitDressRoom(); });
  776. }
  777. );
  778. }
  779. }
  780. public void BuyNavigate(List<CloseUnit> closeUnitList)
  781. {
  782. for (int i = 0; i < closeUnitList.Count; i++)
  783. {
  784. if (closeUnitList[i].Bought)
  785. {
  786. closeUnitList.RemoveAt(i--);
  787. }
  788. else
  789. {
  790. closeUnitList[i].BuyBtn.onClick.Invoke();
  791. closeUnitList.RemoveAt(i--);
  792. ManaReso.Get("Pa_Info").GetTweenCG().AddEventOnetime
  793. (
  794. EventType.BackwardFinish,
  795. () =>
  796. {
  797. if (closeUnitList.Count == 0)
  798. {
  799. Save(false);
  800. }
  801. else
  802. {
  803. BuyNavigate(closeUnitList);
  804. }
  805. }
  806. );
  807. return;
  808. }
  809. }
  810. }
  811. public void ExitDressRoom()
  812. {
  813. ManaCenter.SceneSwitchLock = false;
  814. TweenRoot tweenRoot = ManaReso.Get("I_BlackMask").TweenBacCG();
  815. tweenRoot.AddEventOnetime
  816. (
  817. EventType.BackwardFinish,
  818. () =>
  819. {
  820. transform.SetParent(ManaReso.Get("GardenNormal"));
  821. transform.position = ManaReso.Get("PlayerPosTra").position;
  822. transform.localScale = ManaReso.Get("PlayerPosTra").lossyScale;
  823. ManaReso.Get("Garden").TweenForSr();
  824. ManaReso.Get("DressRoom").TweenBacSr();
  825. ManaReso.Get("C_Main").TweenForCG();
  826. ManaReso.Get("P_DressRoom").TweenBacCG();
  827. }
  828. );
  829. tweenRoot = ManaReso.Get("P_DressRoom").GetTweenCG();
  830. tweenRoot.AddEventOnetime
  831. (
  832. EventType.BackwardFinish,
  833. () =>
  834. {
  835. SetAllCollider(true);
  836. InDressRoom = false;
  837. JumpTimer = 0;
  838. PlayAnim(IdleAnimationName);
  839. DeactiveShadow();
  840. ManaReso.Get("B_SignIn0").TweenForCG();
  841. ManaReso.Get("I_BlackMask").TweenForCG();
  842. }
  843. );
  844. }
  845. public void EnterDressRoom()
  846. {
  847. if (ManaCenter.SceneSwitchLock)
  848. {
  849. return;
  850. }
  851. ManaReso.Get("B_SignIn0").TweenBacCG();
  852. InDressRoom = true;
  853. JumpTime = Mathf.Lerp(0, 10, Random.Range(0.5f, 1f));
  854. ManaCenter.SceneSwitchLock = true;
  855. ManaReso.Get("C_Main").TweenBacCG();
  856. SetAllCollider(false);
  857. TweenRoot tweenRoot = ManaReso.Get("I_BlackMask").TweenBacCG();
  858. tweenRoot.AddEventOnetime
  859. (
  860. EventType.BackwardFinish,
  861. () =>
  862. {
  863. ManaGarden.RetrieveAllElf();
  864. ManaIAP.RetrieveADChest();
  865. ActiveShadow();
  866. transform.SetParent(ManaReso.Get("DressRoom"));
  867. transform.position = ManaReso.Get("DressRoomPos").position;
  868. transform.localScale = ManaReso.Get("DressRoomPos").lossyScale;
  869. ManaReso.Get("Garden").TweenBacSr();
  870. ManaReso.Get("DressRoom").TweenForSr();
  871. ManaReso.Get("P_DressRoom").TweenForCG();
  872. }
  873. );
  874. tweenRoot = ManaReso.Get("P_DressRoom").GetTweenCG();
  875. tweenRoot.AddEventOnetime
  876. (
  877. EventType.ForwardFinish,
  878. () =>
  879. {
  880. ManaReso.Get("I_BlackMask").TweenForCG();
  881. }
  882. );
  883. }
  884. public void ActiveShadow()
  885. {
  886. ChildDic["ShadowParent"].SetActive(true);
  887. ChildDic["ShadowParent"].SetLZ(3);
  888. }
  889. public void DeactiveShadow()
  890. {
  891. Shadow.GetStreamScale().Pause();
  892. Shadow.GetStreamScale().InOrigin = true;
  893. ChildDic["ShadowParent"].SetActive(false);
  894. }
  895. #region 换装
  896. public void CorrectPivot()
  897. {
  898. List<Transform> children = new List<Transform>();
  899. while (transform.childCount > 0)
  900. {
  901. children.Add(transform.GetChild(0));
  902. children.Back(0).parent = null;
  903. }
  904. Vector3 offset = Pivot.position - transform.position;
  905. children[0].position += offset;
  906. children[1].position += offset;
  907. transform.position += offset;
  908. foreach (var collider in GetComponents<BoxCollider2D>())
  909. {
  910. collider.offset -= new Vector2(offset.x, offset.y);
  911. }
  912. for (int i = 0; i < children.Count; i++)
  913. {
  914. children[i].parent = transform;
  915. }
  916. }
  917. public UnityArmatureComponent Build()
  918. {
  919. if (!ManaPlayer.Complete)
  920. {
  921. UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("stand_ske", Folder.Config));
  922. UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("stand_tex", Folder.Config), "stand_texture");
  923. ManaPlayer.Complete = true;
  924. }
  925. UAC = UnityFactory.factory.BuildArmatureComponent("Armature");
  926. UAC.transform.parent = transform;
  927. UAC.transform.localScale = new Vector3(1, 1, 1);
  928. UAC.transform.localPosition = new Vector3();
  929. UAC.anim.Play(IdleAnimationName);
  930. UAC.AddEventListener(EventObject.START, OnStart);
  931. Eye = "眼睛1";
  932. Top = "上衣1";
  933. Shoe = "鞋子1";
  934. Head = "脑壳1";
  935. Wing = "Empty";
  936. Dress = "裙子1";
  937. Mouse = "嘴巴1";
  938. HeadWear = "头饰品1";
  939. NeckSlot = UAC.armature.GetSlot("脖子");
  940. LeftHandSlot = UAC.armature.GetSlot("左手");
  941. RightHandSlot = UAC.armature.GetSlot("右手");
  942. LeftLegSlot = UAC.armature.GetSlot("左腿");
  943. RightLegSlot = UAC.armature.GetSlot("右腿");
  944. LeftLongSleeveUAC = UAC.transform.FindChild("长袖9左 (长袖9左)").GetComponent<UnityArmatureComponent>();
  945. RightLongSleeveUAC = UAC.transform.FindChild("长袖9右 (长袖9右)").GetComponent<UnityArmatureComponent>();
  946. LeftShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子左");
  947. RightShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子右");
  948. EyeSlot = UAC.armature.GetSlot("眼睛");
  949. TopSlot = UAC.armature.GetSlot("上衣");
  950. HeadSlot = UAC.armature.GetSlot("脑壳");
  951. WingSlot = UAC.armature.GetSlot("翅膀");
  952. DressSlot = UAC.armature.GetSlot("裙子");
  953. MouseSlot = UAC.armature.GetSlot("嘴巴");
  954. LeftShoeSlot = UAC.armature.GetSlot("鞋子左");
  955. RightShoeSlot = UAC.armature.GetSlot("鞋子右");
  956. HeadWearSlot = UAC.armature.GetSlot("头饰品");
  957. ChangeClose(BodyPart.Eye, "眼睛1", false);
  958. ChangeClose(BodyPart.Top, "上衣1", false);
  959. ChangeClose(BodyPart.Shoe, "鞋子1", false);
  960. ChangeClose(BodyPart.Head, "脑壳1", false);
  961. ChangeClose(BodyPart.Dress, "裙子1", false);
  962. ChangeClose(BodyPart.Mouse, "嘴巴1", false);
  963. ChangeClose(BodyPart.Headwear, "头饰品1", false);
  964. ChangeClose(BodyPart.LeftLongSleeve, "Empty", false);
  965. ChangeClose(BodyPart.RightLongSleeve, "Empty", false);
  966. ChangeClose(BodyPart.LeftShortSleeve, "短袖2左", false);
  967. ChangeClose(BodyPart.RightShortSleeve, "短袖2右", false);
  968. CorrectPivot();
  969. return UAC;
  970. }
  971. public UnityArmatureComponent BuildPink()
  972. {
  973. Build();
  974. ChangeClose(BodyPart.Eye, "眼睛3", false);
  975. ChangeClose(BodyPart.Top, "上衣3", false);
  976. ChangeClose(BodyPart.Shoe, "鞋子3", false);
  977. ChangeClose(BodyPart.Head, "脑壳3", false);
  978. ChangeClose(BodyPart.Wing, "Empty", false);
  979. ChangeClose(BodyPart.Dress, "裙子3", false);
  980. ChangeClose(BodyPart.Mouse, "嘴巴3", false);
  981. ChangeClose(BodyPart.Headwear, "头饰品3", false);
  982. ResetDepth();
  983. return UAC;
  984. }
  985. public UnityArmatureComponent BuildBlond()
  986. {
  987. Build();
  988. ChangeClose(BodyPart.Wing, "Empty", false);
  989. ResetDepth();
  990. return UAC;
  991. }
  992. public UnityArmatureComponent BuildBrown()
  993. {
  994. Build();
  995. ChangeClose(BodyPart.Eye, "眼睛2", false);
  996. ChangeClose(BodyPart.Top, "上衣2", false);
  997. ChangeClose(BodyPart.Shoe, "鞋子2", false);
  998. ChangeClose(BodyPart.Head, "脑壳2", false);
  999. ChangeClose(BodyPart.Wing, "Empty", false);
  1000. ChangeClose(BodyPart.Dress, "裙子2", false);
  1001. ChangeClose(BodyPart.Mouse, "嘴巴2", false);
  1002. ChangeClose(BodyPart.Headwear, "头饰品2", false);
  1003. ResetDepth();
  1004. return UAC;
  1005. }
  1006. public void ResetDepth()
  1007. {
  1008. UAC.transform.SetLZ(2.5f);
  1009. WingSlot.UnityTransform.SetLZ(0);
  1010. EyeSlot.UnityTransform.SetLZ(0);
  1011. TopSlot.UnityTransform.SetLZ(0);
  1012. MouseSlot.UnityTransform.SetLZ(0);
  1013. HeadWearSlot.UnityTransform.SetLZ(0);
  1014. LeftShoeSlot.UnityTransform.SetLZ(0);
  1015. RightShoeSlot.UnityTransform.SetLZ(0);
  1016. LeftLegSlot.UnityTransform.SetLZ(0);
  1017. RightLegSlot.UnityTransform.SetLZ(0);
  1018. NeckSlot.UnityTransform.SetLZ(0);
  1019. LeftHandSlot.UnityTransform.SetLZ(0);
  1020. RightHandSlot.UnityTransform.SetLZ(0);
  1021. LeftShortSleeveSlot.UnityTransform.SetLZ(0);
  1022. RightShortSleeveSlot.UnityTransform.SetLZ(0);
  1023. WingSlot.SetLZ(0.003f);
  1024. EyeSlot.SetLZ(-0.001f);
  1025. TopSlot.SetLZ(-0.003f);
  1026. MouseSlot.SetLZ(-0.001f);
  1027. HeadWearSlot.SetLZ(-0.001f);
  1028. HeadSlot.UnityTransform.SetLZ(0);
  1029. if (HeadSlot.UnityTransform.childCount > 1)
  1030. {
  1031. HeadSlot.UnityTransform.GetChild(0).SetLZ(0.002f);
  1032. HeadSlot.UnityTransform.GetChild(1).SetLZ(0f);
  1033. }
  1034. DressSlot.UnityTransform.SetLZ(-0.002f);
  1035. if (DressSlot.UnityTransform.childCount > 1)
  1036. {
  1037. DressSlot.UnityTransform.GetChild(0).SetLZ(0.002f);
  1038. DressSlot.UnityTransform.GetChild(1).SetLZ(0f);
  1039. }
  1040. LeftShoeSlot.SetLZ(-0.001f);
  1041. RightShoeSlot.SetLZ(-0.001f);
  1042. LeftLegSlot.SetLZ(0);
  1043. RightLegSlot.SetLZ(0);
  1044. NeckSlot.SetLZ(0.001f);
  1045. LeftHandSlot.SetLZ(-0.001f);
  1046. RightHandSlot.SetLZ(-0.001f);
  1047. LeftShortSleeveSlot.SetLZ(-0.0015f);
  1048. RightShortSleeveSlot.SetLZ(-0.0015f);
  1049. LeftLongSleeveUAC.transform.SetLZ(-0.0015f);
  1050. RightLongSleeveUAC.transform.SetLZ(-0.0015f);
  1051. }
  1052. public void ChangeClose(BodyPart bodyPart, string armatureName, bool setDepth = true)
  1053. {
  1054. // Debug.Log (bodyPart + " " + armatureName);
  1055. List<DragonBones.Slot> slotList = new List<DragonBones.Slot>();
  1056. if (bodyPart == BodyPart.Eye)
  1057. {
  1058. Eye = armatureName;
  1059. slotList.Add(EyeSlot);
  1060. }
  1061. else if (bodyPart == BodyPart.Top)
  1062. {
  1063. Top = armatureName;
  1064. slotList.Add(TopSlot);
  1065. }
  1066. else if (bodyPart == BodyPart.Shoe)
  1067. {
  1068. Shoe = armatureName;
  1069. slotList.Add(LeftShoeSlot);
  1070. slotList.Add(RightShoeSlot);
  1071. }
  1072. else if (bodyPart == BodyPart.Head)
  1073. {
  1074. Head = armatureName;
  1075. slotList.Add(HeadSlot);
  1076. }
  1077. else if (bodyPart == BodyPart.Wing)
  1078. {
  1079. if (Wing == armatureName)
  1080. {
  1081. return;
  1082. }
  1083. else
  1084. {
  1085. Wing = armatureName;
  1086. slotList.Add(WingSlot);
  1087. }
  1088. }
  1089. else if (bodyPart == BodyPart.Dress)
  1090. {
  1091. Dress = armatureName;
  1092. slotList.Add(DressSlot);
  1093. }
  1094. else if (bodyPart == BodyPart.Mouse)
  1095. {
  1096. Mouse = armatureName;
  1097. slotList.Add(MouseSlot);
  1098. }
  1099. else if (bodyPart == BodyPart.Headwear)
  1100. {
  1101. HeadWear = armatureName;
  1102. slotList.Add(HeadWearSlot);
  1103. }
  1104. else if (bodyPart == BodyPart.Leg)
  1105. {
  1106. slotList.Add(LeftLegSlot);
  1107. slotList.Add(RightLegSlot);
  1108. }
  1109. else if (bodyPart == BodyPart.LeftHand)
  1110. {
  1111. slotList.Add(LeftHandSlot);
  1112. }
  1113. else if (bodyPart == BodyPart.RightHand)
  1114. {
  1115. slotList.Add(RightHandSlot);
  1116. }
  1117. else if (bodyPart == BodyPart.Neck)
  1118. {
  1119. slotList.Add(NeckSlot);
  1120. }
  1121. else if (bodyPart == BodyPart.LeftLongSleeve)
  1122. {
  1123. LeftLongSleeve = armatureName;
  1124. ChangeClose(LeftLongSleeveUAC, armatureName);
  1125. return;
  1126. }
  1127. else if (bodyPart == BodyPart.LeftShortSleeve)
  1128. {
  1129. LeftShortSleeve = armatureName;
  1130. slotList.Add(LeftShortSleeveSlot);
  1131. }
  1132. else if (bodyPart == BodyPart.RightLongSleeve)
  1133. {
  1134. RightLongSleeve = armatureName;
  1135. ChangeClose(RightLongSleeveUAC, armatureName);
  1136. return;
  1137. }
  1138. else if (bodyPart == BodyPart.RightShortSleeve)
  1139. {
  1140. RightShortSleeve = armatureName;
  1141. slotList.Add(RightShortSleeveSlot);
  1142. }
  1143. else
  1144. {
  1145. throw new Exception();
  1146. }
  1147. ChangeClose(slotList, armatureName, setDepth);
  1148. if (bodyPart == BodyPart.Wing)
  1149. {
  1150. 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);
  1151. tweenRoot.PingPong = true;
  1152. tweenRoot.StartForward();
  1153. }
  1154. }
  1155. public void ChangeClose(List<DragonBones.Slot> slotList, string armatureName, bool setDepth = true)
  1156. {
  1157. for (int i = 0; i < slotList.Count; i++)
  1158. {
  1159. slotList[i].childArmature = UnityFactory.factory.BuildArmature(armatureName, null, null, null, true);
  1160. slotList[i].UnityTransform = slotList[i].childArmature.UnityTransform.parent;
  1161. }
  1162. if (setDepth)
  1163. {
  1164. ResetDepth();
  1165. }
  1166. }
  1167. public void ChangeClose(UnityArmatureComponent uac, string armatureName, bool setDepth = true)
  1168. {
  1169. if (armatureName == "Empty")
  1170. {
  1171. uac.SetActive(false);
  1172. }
  1173. else
  1174. {
  1175. uac.SetActive(true);
  1176. }
  1177. if (setDepth)
  1178. {
  1179. ResetDepth();
  1180. }
  1181. }
  1182. #endregion
  1183. }