Player.cs 24 KB

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