Player.cs 26 KB

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