Player.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  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 Slot = DragonBones.Slot;
  11. using Random = UnityEngine.Random;
  12. using Transform = UnityEngine.Transform;
  13. public enum BodyPart
  14. {
  15. Eye,
  16. Top,
  17. Shoe,
  18. Head,
  19. Dress,
  20. Mouse,
  21. Headwear,
  22. }
  23. public class CloseUnit
  24. {
  25. public enum CloseType
  26. {
  27. Top,
  28. Hair,
  29. Wing,
  30. Dress,
  31. Decarator,
  32. }
  33. #region Var
  34. public string Description
  35. {
  36. get { return Language.GetStr("DressRoom", "Armature" + ID); }
  37. }
  38. public int ID;
  39. public int Index;
  40. public int BuyLevel;
  41. public int PixelSize;
  42. public bool Bought;
  43. public string ArmatureName;
  44. public float IconOffset;
  45. public Text BuyBtnLab;
  46. public Sprite[] Sprites;
  47. public Image Icon1;
  48. public Image Icon2;
  49. public Button BuyBtn;
  50. public Button DressBtn;
  51. public Vector2 Icon1Offset;
  52. public BodyPart BodyPart;
  53. public Transform Transform;
  54. public CloseType Type;
  55. public double BuyAmt;
  56. public double BuyAdvanceAmt;
  57. public Current BuyCurrent;
  58. public Current BuyAdvanceCurrent;
  59. public Dictionary<string, Transform> ChildDic = new Dictionary<string, Transform>();
  60. #endregion
  61. public CloseUnit(XmlAttributeCollection attribute)
  62. {
  63. ID = Auxiliary.IntParse(attribute[0].Value, -1);
  64. Type = TypeParse(attribute[2].Value);
  65. Index = Auxiliary.IntParse(attribute[3].Value, -1);
  66. BodyPart = BodyPartParse(attribute[4].Value);
  67. BuyLevel = Auxiliary.IntParse(attribute[5].Value, 0);
  68. BuyCurrent = Auxiliary.CurrentParse(attribute[6].Value);
  69. BuyAmt = Auxiliary.DoubleParse(attribute[7].Value, 0);
  70. BuyAdvanceCurrent = Auxiliary.CurrentParse(attribute[8].Value);
  71. BuyAdvanceAmt = Auxiliary.DoubleParse(attribute[9].Value, 0);
  72. PixelSize = Auxiliary.IntParse(attribute[10].Value, 100);
  73. IconOffset = Auxiliary.FloatParse(attribute[11].Value, 0);
  74. Icon1Offset = Auxiliary.VectorParse(',', attribute[12].Value, new Vector3());
  75. Sprites = SpriteParse(attribute[13].Value);
  76. ArmatureName = attribute[14].Value;
  77. ManaPlayer.CloseIDDic.Add(ArmatureName, ID);
  78. ManaPlayer.CloseUnitDic.Add(ID, this);
  79. CreateItem();
  80. }
  81. protected void CreateItem()
  82. {
  83. Transform = ManaReso.Get("CloseItem", Folder.UI, false, ManaReso.Get("Canvas"), false);
  84. if (Type == CloseType.Top)
  85. {
  86. Transform.SetParent(ManaReso.Get("Pb_TopGrid"));
  87. }
  88. else if (Type == CloseType.Hair)
  89. {
  90. Transform.SetParent(ManaReso.Get("Pa_HairGrid"));
  91. }
  92. else if (Type == CloseType.Dress)
  93. {
  94. Transform.SetParent(ManaReso.Get("Pc_DressGrid"));
  95. }
  96. else if (Type == CloseType.Wing)
  97. {
  98. Transform.SetParent(ManaReso.Get("Pe_WingGrid"));
  99. }
  100. else if (Type == CloseType.Decarator)
  101. {
  102. Transform.SetParent(ManaReso.Get("Pd_DecaratorGrid"));
  103. }
  104. else
  105. {
  106. throw new Exception();
  107. }
  108. Transform.SetSiblingIndex(Index);
  109. Auxiliary.CompileDic(Transform, ChildDic);
  110. Icon1 = ChildDic["Icon1"].GetComponent<Image>();
  111. Icon2 = ChildDic["Icon2"].GetComponent<Image>();
  112. DressBtn = ChildDic["CloseItem"].GetComponent<Button>();
  113. BuyBtn = ChildDic["BuyBtn"].GetComponent<Button>();
  114. BuyBtnLab = ChildDic["BuyBtnLab"].GetComponent<Text>();
  115. Icon2.sprite = Sprites[0];
  116. float newSize = PixelSize / Icon2.sprite.rect.width;
  117. Icon2.Resize(true, new Vector2(newSize, newSize));
  118. Icon2.transform.localPosition = new Vector2(0, IconOffset);
  119. if (Sprites.Length > 1)
  120. {
  121. Icon1.SetActive(true);
  122. Icon1.sprite = Sprites[1];
  123. Icon1.Resize(true, new Vector2(newSize, newSize));
  124. Icon1.transform.localPosition = Icon1Offset*newSize + new Vector2(0, IconOffset);
  125. }
  126. BuyBtnLab.text = Language.GetStr("UI", "P_BtnLab1");
  127. BuyBtn.onClick.AddListener
  128. (
  129. () =>
  130. {
  131. ManaAudio.PlayClip(Clip.BtnClip);
  132. ManaReso.Get("Pa_Info").TweenForCG();
  133. Image image = ManaReso.Get<Image>("Pa_Icon2");
  134. image.sprite = Sprites[0];
  135. image.Resize(true, new Vector2(newSize, newSize));
  136. if (Sprites.Length > 1)
  137. {
  138. ManaReso.SetActive("Pa_Icon1", true);
  139. Image image1 = ManaReso.Get<Image>("Pa_Icon1");
  140. image1.sprite = Sprites[1];
  141. image1.Resize(true, new Vector2(newSize, newSize));
  142. image1.transform.position = image.transform.position + (Vector3) Icon1Offset*newSize;
  143. }
  144. else
  145. {
  146. ManaReso.SetActive("Pa_Icon1", false);
  147. }
  148. ManaReso.SetText("Pa_Lab", Description);
  149. ManaReso.SetText("Pa_BtnLab", Language.GetStr("UI", "Pa_BtnLab") + Auxiliary.ImageParse(BuyCurrent) + BuyAmt.ToString("0"));
  150. ManaReso.SetButtonEvent
  151. (
  152. "Pa_Btn",
  153. OnBuy
  154. );
  155. }
  156. );
  157. DressBtn.onClick.AddListener
  158. (
  159. () =>
  160. {
  161. ManaAudio.PlayClip(Clip.BtnClip);
  162. ManaPlayer.Player.ChangeClose(BodyPart, ArmatureName);
  163. }
  164. );
  165. }
  166. protected Sprite[] SpriteParse(string str)
  167. {
  168. string[] spriteNames = str.Split(',');
  169. Sprite[] sprites = new Sprite[spriteNames.Length];
  170. for (int i = 0; i < spriteNames.Length; i++)
  171. {
  172. sprites[i] = ManaPlayer.CloseSpriteDic[spriteNames[i]];
  173. }
  174. return sprites;
  175. }
  176. protected BodyPart BodyPartParse(string str)
  177. {
  178. int type = Auxiliary.IntParse(str, -1);
  179. if (type == 1)
  180. {
  181. return BodyPart.Head;
  182. }
  183. else if (type == 2)
  184. {
  185. return BodyPart.Dress;
  186. }
  187. else if (type == 3)
  188. {
  189. return BodyPart.Shoe;
  190. }
  191. else if (type == 4)
  192. {
  193. return BodyPart.Headwear;
  194. }
  195. else if (type == 5)
  196. {
  197. return BodyPart.Top;
  198. }
  199. else
  200. {
  201. throw new Exception();
  202. }
  203. }
  204. protected CloseType TypeParse(string str)
  205. {
  206. int type = Auxiliary.IntParse(str, -1);
  207. if (type == 1)
  208. {
  209. return CloseType.Hair;
  210. }
  211. else if (type == 2)
  212. {
  213. return CloseType.Top;
  214. }
  215. else if (type == 3)
  216. {
  217. return CloseType.Dress;
  218. }
  219. else if (type == 4)
  220. {
  221. return CloseType.Decarator;
  222. }
  223. else if (type == 5)
  224. {
  225. return CloseType.Wing;
  226. }
  227. else
  228. {
  229. throw new Exception();
  230. }
  231. }
  232. public void Unlock()
  233. {
  234. Bought = true;
  235. BuyBtn.interactable = false;
  236. BuyBtn.image.material = Lib.GrayMat;
  237. BuyBtnLab.text = Language.GetStr("UI", "P_BtnLab2");
  238. }
  239. public void OnBuy()
  240. {
  241. ManaCenter.Pay
  242. (
  243. "",
  244. BuyAmt,
  245. BuyCurrent,
  246. () =>
  247. {
  248. Unlock();
  249. ManaAudio.PlayClip(Clip.CurrentClip);
  250. ManaPlayer.BoughtCloseList.UniqueAdd(ID);
  251. ManaReso.Get("Pa_Info").TweenBacCG();
  252. },
  253. false
  254. );
  255. }
  256. public void OnLevelChange()
  257. {
  258. }
  259. }
  260. public class Player : Regist , IPointerClickHandler
  261. {
  262. #region 变量
  263. public static bool InDressRoom;
  264. public static float JumpFrequency;
  265. public bool AnimLock1;
  266. public bool AnimLock2;
  267. public float JumpTime;
  268. public float JumpTimer;
  269. public Dictionary<string, Transform> ChildDic = new Dictionary<string, Transform>();
  270. #region 换装
  271. private string Eye;
  272. private string Top;
  273. private string Shoe;
  274. private string Head;
  275. private string Dress;
  276. private string Mouse;
  277. private string HeadWear;
  278. private string TempClose;
  279. public DragonBones.Slot EyeSlot;
  280. public DragonBones.Slot TopSlot;
  281. public DragonBones.Slot HeadSlot;
  282. public DragonBones.Slot DressSlot;
  283. public DragonBones.Slot MouseSlot;
  284. public DragonBones.Slot LeftShoeSlot;
  285. public DragonBones.Slot RightShoeSlot;
  286. public DragonBones.Slot HeadWearSlot;
  287. public UnityArmatureComponent UAC;
  288. #endregion
  289. #endregion
  290. public override bool RegistImmed()
  291. {
  292. if (base.RegistImmed())
  293. {
  294. return true;
  295. }
  296. enabled = true;
  297. Auxiliary.CompileDic(transform, ChildDic);
  298. Vector3 bigShadowScale = new Vector3(1.820952f, 2.418199f, 1.820952f);
  299. Vector3 smallShadowScale = new Vector3(1.081191f, 1.435807f, 1.081191f);
  300. ChildDic["Shadow"].CreateStreamScale
  301. (
  302. new List<float>() {0, 0, 0},
  303. new List<float>() {0.33f, 0.33f, 0.33f, 0.33f},
  304. new List<VecPair>() {new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale), new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale)},
  305. true,
  306. true,
  307. Curve.EaseOutQuad
  308. );
  309. return false;
  310. }
  311. public void FixedUpdate()
  312. {
  313. if (InDressRoom)
  314. {
  315. JumpTimer += Time.fixedDeltaTime;
  316. if (JumpTimer > JumpTime)
  317. {
  318. if (!AnimLock1 && !AnimLock2)
  319. {
  320. PlayAnim("newAnimation1");
  321. }
  322. AnimLock2 = true;
  323. }
  324. if (JumpTimer > JumpFrequency)
  325. {
  326. AnimLock2 = false;
  327. JumpTime = Mathf.Lerp(0, JumpFrequency, Random.Range(0f, 1f));
  328. JumpTimer = 0;
  329. }
  330. }
  331. }
  332. public void OnStart(string str, EventObject eventObject)
  333. {
  334. if (eventObject.animationState.name == "newAnimation1")
  335. {
  336. ChildDic["Shadow"].StreamReForScale();
  337. AnimLock1 = true;
  338. TempClose = Eye;
  339. ChangeClose(BodyPart.Eye, "眼睛表情1");
  340. }
  341. else if (eventObject.animationState.name == "newAnimation")
  342. {
  343. AnimLock1 = false;
  344. if (TempClose != null)
  345. {
  346. ChangeClose(BodyPart.Eye, TempClose);
  347. }
  348. }
  349. }
  350. public void PlayAnim(string animName)
  351. {
  352. if (AnimLock1)
  353. {
  354. return;
  355. }
  356. UAC.anim.Play(animName);
  357. }
  358. public void SetAllCollider(bool enable)
  359. {
  360. BoxCollider2D[] colliders = GetComponentsInChildren<BoxCollider2D>();
  361. for (int i = 0; i < colliders.Length; i++)
  362. {
  363. colliders[i].enabled = enable;
  364. }
  365. }
  366. public void OnPointerClick(PointerEventData eventData)
  367. {
  368. if (ManaCenter.Level < 13)
  369. {
  370. return;
  371. }
  372. ManaReso.Get("I_BlackMask").GetTweenCG().Duration = 0.5f;
  373. ManaAudio.PlayClip(Clip.CurrentClip);
  374. EnterDressRoom();
  375. }
  376. public void Save()
  377. {
  378. ManaAudio.PlayClip(Clip.BtnClip);
  379. List<CloseUnit> closeUnitList = new List<CloseUnit>();
  380. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Head]]);
  381. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Dress]]);
  382. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Shoe]]);
  383. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[HeadWear]]);
  384. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Top]]);
  385. for (int i = 0; i < closeUnitList.Count; i++)
  386. {
  387. if (!closeUnitList[i].Bought)
  388. {
  389. BuyNavigate(closeUnitList);
  390. return;
  391. }
  392. }
  393. ManaPlayer.DressData[0] = Head;
  394. ManaPlayer.DressData[1] = Dress;
  395. ManaPlayer.DressData[2] = Shoe;
  396. ManaPlayer.DressData[3] = HeadWear;
  397. ManaPlayer.DressData[4] = Top;
  398. ExitDressRoom();
  399. }
  400. public void Reset()
  401. {
  402. ManaAudio.PlayClip(Clip.BtnClip);
  403. List<string> dressData = new List<string>(ManaPlayer.DressData);
  404. dressData[5] = Eye;
  405. ManaPlayer.BuildPlayer(dressData);
  406. }
  407. public void BuyNavigate(List<CloseUnit> closeUnitList)
  408. {
  409. for (int i = 0; i < closeUnitList.Count; i++)
  410. {
  411. if (closeUnitList[i].Bought)
  412. {
  413. closeUnitList.RemoveAt(i--);
  414. }
  415. else
  416. {
  417. closeUnitList[i].BuyBtn.onClick.Invoke();
  418. closeUnitList.RemoveAt(i--);
  419. ManaReso.Get("Pa_Info").GetTweenCG().AddEventOnetime
  420. (
  421. EventType.BackwardFinish,
  422. () =>
  423. {
  424. BuyNavigate(closeUnitList);
  425. }
  426. );
  427. return;
  428. }
  429. }
  430. }
  431. public void ExitDressRoom()
  432. {
  433. ManaCenter.SceneSwitchLock = false;
  434. TweenRoot tweenRoot = ManaReso.Get("I_BlackMask").TweenBacCG();
  435. tweenRoot.AddEventOnetime
  436. (
  437. EventType.BackwardFinish,
  438. () =>
  439. {
  440. transform.position = ManaReso.Get("PlayerPosTra").position;
  441. transform.localScale = ManaReso.Get("PlayerPosTra").lossyScale;
  442. ManaReso.Get("Garden").TweenForSr();
  443. ManaReso.Get("DressRoom").TweenBacSr();
  444. ManaReso.Get("C_Main").TweenForCG();
  445. ManaReso.Get("P_DressRoom").TweenBacCG();
  446. }
  447. );
  448. tweenRoot = ManaReso.Get("P_DressRoom").GetTweenCG();
  449. tweenRoot.AddEventOnetime
  450. (
  451. EventType.BackwardFinish,
  452. () =>
  453. {
  454. SetAllCollider(true);
  455. InDressRoom = false;
  456. JumpTimer = 0;
  457. PlayAnim("newAnimation");
  458. ChildDic["Shadow"].GetStreamScale().Pause();
  459. ChildDic["Shadow"].GetStreamScale().InOrigin = true;
  460. ChildDic["Shadow"].SetActive(false);
  461. ManaReso.Get("B_SignIn0").TweenForCG();
  462. ManaReso.Get("I_BlackMask").TweenForCG();
  463. }
  464. );
  465. }
  466. public void EnterDressRoom()
  467. {
  468. if (ManaCenter.SceneSwitchLock)
  469. {
  470. return;
  471. }
  472. ManaReso.Get("B_SignIn0").TweenBacCG();
  473. InDressRoom = true;
  474. JumpTime = Mathf.Lerp(0, 10, Random.Range(0.5f, 1f));
  475. ManaCenter.SceneSwitchLock = true;
  476. ManaReso.Get("C_Main").TweenBacCG();
  477. SetAllCollider(false);
  478. TweenRoot tweenRoot = ManaReso.Get("I_BlackMask").TweenBacCG();
  479. tweenRoot.AddEventOnetime
  480. (
  481. EventType.BackwardFinish,
  482. () =>
  483. {
  484. for (int i = 0; i < ManaGarden.PlantList.Count; i++)
  485. {
  486. ManaGarden.PlantList[i].Flower.RetrieveElf();
  487. }
  488. ChildDic["Shadow"].SetActive(true);
  489. transform.position = ManaReso.Get("DressRoomPos").position;
  490. transform.localScale = ManaReso.Get("DressRoomPos").lossyScale;
  491. ManaReso.Get("Garden").TweenBacSr();
  492. ManaReso.Get("DressRoom").TweenForSr();
  493. ManaReso.Get("P_DressRoom").TweenForCG();
  494. }
  495. );
  496. tweenRoot = ManaReso.Get("P_DressRoom").GetTweenCG();
  497. tweenRoot.AddEventOnetime
  498. (
  499. EventType.ForwardFinish,
  500. () =>
  501. {
  502. if (!ManaPlayer.DressRoomInitialized)
  503. {
  504. ManaReso.SetText("I_Lab", Language.GetStr("UI", "I_Lab"));
  505. ManaReso.SetActive("I_Lab", true);
  506. Auxiliary.Instance.DelayCall
  507. (
  508. () =>
  509. {
  510. ManaPlayer.InitializeDressRoom();
  511. ManaReso.Get("I_BlackMask").TweenForCG();
  512. },
  513. 1
  514. );
  515. }
  516. else
  517. {
  518. ManaReso.Get("I_BlackMask").TweenForCG();
  519. }
  520. }
  521. );
  522. }
  523. #region 换装
  524. public UnityArmatureComponent Build()
  525. {
  526. if (!ManaPlayer.Complete)
  527. {
  528. UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("stand_ske", Folder.Config));
  529. UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("Closet_ske", Folder.Config));
  530. UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("stand_tex", Folder.Config), "stand_texture");
  531. UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("Closet_tex", Folder.Config), "Closet_texture");
  532. ManaPlayer.Complete = true;
  533. }
  534. UAC = UnityFactory.factory.BuildArmatureComponent("Armature");
  535. UAC.transform.parent = transform;
  536. UAC.transform.localScale = new Vector3(1, 1, 1);
  537. UAC.transform.localPosition = new Vector3();
  538. UAC.anim.Play("newAnimation");
  539. UAC.AddEventListener(EventObject.START, OnStart);
  540. Eye = "眼睛1";
  541. Top = "上衣1";
  542. Shoe = "鞋子1";
  543. Head = "脑壳1";
  544. Dress = "裙子1";
  545. Mouse = "嘴巴1";
  546. HeadWear = "头饰品1";
  547. EyeSlot = UAC.armature.GetSlot("眼睛");
  548. TopSlot = UAC.armature.GetSlot("上衣");
  549. HeadSlot = UAC.armature.GetSlot("脑壳");
  550. DressSlot = UAC.armature.GetSlot("裙子");
  551. MouseSlot = UAC.armature.GetSlot("嘴巴");
  552. LeftShoeSlot = UAC.armature.GetSlot("鞋子左");
  553. RightShoeSlot = UAC.armature.GetSlot("鞋子右");
  554. HeadWearSlot = UAC.armature.GetSlot("头饰品");
  555. ChangeClose(BodyPart.Eye, "眼睛1", false);
  556. ChangeClose(BodyPart.Top, "上衣1", false);
  557. ChangeClose(BodyPart.Shoe, "鞋子1", false);
  558. ChangeClose(BodyPart.Head, "脑壳1", false);
  559. ChangeClose(BodyPart.Dress, "裙子1", false);
  560. ChangeClose(BodyPart.Mouse, "嘴巴1", false);
  561. ChangeClose(BodyPart.Headwear, "头饰品1", false);
  562. return UAC;
  563. }
  564. public UnityArmatureComponent BuildPink()
  565. {
  566. Build();
  567. ChangeClose(BodyPart.Eye, "眼睛3");
  568. ChangeClose(BodyPart.Top, "上衣3");
  569. ChangeClose(BodyPart.Shoe, "鞋子3");
  570. ChangeClose(BodyPart.Head, "脑壳3");
  571. ChangeClose(BodyPart.Dress, "裙子3");
  572. ChangeClose(BodyPart.Mouse, "嘴巴3");
  573. ChangeClose(BodyPart.Headwear, "头饰品3");
  574. return UAC;
  575. }
  576. public UnityArmatureComponent BuildBlond()
  577. {
  578. Build();
  579. ResetDepth();
  580. return UAC;
  581. }
  582. public UnityArmatureComponent BuildBrown()
  583. {
  584. Build();
  585. ChangeClose(BodyPart.Eye, "眼睛2");
  586. ChangeClose(BodyPart.Top, "上衣2");
  587. ChangeClose(BodyPart.Shoe, "鞋子2");
  588. ChangeClose(BodyPart.Head, "脑壳2");
  589. ChangeClose(BodyPart.Dress, "裙子2");
  590. ChangeClose(BodyPart.Mouse, "嘴巴2");
  591. ChangeClose(BodyPart.Headwear, "头饰品2");
  592. return UAC;
  593. }
  594. public void ResetDepth()
  595. {
  596. UAC.transform.SetLZ(2);
  597. transform.FindChild("Armature/" + Eye).SetLZ(-0.001f);
  598. transform.FindChild("Armature/" + Top).SetLZ(-0.003f);
  599. transform.FindChild("Armature/" + Dress).SetLZ(-0.002f);
  600. transform.FindChild("Armature/" + Mouse).SetLZ(-0.001f);
  601. transform.FindChild("Armature/" + HeadWear).SetLZ(-0.001f);
  602. Transform tempTra = transform.FindChild("Armature/" + Head);
  603. tempTra.SetLZ(0);
  604. tempTra.GetChild(0).SetLZ(0.002f);
  605. tempTra = transform.FindChild("Armature/" + Shoe);
  606. tempTra.SetLZ(-0.001f);
  607. transform.FindChild("Armature").GetChild(tempTra.GetSiblingIndex() + 1).SetLZ(-0.001f);
  608. transform.FindChild("Armature/左腿").SetLZ(0);
  609. transform.FindChild("Armature/右腿").SetLZ(0);
  610. transform.FindChild("Armature/脖子").SetLZ(0.001f);
  611. transform.FindChild("Armature/左手").SetLZ(-0.001f);
  612. transform.FindChild("Armature/右手").SetLZ(-0.001f);
  613. }
  614. public void ChangeClose(BodyPart bodyPart, string armatureName, bool setDepth = true)
  615. {
  616. List<DragonBones.Slot> slotList = new List<DragonBones.Slot>();
  617. if (bodyPart == BodyPart.Eye)
  618. {
  619. Eye = armatureName;
  620. slotList.Add(EyeSlot);
  621. }
  622. else if (bodyPart == BodyPart.Top)
  623. {
  624. Top = armatureName;
  625. slotList.Add(TopSlot);
  626. }
  627. else if (bodyPart == BodyPart.Shoe)
  628. {
  629. Shoe = armatureName;
  630. slotList.Add(LeftShoeSlot);
  631. slotList.Add(RightShoeSlot);
  632. }
  633. else if (bodyPart == BodyPart.Head)
  634. {
  635. Head = armatureName;
  636. slotList.Add(HeadSlot);
  637. }
  638. else if (bodyPart == BodyPart.Dress)
  639. {
  640. Dress = armatureName;
  641. slotList.Add(DressSlot);
  642. }
  643. else if (bodyPart == BodyPart.Mouse)
  644. {
  645. Mouse = armatureName;
  646. slotList.Add(MouseSlot);
  647. }
  648. else if (bodyPart == BodyPart.Headwear)
  649. {
  650. HeadWear = armatureName;
  651. slotList.Add(HeadWearSlot);
  652. }
  653. else
  654. {
  655. throw new Exception();
  656. }
  657. ChangeClose(slotList, armatureName, setDepth);
  658. }
  659. public void ChangeClose(List<DragonBones.Slot> slotList, string armatureName, bool setDepth = true)
  660. {
  661. for (int i = 0; i < slotList.Count; i++)
  662. {
  663. slotList[i].childArmature = UnityFactory.factory.BuildArmature(armatureName);
  664. }
  665. if (setDepth)
  666. {
  667. ResetDepth();
  668. }
  669. }
  670. #endregion
  671. }