Player.cs 27 KB

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