Player.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464
  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 SpriteRenderer ExpressionSr;
  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. ExpressionSr = ChildDic["ExpressionSr"].GetComponent<SpriteRenderer>();
  541. return false;
  542. }
  543. public void Update()
  544. {
  545. if (InDressRoom)
  546. {
  547. JumpTimer += Time.deltaTime;
  548. if (JumpTimer > JumpTime)
  549. {
  550. if (!AnimLock1 && !AnimLock2)
  551. {
  552. PlayAnim(JumpAnimationName);
  553. }
  554. AnimLock2 = true;
  555. }
  556. if (JumpTimer > JumpFrequency)
  557. {
  558. AnimLock2 = false;
  559. JumpTime = Mathf.Lerp(0, JumpFrequency, Random.Range(0f, 1f));
  560. JumpTimer = 0;
  561. }
  562. }
  563. //if (GardenSmartFoxManager.GardenSmartFox.PlazaRoomManager.InPlazaRoom)
  564. //{
  565. // MoveThread();
  566. //}
  567. }
  568. public void OnStart(string str, EventObject eventObject)
  569. {
  570. if (eventObject.animationState.name == JumpAnimationName)
  571. {
  572. Shadow.StreamReForScale();
  573. AnimLock1 = true;
  574. TempClose = Eye;
  575. ChangeClose(BodyPart.Eye, "眼睛表情1");
  576. }
  577. else if (eventObject.animationState.name == IdleAnimationName)
  578. {
  579. AnimLock1 = false;
  580. if (TempClose != null)
  581. {
  582. ChangeClose(BodyPart.Eye, TempClose);
  583. }
  584. }
  585. }
  586. public string CurrentAnimationName;
  587. public void PlayAnim(string animName)
  588. {
  589. if (AnimLock1)
  590. {
  591. return;
  592. }
  593. if (UAC.anim.lastAnimationName == animName)
  594. {
  595. return;
  596. }
  597. if (SFSManager.GardenSmartFox.PlazaRoomManager.JoinedPlazaRoom)
  598. {
  599. CurrentAnimationName = animName;
  600. }
  601. UAC.anim.FadeIn(animName, GetFadeInTime(UAC.anim.lastAnimationName, animName));
  602. }
  603. public float GetFadeInTime(string lastAnimation, string targetAnimation)
  604. {
  605. if (lastAnimation == JumpAnimationName && targetAnimation == IdleAnimationName)
  606. return -1f;
  607. else
  608. return 0.1f;
  609. //throw new Exception();
  610. }
  611. public void SetAllCollider(bool enable)
  612. {
  613. BoxCollider2D[] colliders = GetComponentsInChildren<BoxCollider2D>();
  614. for (int i = 0; i < colliders.Length; i++)
  615. {
  616. colliders[i].enabled = enable;
  617. }
  618. }
  619. public void OnPointerClick(PointerEventData eventData)
  620. {
  621. ManaAudio.PlayClip(Clip.CurrentClip);
  622. PlayAnim(JumpAnimationName);
  623. }
  624. public void ResetExpression()
  625. {
  626. ExpressionSr.SetActive(false);
  627. EyeSlot.UnityTransform.GetChild(0).SetActive(true);
  628. MouseSlot.UnityTransform.GetChild(0).SetActive(true);
  629. }
  630. private string ExpressionName;
  631. private Coroutine ResetExpressionCoroutine;
  632. public void ChangeExpression(string expressionName, float duration)
  633. {
  634. ExpressionName = expressionName;
  635. ExpressionSr.sprite = ManaReso.LoadSprite(expressionName, Folder.Scene);
  636. ExpressionSr.transform.parent = EyeSlot.UnityTransform;
  637. ExpressionSr.SetActive(true);
  638. EyeSlot.UnityTransform.GetChild(0).SetActive(false);
  639. MouseSlot.UnityTransform.GetChild(0).SetActive(false);
  640. FlipExpression(expressionName, PlayerDirection);
  641. if (ResetExpressionCoroutine != null)
  642. Auxiliary.Instance.StopCoroutine(ResetExpressionCoroutine);
  643. ResetExpressionCoroutine = Auxiliary.Instance.DelayCall
  644. (
  645. () =>
  646. {
  647. ResetExpression();
  648. },
  649. duration
  650. );
  651. }
  652. public void Flip(PlayerDirection direction)
  653. {
  654. FlipExpression(ExpressionName, direction);
  655. if (direction == PlayerDirection.Left)
  656. {
  657. UAC.armature.flipX = false;
  658. playerDirection = PlayerDirection.Left;
  659. }
  660. else if (direction == PlayerDirection.Right)
  661. {
  662. UAC.armature.flipX = true;
  663. playerDirection = PlayerDirection.Right;
  664. }
  665. else
  666. {
  667. throw new Exception();
  668. }
  669. DelayCall.Call(1, () => Shadow.SetX(Pivot.position.x));
  670. }
  671. public void FlipExpression(string expressionName, PlayerDirection direction)
  672. {
  673. if (string.IsNullOrEmpty(ExpressionName))
  674. {
  675. return;
  676. }
  677. if (direction == PlayerDirection.Left)
  678. {
  679. ExpressionSr.flipX = false;
  680. ExpressionSr.transform.localPosition = LeftExpressionPositionDictionary[ExpressionName];
  681. }
  682. else if (direction == PlayerDirection.Right)
  683. {
  684. UAC.armature.flipX = true;
  685. ExpressionSr.flipX = true;
  686. ExpressionSr.transform.localPosition = RightExpressionPositionDictionary[ExpressionName];
  687. playerDirection = PlayerDirection.Right;
  688. }
  689. else
  690. {
  691. throw new Exception();
  692. }
  693. }
  694. public void Save(bool showNavigate)
  695. {
  696. ManaAudio.PlayClip(Clip.BtnClip);
  697. List<CloseUnit> closeUnitList = new List<CloseUnit>();
  698. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Head]]);
  699. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Dress]]);
  700. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Shoe]]);
  701. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[HeadWear]]);
  702. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Top]]);
  703. if (Wing != "Empty")
  704. {
  705. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Wing]]);
  706. }
  707. for (int i = 0; i < closeUnitList.Count; i++)
  708. {
  709. if (!closeUnitList[i].Bought)
  710. {
  711. if (showNavigate)
  712. {
  713. BuyNavigate(closeUnitList);
  714. }
  715. return;
  716. }
  717. }
  718. ManaPlayer.DressData[0] = Head;
  719. ManaPlayer.DressData[1] = Dress;
  720. ManaPlayer.DressData[2] = Shoe;
  721. ManaPlayer.DressData[3] = HeadWear;
  722. ManaPlayer.DressData[4] = Top;
  723. ManaPlayer.DressData[7] = Wing;
  724. ManaPlayer.DressData[8] = LeftLongSleeve;
  725. ManaPlayer.DressData[9] = LeftShortSleeve;
  726. ManaPlayer.DressData[10] = RightLongSleeve;
  727. ManaPlayer.DressData[11] = RightShortSleeve;
  728. //GardenSmartFoxManager.GardenSmartFox.PlazaRoomManager.SyncClose();
  729. }
  730. public void Reset()
  731. {
  732. ManaAudio.PlayClip(Clip.BtnClip);
  733. List<string> dressData = new List<string>(ManaPlayer.DressData);
  734. dressData[5] = Eye;
  735. ManaPlayer.BuildPlayer(dressData);
  736. }
  737. public void Return()
  738. {
  739. bool allSave = true;
  740. bool allBought = true;
  741. List<string> currentDerssData = new List<string>() {Head, Dress, Shoe, HeadWear, Top, Wing};
  742. for (int i = 0; i < currentDerssData.Count; i++)
  743. {
  744. if (!ManaPlayer.CloseIDDic.ContainsKey(currentDerssData[i]))
  745. {
  746. continue;
  747. }
  748. int id = ManaPlayer.CloseIDDic[currentDerssData[i]];
  749. allBought = allBought && ManaPlayer.CloseUnitDic[id].Bought;
  750. //Debug.Log(ManaPlayer.CloseUnitDic[id].Name + " " + ManaPlayer.CloseUnitDic[id].Bought);
  751. allSave = allSave && currentDerssData[i] == ManaPlayer.DressData[i];
  752. }
  753. if (allBought)
  754. {
  755. if (allSave)
  756. {
  757. ExitDressRoom();
  758. }
  759. else
  760. {
  761. Reset();
  762. ExitDressRoom();
  763. }
  764. }
  765. else
  766. {
  767. Bubble.Show
  768. (
  769. null, Language.GetStr("UI", "P_Return"), null, null,
  770. () =>
  771. {
  772. Reset();
  773. ManaReso.Get("K_Bubble").GetTweenGra().AddEventOnetime(EventType.BackwardFinish, () => { ExitDressRoom(); });
  774. }
  775. );
  776. }
  777. }
  778. public void BuyNavigate(List<CloseUnit> closeUnitList)
  779. {
  780. for (int i = 0; i < closeUnitList.Count; i++)
  781. {
  782. if (closeUnitList[i].Bought)
  783. {
  784. closeUnitList.RemoveAt(i--);
  785. }
  786. else
  787. {
  788. closeUnitList[i].BuyBtn.onClick.Invoke();
  789. closeUnitList.RemoveAt(i--);
  790. ManaReso.Get("Pa_Info").GetTweenCG().AddEventOnetime
  791. (
  792. EventType.BackwardFinish,
  793. () =>
  794. {
  795. if (closeUnitList.Count == 0)
  796. {
  797. Save(false);
  798. }
  799. else
  800. {
  801. BuyNavigate(closeUnitList);
  802. }
  803. }
  804. );
  805. return;
  806. }
  807. }
  808. }
  809. public void ExitDressRoom()
  810. {
  811. ManaCenter.SceneSwitchLock = false;
  812. TweenRoot tweenRoot = ManaReso.Get("I_BlackMask").TweenBacCG();
  813. tweenRoot.AddEventOnetime
  814. (
  815. EventType.BackwardFinish,
  816. () =>
  817. {
  818. transform.SetParent(ManaReso.Get("GardenNormal"));
  819. transform.position = ManaReso.Get("PlayerPosTra").position;
  820. transform.localScale = ManaReso.Get("PlayerPosTra").lossyScale;
  821. ManaReso.Get("Garden").TweenForSr();
  822. ManaReso.Get("DressRoom").TweenBacSr();
  823. ManaReso.Get("C_Main").TweenForCG();
  824. ManaReso.Get("P_DressRoom").TweenBacCG();
  825. }
  826. );
  827. tweenRoot = ManaReso.Get("P_DressRoom").GetTweenCG();
  828. tweenRoot.AddEventOnetime
  829. (
  830. EventType.BackwardFinish,
  831. () =>
  832. {
  833. SetAllCollider(true);
  834. InDressRoom = false;
  835. JumpTimer = 0;
  836. PlayAnim(IdleAnimationName);
  837. DeactiveShadow();
  838. ManaReso.Get("B_SignIn0").TweenForCG();
  839. ManaReso.Get("I_BlackMask").TweenForCG();
  840. }
  841. );
  842. }
  843. public void EnterDressRoom()
  844. {
  845. if (ManaCenter.SceneSwitchLock)
  846. {
  847. return;
  848. }
  849. ManaReso.Get("B_SignIn0").TweenBacCG();
  850. InDressRoom = true;
  851. JumpTime = Mathf.Lerp(0, 10, Random.Range(0.5f, 1f));
  852. ManaCenter.SceneSwitchLock = true;
  853. ManaReso.Get("C_Main").TweenBacCG();
  854. SetAllCollider(false);
  855. TweenRoot tweenRoot = ManaReso.Get("I_BlackMask").TweenBacCG();
  856. tweenRoot.AddEventOnetime
  857. (
  858. EventType.BackwardFinish,
  859. () =>
  860. {
  861. ManaGarden.RetrieveAllElf();
  862. ManaIAP.RetrieveADChest();
  863. ActiveShadow();
  864. transform.SetParent(ManaReso.Get("DressRoom"));
  865. transform.position = ManaReso.Get("DressRoomPos").position;
  866. transform.localScale = ManaReso.Get("DressRoomPos").lossyScale;
  867. ManaReso.Get("Garden").TweenBacSr();
  868. ManaReso.Get("DressRoom").TweenForSr();
  869. ManaReso.Get("P_DressRoom").TweenForCG();
  870. }
  871. );
  872. tweenRoot = ManaReso.Get("P_DressRoom").GetTweenCG();
  873. tweenRoot.AddEventOnetime
  874. (
  875. EventType.ForwardFinish,
  876. () =>
  877. {
  878. ManaReso.Get("I_BlackMask").TweenForCG();
  879. }
  880. );
  881. }
  882. public void ActiveShadow()
  883. {
  884. ChildDic["ShadowParent"].SetActive(true);
  885. ChildDic["ShadowParent"].SetLZ(3);
  886. }
  887. public void DeactiveShadow()
  888. {
  889. Shadow.GetStreamScale().Pause();
  890. Shadow.GetStreamScale().InOrigin = true;
  891. ChildDic["ShadowParent"].SetActive(false);
  892. }
  893. #region 换装
  894. public void CorrectPivot()
  895. {
  896. List<Transform> children = new List<Transform>();
  897. while (transform.childCount > 0)
  898. {
  899. children.Add(transform.GetChild(0));
  900. children.Back(0).parent = null;
  901. }
  902. Vector3 offset = Pivot.position - transform.position;
  903. children[0].position += offset;
  904. children[1].position += offset;
  905. transform.position += offset;
  906. foreach (var collider in GetComponents<BoxCollider2D>())
  907. {
  908. collider.offset -= new Vector2(offset.x, offset.y);
  909. }
  910. for (int i = 0; i < children.Count; i++)
  911. {
  912. children[i].parent = transform;
  913. }
  914. }
  915. public UnityArmatureComponent Build()
  916. {
  917. if (!ManaPlayer.Complete)
  918. {
  919. UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("stand_ske", Folder.Config));
  920. UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("stand_tex", Folder.Config), "stand_texture");
  921. ManaPlayer.Complete = true;
  922. }
  923. UAC = UnityFactory.factory.BuildArmatureComponent("Armature");
  924. UAC.transform.parent = transform;
  925. UAC.transform.localScale = new Vector3(1, 1, 1);
  926. UAC.transform.localPosition = new Vector3();
  927. UAC.anim.Play(IdleAnimationName);
  928. UAC.AddEventListener(EventObject.START, OnStart);
  929. Eye = "眼睛1";
  930. Top = "上衣1";
  931. Shoe = "鞋子1";
  932. Head = "脑壳1";
  933. Wing = "Empty";
  934. Dress = "裙子1";
  935. Mouse = "嘴巴1";
  936. HeadWear = "头饰品1";
  937. NeckSlot = UAC.armature.GetSlot("脖子");
  938. LeftHandSlot = UAC.armature.GetSlot("左手");
  939. RightHandSlot = UAC.armature.GetSlot("右手");
  940. LeftLegSlot = UAC.armature.GetSlot("左腿");
  941. RightLegSlot = UAC.armature.GetSlot("右腿");
  942. LeftLongSleeveUAC = UAC.transform.FindChild("长袖9左 (长袖9左)").GetComponent<UnityArmatureComponent>();
  943. RightLongSleeveUAC = UAC.transform.FindChild("长袖9右 (长袖9右)").GetComponent<UnityArmatureComponent>();
  944. LeftShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子左");
  945. RightShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子右");
  946. EyeSlot = UAC.armature.GetSlot("眼睛");
  947. TopSlot = UAC.armature.GetSlot("上衣");
  948. HeadSlot = UAC.armature.GetSlot("脑壳");
  949. WingSlot = UAC.armature.GetSlot("翅膀");
  950. DressSlot = UAC.armature.GetSlot("裙子");
  951. MouseSlot = UAC.armature.GetSlot("嘴巴");
  952. LeftShoeSlot = UAC.armature.GetSlot("鞋子左");
  953. RightShoeSlot = UAC.armature.GetSlot("鞋子右");
  954. HeadWearSlot = UAC.armature.GetSlot("头饰品");
  955. ChangeClose(BodyPart.Eye, "眼睛1", false);
  956. ChangeClose(BodyPart.Top, "上衣1", false);
  957. ChangeClose(BodyPart.Shoe, "鞋子1", false);
  958. ChangeClose(BodyPart.Head, "脑壳1", false);
  959. ChangeClose(BodyPart.Dress, "裙子1", false);
  960. ChangeClose(BodyPart.Mouse, "嘴巴1", false);
  961. ChangeClose(BodyPart.Headwear, "头饰品1", false);
  962. ChangeClose(BodyPart.LeftLongSleeve, "Empty", false);
  963. ChangeClose(BodyPart.RightLongSleeve, "Empty", false);
  964. ChangeClose(BodyPart.LeftShortSleeve, "短袖2左", false);
  965. ChangeClose(BodyPart.RightShortSleeve, "短袖2右", false);
  966. CorrectPivot();
  967. return UAC;
  968. }
  969. public UnityArmatureComponent BuildPink()
  970. {
  971. Build();
  972. ChangeClose(BodyPart.Eye, "眼睛3", false);
  973. ChangeClose(BodyPart.Top, "上衣3", false);
  974. ChangeClose(BodyPart.Shoe, "鞋子3", false);
  975. ChangeClose(BodyPart.Head, "脑壳3", false);
  976. ChangeClose(BodyPart.Wing, "Empty", false);
  977. ChangeClose(BodyPart.Dress, "裙子3", false);
  978. ChangeClose(BodyPart.Mouse, "嘴巴3", false);
  979. ChangeClose(BodyPart.Headwear, "头饰品3", false);
  980. ResetDepth();
  981. return UAC;
  982. }
  983. public UnityArmatureComponent BuildBlond()
  984. {
  985. Build();
  986. ChangeClose(BodyPart.Wing, "Empty", false);
  987. ResetDepth();
  988. return UAC;
  989. }
  990. public UnityArmatureComponent BuildBrown()
  991. {
  992. Build();
  993. ChangeClose(BodyPart.Eye, "眼睛2", false);
  994. ChangeClose(BodyPart.Top, "上衣2", false);
  995. ChangeClose(BodyPart.Shoe, "鞋子2", false);
  996. ChangeClose(BodyPart.Head, "脑壳2", false);
  997. ChangeClose(BodyPart.Wing, "Empty", false);
  998. ChangeClose(BodyPart.Dress, "裙子2", false);
  999. ChangeClose(BodyPart.Mouse, "嘴巴2", false);
  1000. ChangeClose(BodyPart.Headwear, "头饰品2", false);
  1001. ResetDepth();
  1002. return UAC;
  1003. }
  1004. public void ResetDepth()
  1005. {
  1006. UAC.transform.SetLZ(2.5f);
  1007. WingSlot.UnityTransform.SetLZ(0);
  1008. EyeSlot.UnityTransform.SetLZ(0);
  1009. TopSlot.UnityTransform.SetLZ(0);
  1010. MouseSlot.UnityTransform.SetLZ(0);
  1011. HeadWearSlot.UnityTransform.SetLZ(0);
  1012. LeftShoeSlot.UnityTransform.SetLZ(0);
  1013. RightShoeSlot.UnityTransform.SetLZ(0);
  1014. LeftLegSlot.UnityTransform.SetLZ(0);
  1015. RightLegSlot.UnityTransform.SetLZ(0);
  1016. NeckSlot.UnityTransform.SetLZ(0);
  1017. LeftHandSlot.UnityTransform.SetLZ(0);
  1018. RightHandSlot.UnityTransform.SetLZ(0);
  1019. LeftShortSleeveSlot.UnityTransform.SetLZ(0);
  1020. RightShortSleeveSlot.UnityTransform.SetLZ(0);
  1021. WingSlot.SetLZ(0.003f);
  1022. EyeSlot.SetLZ(-0.001f);
  1023. TopSlot.SetLZ(-0.003f);
  1024. MouseSlot.SetLZ(-0.001f);
  1025. HeadWearSlot.SetLZ(-0.001f);
  1026. HeadSlot.UnityTransform.SetLZ(0);
  1027. if (HeadSlot.UnityTransform.childCount > 1)
  1028. {
  1029. HeadSlot.UnityTransform.GetChild(0).SetLZ(0.002f);
  1030. HeadSlot.UnityTransform.GetChild(1).SetLZ(0f);
  1031. }
  1032. DressSlot.UnityTransform.SetLZ(-0.002f);
  1033. if (DressSlot.UnityTransform.childCount > 1)
  1034. {
  1035. DressSlot.UnityTransform.GetChild(0).SetLZ(0.002f);
  1036. DressSlot.UnityTransform.GetChild(1).SetLZ(0f);
  1037. }
  1038. LeftShoeSlot.SetLZ(-0.001f);
  1039. RightShoeSlot.SetLZ(-0.001f);
  1040. LeftLegSlot.SetLZ(0);
  1041. RightLegSlot.SetLZ(0);
  1042. NeckSlot.SetLZ(0.001f);
  1043. LeftHandSlot.SetLZ(-0.001f);
  1044. RightHandSlot.SetLZ(-0.001f);
  1045. LeftShortSleeveSlot.SetLZ(-0.0015f);
  1046. RightShortSleeveSlot.SetLZ(-0.0015f);
  1047. LeftLongSleeveUAC.transform.SetLZ(-0.0015f);
  1048. RightLongSleeveUAC.transform.SetLZ(-0.0015f);
  1049. }
  1050. public void ChangeClose(BodyPart bodyPart, string armatureName, bool setDepth = true)
  1051. {
  1052. // Debug.Log (bodyPart + " " + armatureName);
  1053. List<DragonBones.Slot> slotList = new List<DragonBones.Slot>();
  1054. if (bodyPart == BodyPart.Eye)
  1055. {
  1056. Eye = armatureName;
  1057. slotList.Add(EyeSlot);
  1058. }
  1059. else if (bodyPart == BodyPart.Top)
  1060. {
  1061. Top = armatureName;
  1062. slotList.Add(TopSlot);
  1063. }
  1064. else if (bodyPart == BodyPart.Shoe)
  1065. {
  1066. Shoe = armatureName;
  1067. slotList.Add(LeftShoeSlot);
  1068. slotList.Add(RightShoeSlot);
  1069. }
  1070. else if (bodyPart == BodyPart.Head)
  1071. {
  1072. Head = armatureName;
  1073. slotList.Add(HeadSlot);
  1074. }
  1075. else if (bodyPart == BodyPart.Wing)
  1076. {
  1077. if (Wing == armatureName)
  1078. {
  1079. return;
  1080. }
  1081. else
  1082. {
  1083. Wing = armatureName;
  1084. slotList.Add(WingSlot);
  1085. }
  1086. }
  1087. else if (bodyPart == BodyPart.Dress)
  1088. {
  1089. Dress = armatureName;
  1090. slotList.Add(DressSlot);
  1091. }
  1092. else if (bodyPart == BodyPart.Mouse)
  1093. {
  1094. Mouse = armatureName;
  1095. slotList.Add(MouseSlot);
  1096. }
  1097. else if (bodyPart == BodyPart.Headwear)
  1098. {
  1099. HeadWear = armatureName;
  1100. slotList.Add(HeadWearSlot);
  1101. }
  1102. else if (bodyPart == BodyPart.Leg)
  1103. {
  1104. slotList.Add(LeftLegSlot);
  1105. slotList.Add(RightLegSlot);
  1106. }
  1107. else if (bodyPart == BodyPart.LeftHand)
  1108. {
  1109. slotList.Add(LeftHandSlot);
  1110. }
  1111. else if (bodyPart == BodyPart.RightHand)
  1112. {
  1113. slotList.Add(RightHandSlot);
  1114. }
  1115. else if (bodyPart == BodyPart.Neck)
  1116. {
  1117. slotList.Add(NeckSlot);
  1118. }
  1119. else if (bodyPart == BodyPart.LeftLongSleeve)
  1120. {
  1121. LeftLongSleeve = armatureName;
  1122. ChangeClose(LeftLongSleeveUAC, armatureName);
  1123. return;
  1124. }
  1125. else if (bodyPart == BodyPart.LeftShortSleeve)
  1126. {
  1127. LeftShortSleeve = armatureName;
  1128. slotList.Add(LeftShortSleeveSlot);
  1129. }
  1130. else if (bodyPart == BodyPart.RightLongSleeve)
  1131. {
  1132. RightLongSleeve = armatureName;
  1133. ChangeClose(RightLongSleeveUAC, armatureName);
  1134. return;
  1135. }
  1136. else if (bodyPart == BodyPart.RightShortSleeve)
  1137. {
  1138. RightShortSleeve = armatureName;
  1139. slotList.Add(RightShortSleeveSlot);
  1140. }
  1141. else
  1142. {
  1143. throw new Exception();
  1144. }
  1145. ChangeClose(slotList, armatureName, setDepth);
  1146. if (bodyPart == BodyPart.Wing)
  1147. {
  1148. 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);
  1149. tweenRoot.PingPong = true;
  1150. tweenRoot.StartForward();
  1151. }
  1152. }
  1153. public void ChangeClose(List<DragonBones.Slot> slotList, string armatureName, bool setDepth = true)
  1154. {
  1155. for (int i = 0; i < slotList.Count; i++)
  1156. {
  1157. slotList[i].childArmature = UnityFactory.factory.BuildArmature(armatureName, null, null, null, true);
  1158. slotList[i].UnityTransform = slotList[i].childArmature.UnityTransform.parent;
  1159. }
  1160. if (setDepth)
  1161. {
  1162. ResetDepth();
  1163. }
  1164. }
  1165. public void ChangeClose(UnityArmatureComponent uac, string armatureName, bool setDepth = true)
  1166. {
  1167. if (armatureName == "Empty")
  1168. {
  1169. uac.SetActive(false);
  1170. }
  1171. else
  1172. {
  1173. uac.SetActive(true);
  1174. }
  1175. if (setDepth)
  1176. {
  1177. ResetDepth();
  1178. }
  1179. }
  1180. #endregion
  1181. }