Player.cs 27 KB

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