Player.cs 25 KB

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