Player.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  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.001f);
  713. }
  714. tempTra = transform.FindChild("Armature/" + Shoe);
  715. tempTra.SetLZ(-0.001f);
  716. transform.FindChild("Armature").GetChild(tempTra.GetSiblingIndex() + 1).SetLZ(-0.001f);
  717. transform.FindChild("Armature/左腿").SetLZ(0);
  718. transform.FindChild("Armature/右腿").SetLZ(0);
  719. transform.FindChild("Armature/脖子").SetLZ(0.001f);
  720. transform.FindChild("Armature/左手").SetLZ(-0.001f);
  721. transform.FindChild("Armature/右手").SetLZ(-0.001f);
  722. }
  723. public void ChangeClose(BodyPart bodyPart, string armatureName, bool setDepth = true)
  724. {
  725. List<DragonBones.Slot> slotList = new List<DragonBones.Slot>();
  726. if (bodyPart == BodyPart.Eye)
  727. {
  728. Eye = armatureName;
  729. slotList.Add(EyeSlot);
  730. }
  731. else if (bodyPart == BodyPart.Top)
  732. {
  733. Top = armatureName;
  734. slotList.Add(TopSlot);
  735. }
  736. else if (bodyPart == BodyPart.Shoe)
  737. {
  738. Shoe = armatureName;
  739. slotList.Add(LeftShoeSlot);
  740. slotList.Add(RightShoeSlot);
  741. }
  742. else if (bodyPart == BodyPart.Head)
  743. {
  744. Head = armatureName;
  745. slotList.Add(HeadSlot);
  746. }
  747. else if (bodyPart == BodyPart.Wing)
  748. {
  749. if (Wing == armatureName)
  750. {
  751. return;
  752. }
  753. else
  754. {
  755. Wing = armatureName;
  756. slotList.Add(WingSlot);
  757. }
  758. }
  759. else if (bodyPart == BodyPart.Dress)
  760. {
  761. Dress = armatureName;
  762. slotList.Add(DressSlot);
  763. }
  764. else if (bodyPart == BodyPart.Mouse)
  765. {
  766. Mouse = armatureName;
  767. slotList.Add(MouseSlot);
  768. }
  769. else if (bodyPart == BodyPart.Headwear)
  770. {
  771. HeadWear = armatureName;
  772. slotList.Add(HeadWearSlot);
  773. }
  774. else if (bodyPart == BodyPart.Leg)
  775. {
  776. slotList.Add(LeftLegSlot);
  777. slotList.Add(RightLegSlot);
  778. }
  779. else if (bodyPart == BodyPart.LeftHand)
  780. {
  781. slotList.Add(LeftHandSlot);
  782. }
  783. else if (bodyPart == BodyPart.RightHand)
  784. {
  785. slotList.Add(RightHandSlot);
  786. }
  787. else if (bodyPart == BodyPart.Neck)
  788. {
  789. slotList.Add(NeckSlot);
  790. }
  791. else
  792. {
  793. throw new Exception();
  794. }
  795. ChangeClose(slotList, armatureName, setDepth);
  796. if (bodyPart == BodyPart.Wing)
  797. {
  798. 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);
  799. tweenRoot.PingPong = true;
  800. tweenRoot.StartForward();
  801. }
  802. }
  803. public void ChangeClose(List<DragonBones.Slot> slotList, string armatureName, bool setDepth = true)
  804. {
  805. for (int i = 0; i < slotList.Count; i++)
  806. {
  807. slotList[i].childArmature = UnityFactory.factory.BuildArmature(armatureName);
  808. }
  809. if (setDepth)
  810. {
  811. ResetDepth();
  812. }
  813. }
  814. #endregion
  815. }