Player.cs 25 KB

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