Player.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  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. ManaCenter.CloseAmt++;
  252. }
  253. public void OnBuy()
  254. {
  255. ManaCenter.Pay
  256. (
  257. "",
  258. BuyAmt,
  259. BuyCurrent,
  260. () =>
  261. {
  262. Unlock();
  263. ManaAudio.PlayClip(Clip.CurrentClip);
  264. ManaPlayer.BoughtCloseList.UniqueAdd(ID);
  265. ManaReso.Get("Pa_Info").TweenBacCG();
  266. },
  267. StaticsManager.ItemID.解锁服装,
  268. StaticsManager.ConsumeModule.Shop,
  269. false
  270. );
  271. }
  272. public void OnLevelChange()
  273. {
  274. }
  275. }
  276. public class Player : Regist , IPointerClickHandler
  277. {
  278. #region 变量
  279. public static bool InDressRoom;
  280. public static float JumpFrequency;
  281. public bool AnimLock1;
  282. public bool AnimLock2;
  283. public float JumpTime;
  284. public float JumpTimer;
  285. public Dictionary<string, Transform> ChildDic = new Dictionary<string, Transform>();
  286. #region 换装
  287. private string Eye;
  288. private string Top;
  289. private string Shoe;
  290. private string Head;
  291. private string Wing;
  292. private string Dress;
  293. private string Mouse;
  294. private string HeadWear;
  295. private string TempClose;
  296. public DragonBones.Slot EyeSlot;
  297. public DragonBones.Slot TopSlot;
  298. public DragonBones.Slot HeadSlot;
  299. public DragonBones.Slot DressSlot;
  300. public DragonBones.Slot WingSlot;
  301. public DragonBones.Slot MouseSlot;
  302. public DragonBones.Slot LeftShoeSlot;
  303. public DragonBones.Slot RightShoeSlot;
  304. public DragonBones.Slot HeadWearSlot;
  305. public UnityArmatureComponent UAC;
  306. #endregion
  307. #endregion
  308. public override bool RegistImmed()
  309. {
  310. if (base.RegistImmed())
  311. {
  312. return true;
  313. }
  314. enabled = true;
  315. Auxiliary.CompileDic(transform, ChildDic);
  316. Vector3 bigShadowScale = new Vector3(1.820952f, 2.418199f, 1.820952f);
  317. Vector3 smallShadowScale = new Vector3(1.081191f, 1.435807f, 1.081191f);
  318. ChildDic["Shadow"].CreateStreamScale
  319. (
  320. new List<float>() {0, 0, 0},
  321. new List<float>() {0.33f, 0.33f, 0.33f, 0.33f},
  322. new List<VecPair>() {new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale), new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale)},
  323. true,
  324. true,
  325. Curve.EaseOutQuad
  326. );
  327. return false;
  328. }
  329. public void Update()
  330. {
  331. if (Input.GetKeyDown(KeyCode.Space))
  332. {
  333. UnityFactory.factory.BuildArmature("脑壳1");
  334. }
  335. }
  336. public void FixedUpdate()
  337. {
  338. if (InDressRoom)
  339. {
  340. JumpTimer += Time.fixedDeltaTime;
  341. if (JumpTimer > JumpTime)
  342. {
  343. if (!AnimLock1 && !AnimLock2)
  344. {
  345. PlayAnim("newAnimation1");
  346. }
  347. AnimLock2 = true;
  348. }
  349. if (JumpTimer > JumpFrequency)
  350. {
  351. AnimLock2 = false;
  352. JumpTime = Mathf.Lerp(0, JumpFrequency, Random.Range(0f, 1f));
  353. JumpTimer = 0;
  354. }
  355. }
  356. }
  357. public void OnStart(string str, EventObject eventObject)
  358. {
  359. if (eventObject.animationState.name == "newAnimation1")
  360. {
  361. ChildDic["Shadow"].StreamReForScale();
  362. AnimLock1 = true;
  363. TempClose = Eye;
  364. ChangeClose(BodyPart.Eye, "眼睛表情1");
  365. }
  366. else if (eventObject.animationState.name == "newAnimation")
  367. {
  368. AnimLock1 = false;
  369. if (TempClose != null)
  370. {
  371. ChangeClose(BodyPart.Eye, TempClose);
  372. }
  373. }
  374. }
  375. public void PlayAnim(string animName)
  376. {
  377. if (AnimLock1)
  378. {
  379. return;
  380. }
  381. UAC.anim.Play(animName);
  382. }
  383. public void SetAllCollider(bool enable)
  384. {
  385. BoxCollider2D[] colliders = GetComponentsInChildren<BoxCollider2D>();
  386. for (int i = 0; i < colliders.Length; i++)
  387. {
  388. colliders[i].enabled = enable;
  389. }
  390. }
  391. public void OnPointerClick(PointerEventData eventData)
  392. {
  393. if (ManaCenter.Level < 13)
  394. {
  395. return;
  396. }
  397. ManaReso.Get("I_BlackMask").GetTweenCG().Duration = 0.5f;
  398. ManaAudio.PlayClip(Clip.CurrentClip);
  399. EnterDressRoom();
  400. }
  401. public void Save()
  402. {
  403. ManaAudio.PlayClip(Clip.BtnClip);
  404. List<CloseUnit> closeUnitList = new List<CloseUnit>();
  405. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Head]]);
  406. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Dress]]);
  407. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Shoe]]);
  408. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[HeadWear]]);
  409. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Top]]);
  410. if (Wing != "Empty")
  411. {
  412. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Wing]]);
  413. }
  414. for (int i = 0; i < closeUnitList.Count; i++)
  415. {
  416. if (!closeUnitList[i].Bought)
  417. {
  418. BuyNavigate(closeUnitList);
  419. return;
  420. }
  421. }
  422. ManaPlayer.DressData[0] = Head;
  423. ManaPlayer.DressData[1] = Dress;
  424. ManaPlayer.DressData[2] = Shoe;
  425. ManaPlayer.DressData[3] = HeadWear;
  426. ManaPlayer.DressData[4] = Top;
  427. ManaPlayer.DressData[7] = Wing;
  428. ExitDressRoom();
  429. }
  430. public void Reset()
  431. {
  432. ManaAudio.PlayClip(Clip.BtnClip);
  433. List<string> dressData = new List<string>(ManaPlayer.DressData);
  434. dressData[5] = Eye;
  435. ManaPlayer.BuildPlayer(dressData);
  436. }
  437. public void BuyNavigate(List<CloseUnit> closeUnitList)
  438. {
  439. for (int i = 0; i < closeUnitList.Count; i++)
  440. {
  441. if (closeUnitList[i].Bought)
  442. {
  443. closeUnitList.RemoveAt(i--);
  444. }
  445. else
  446. {
  447. closeUnitList[i].BuyBtn.onClick.Invoke();
  448. closeUnitList.RemoveAt(i--);
  449. ManaReso.Get("Pa_Info").GetTweenCG().AddEventOnetime
  450. (
  451. EventType.BackwardFinish,
  452. () =>
  453. {
  454. BuyNavigate(closeUnitList);
  455. }
  456. );
  457. return;
  458. }
  459. }
  460. }
  461. public void ExitDressRoom()
  462. {
  463. ManaCenter.SceneSwitchLock = false;
  464. TweenRoot tweenRoot = ManaReso.Get("I_BlackMask").TweenBacCG();
  465. tweenRoot.AddEventOnetime
  466. (
  467. EventType.BackwardFinish,
  468. () =>
  469. {
  470. transform.position = ManaReso.Get("PlayerPosTra").position;
  471. transform.localScale = ManaReso.Get("PlayerPosTra").lossyScale;
  472. ManaReso.Get("Garden").TweenForSr();
  473. ManaReso.Get("DressRoom").TweenBacSr();
  474. ManaReso.Get("C_Main").TweenForCG();
  475. ManaReso.Get("P_DressRoom").TweenBacCG();
  476. }
  477. );
  478. tweenRoot = ManaReso.Get("P_DressRoom").GetTweenCG();
  479. tweenRoot.AddEventOnetime
  480. (
  481. EventType.BackwardFinish,
  482. () =>
  483. {
  484. SetAllCollider(true);
  485. InDressRoom = false;
  486. JumpTimer = 0;
  487. PlayAnim("newAnimation");
  488. ChildDic["Shadow"].GetStreamScale().Pause();
  489. ChildDic["Shadow"].GetStreamScale().InOrigin = true;
  490. ChildDic["Shadow"].SetActive(false);
  491. ManaReso.Get("B_SignIn0").TweenForCG();
  492. ManaReso.Get("I_BlackMask").TweenForCG();
  493. }
  494. );
  495. }
  496. public void EnterDressRoom()
  497. {
  498. if (ManaCenter.SceneSwitchLock)
  499. {
  500. return;
  501. }
  502. ManaReso.Get("B_SignIn0").TweenBacCG();
  503. InDressRoom = true;
  504. JumpTime = Mathf.Lerp(0, 10, Random.Range(0.5f, 1f));
  505. ManaCenter.SceneSwitchLock = true;
  506. ManaReso.Get("C_Main").TweenBacCG();
  507. SetAllCollider(false);
  508. TweenRoot tweenRoot = ManaReso.Get("I_BlackMask").TweenBacCG();
  509. tweenRoot.AddEventOnetime
  510. (
  511. EventType.BackwardFinish,
  512. () =>
  513. {
  514. for (int i = 0; i < ManaGarden.PlantList.Count; i++)
  515. {
  516. ManaGarden.PlantList[i].Flower.RetrieveElf();
  517. }
  518. ChildDic["Shadow"].SetActive(true);
  519. transform.position = ManaReso.Get("DressRoomPos").position;
  520. transform.localScale = ManaReso.Get("DressRoomPos").lossyScale;
  521. ManaReso.Get("Garden").TweenBacSr();
  522. ManaReso.Get("DressRoom").TweenForSr();
  523. ManaReso.Get("P_DressRoom").TweenForCG();
  524. }
  525. );
  526. tweenRoot = ManaReso.Get("P_DressRoom").GetTweenCG();
  527. tweenRoot.AddEventOnetime
  528. (
  529. EventType.ForwardFinish,
  530. () =>
  531. {
  532. if (!ManaPlayer.DressRoomInitialized)
  533. {
  534. ManaReso.SetText("I_Lab", Language.GetStr("UI", "I_Lab"));
  535. ManaReso.SetActive("I_Lab", true);
  536. Auxiliary.Instance.DelayCall
  537. (
  538. () =>
  539. {
  540. ManaPlayer.InitializeDressRoom();
  541. ManaReso.Get("I_BlackMask").TweenForCG();
  542. },
  543. 1
  544. );
  545. }
  546. else
  547. {
  548. ManaReso.Get("I_BlackMask").TweenForCG();
  549. }
  550. }
  551. );
  552. }
  553. #region 换装
  554. public UnityArmatureComponent Build()
  555. {
  556. if (!ManaPlayer.Complete)
  557. {
  558. UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("stand_ske", Folder.Config));
  559. UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("Closet_ske", Folder.Config));
  560. UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("stand_tex", Folder.Config), "stand_texture");
  561. UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("Closet_tex", Folder.Config), "Closet_texture");
  562. ManaPlayer.Complete = true;
  563. }
  564. UAC = UnityFactory.factory.BuildArmatureComponent("Armature");
  565. UAC.transform.parent = transform;
  566. UAC.transform.localScale = new Vector3(1, 1, 1);
  567. UAC.transform.localPosition = new Vector3();
  568. UAC.anim.Play("newAnimation");
  569. UAC.AddEventListener(EventObject.START, OnStart);
  570. Eye = "眼睛1";
  571. Top = "上衣1";
  572. Shoe = "鞋子1";
  573. Head = "脑壳1";
  574. Wing = "Empty";
  575. Dress = "裙子1";
  576. Mouse = "嘴巴1";
  577. HeadWear = "头饰品1";
  578. EyeSlot = UAC.armature.GetSlot("眼睛");
  579. TopSlot = UAC.armature.GetSlot("上衣");
  580. HeadSlot = UAC.armature.GetSlot("脑壳");
  581. WingSlot = UAC.armature.GetSlot("翅膀");
  582. DressSlot = UAC.armature.GetSlot("裙子");
  583. MouseSlot = UAC.armature.GetSlot("嘴巴");
  584. LeftShoeSlot = UAC.armature.GetSlot("鞋子左");
  585. RightShoeSlot = UAC.armature.GetSlot("鞋子右");
  586. HeadWearSlot = UAC.armature.GetSlot("头饰品");
  587. ChangeClose(BodyPart.Eye, "眼睛1", false);
  588. ChangeClose(BodyPart.Top, "上衣1", false);
  589. ChangeClose(BodyPart.Shoe, "鞋子1", false);
  590. ChangeClose(BodyPart.Head, "脑壳1", false);
  591. ChangeClose(BodyPart.Dress, "裙子1", false);
  592. ChangeClose(BodyPart.Mouse, "嘴巴1", false);
  593. ChangeClose(BodyPart.Headwear, "头饰品1", false);
  594. return UAC;
  595. }
  596. public UnityArmatureComponent BuildPink()
  597. {
  598. Build();
  599. ChangeClose(BodyPart.Eye, "眼睛3", false);
  600. ChangeClose(BodyPart.Top, "上衣3", false);
  601. ChangeClose(BodyPart.Shoe, "鞋子3", false);
  602. ChangeClose(BodyPart.Head, "脑壳3", false);
  603. ChangeClose(BodyPart.Wing, "Empty", false);
  604. ChangeClose(BodyPart.Dress, "裙子3", false);
  605. ChangeClose(BodyPart.Mouse, "嘴巴3", false);
  606. ChangeClose(BodyPart.Headwear, "头饰品3", false);
  607. ResetDepth();
  608. return UAC;
  609. }
  610. public UnityArmatureComponent BuildBlond()
  611. {
  612. Build();
  613. ChangeClose(BodyPart.Wing, "Empty", false);
  614. ResetDepth();
  615. return UAC;
  616. }
  617. public UnityArmatureComponent BuildBrown()
  618. {
  619. Build();
  620. ChangeClose(BodyPart.Eye, "眼睛2", false);
  621. ChangeClose(BodyPart.Top, "上衣2", false);
  622. ChangeClose(BodyPart.Shoe, "鞋子2", false);
  623. ChangeClose(BodyPart.Head, "脑壳2", false);
  624. ChangeClose(BodyPart.Wing, "Empty", false);
  625. ChangeClose(BodyPart.Dress, "裙子2", false);
  626. ChangeClose(BodyPart.Mouse, "嘴巴2", false);
  627. ChangeClose(BodyPart.Headwear, "头饰品2", false);
  628. ResetDepth();
  629. return UAC;
  630. }
  631. public void ResetDepth()
  632. {
  633. UAC.transform.SetLZ(2);
  634. if (Wing != "Empty")
  635. {
  636. transform.FindChild("Armature/" + Wing).SetLZ(0.003f);
  637. }
  638. transform.FindChild("Armature/" + Eye).SetLZ(-0.001f);
  639. transform.FindChild("Armature/" + Top).SetLZ(-0.003f);
  640. transform.FindChild("Armature/" + Mouse).SetLZ(-0.001f);
  641. transform.FindChild("Armature/" + HeadWear).SetLZ(-0.001f);
  642. Transform tempTra = transform.FindChild("Armature/" + Head);
  643. tempTra.SetLZ(0);
  644. if (tempTra.childCount > 1)
  645. {
  646. tempTra.GetChild(0).SetLZ(0.002f);
  647. tempTra.GetChild(1).SetLZ(0f);
  648. }
  649. tempTra = transform.FindChild("Armature/" + Dress);
  650. tempTra.SetLZ(-0.002f);
  651. if (tempTra.childCount > 1)
  652. {
  653. tempTra.GetChild(0).SetLZ(0.001f);
  654. }
  655. tempTra = transform.FindChild("Armature/" + Shoe);
  656. tempTra.SetLZ(-0.001f);
  657. transform.FindChild("Armature").GetChild(tempTra.GetSiblingIndex() + 1).SetLZ(-0.001f);
  658. transform.FindChild("Armature/左腿").SetLZ(0);
  659. transform.FindChild("Armature/右腿").SetLZ(0);
  660. transform.FindChild("Armature/脖子").SetLZ(0.001f);
  661. transform.FindChild("Armature/左手").SetLZ(-0.001f);
  662. transform.FindChild("Armature/右手").SetLZ(-0.001f);
  663. }
  664. public void ChangeClose(BodyPart bodyPart, string armatureName, bool setDepth = true)
  665. {
  666. List<DragonBones.Slot> slotList = new List<DragonBones.Slot>();
  667. if (bodyPart == BodyPart.Eye)
  668. {
  669. Eye = armatureName;
  670. slotList.Add(EyeSlot);
  671. }
  672. else if (bodyPart == BodyPart.Top)
  673. {
  674. Top = armatureName;
  675. slotList.Add(TopSlot);
  676. }
  677. else if (bodyPart == BodyPart.Shoe)
  678. {
  679. Shoe = armatureName;
  680. slotList.Add(LeftShoeSlot);
  681. slotList.Add(RightShoeSlot);
  682. }
  683. else if (bodyPart == BodyPart.Head)
  684. {
  685. Head = armatureName;
  686. slotList.Add(HeadSlot);
  687. }
  688. else if (bodyPart == BodyPart.Wing)
  689. {
  690. if (Wing == armatureName)
  691. {
  692. return;
  693. }
  694. else
  695. {
  696. Wing = armatureName;
  697. slotList.Add(WingSlot);
  698. }
  699. }
  700. else if (bodyPart == BodyPart.Dress)
  701. {
  702. Dress = armatureName;
  703. slotList.Add(DressSlot);
  704. }
  705. else if (bodyPart == BodyPart.Mouse)
  706. {
  707. Mouse = armatureName;
  708. slotList.Add(MouseSlot);
  709. }
  710. else if (bodyPart == BodyPart.Headwear)
  711. {
  712. HeadWear = armatureName;
  713. slotList.Add(HeadWearSlot);
  714. }
  715. else
  716. {
  717. throw new Exception();
  718. }
  719. ChangeClose(slotList, armatureName, setDepth);
  720. if (bodyPart == BodyPart.Wing)
  721. {
  722. 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);
  723. tweenRoot.PingPong = true;
  724. tweenRoot.StartForward();
  725. }
  726. }
  727. public void ChangeClose(List<DragonBones.Slot> slotList, string armatureName, bool setDepth = true)
  728. {
  729. for (int i = 0; i < slotList.Count; i++)
  730. {
  731. slotList[i].childArmature = UnityFactory.factory.BuildArmature(armatureName);
  732. }
  733. if (setDepth)
  734. {
  735. ResetDepth();
  736. }
  737. }
  738. #endregion
  739. }