Player.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032
  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. //ManaNickName.ShowNickNameSettingPanel();
  421. PlayAnim("newAnimation1");
  422. }
  423. public void Save(bool showNavigate)
  424. {
  425. ManaAudio.PlayClip(Clip.BtnClip);
  426. List<CloseUnit> closeUnitList = new List<CloseUnit>();
  427. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Head]]);
  428. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Dress]]);
  429. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Shoe]]);
  430. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[HeadWear]]);
  431. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Top]]);
  432. if (Wing != "Empty")
  433. {
  434. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Wing]]);
  435. }
  436. for (int i = 0; i < closeUnitList.Count; i++)
  437. {
  438. if (!closeUnitList[i].Bought)
  439. {
  440. if (showNavigate)
  441. {
  442. BuyNavigate(closeUnitList);
  443. }
  444. return;
  445. }
  446. }
  447. ManaPlayer.DressData[0] = Head;
  448. ManaPlayer.DressData[1] = Dress;
  449. ManaPlayer.DressData[2] = Shoe;
  450. ManaPlayer.DressData[3] = HeadWear;
  451. ManaPlayer.DressData[4] = Top;
  452. ManaPlayer.DressData[7] = Wing;
  453. }
  454. public void Reset()
  455. {
  456. ManaAudio.PlayClip(Clip.BtnClip);
  457. List<string> dressData = new List<string>(ManaPlayer.DressData);
  458. dressData[5] = Eye;
  459. ManaPlayer.BuildPlayer(dressData);
  460. }
  461. public void Return()
  462. {
  463. bool allSave = true;
  464. bool allBought = true;
  465. List<string> currentDerssData = new List<string>() {Head, Dress, Shoe, HeadWear, Top, Eye, Mouse, Wing};
  466. for (int i = 0; i < currentDerssData.Count; i++)
  467. {
  468. if (!ManaPlayer.CloseIDDic.ContainsKey(currentDerssData[i]))
  469. {
  470. continue;
  471. }
  472. int id = ManaPlayer.CloseIDDic[currentDerssData[i]];
  473. allBought = allBought && ManaPlayer.CloseUnitDic[id].Bought;
  474. allSave = allSave && currentDerssData[i] == ManaPlayer.DressData[i];
  475. }
  476. if (allBought)
  477. {
  478. if (allSave)
  479. {
  480. ExitDressRoom();
  481. }
  482. else
  483. {
  484. Reset();
  485. ExitDressRoom();
  486. }
  487. }
  488. else
  489. {
  490. Bubble.Show
  491. (
  492. null, Language.GetStr("UI", "P_Return"), null, null,
  493. () =>
  494. {
  495. Reset();
  496. ManaReso.Get("K_Bubble").GetTweenGra().AddEventOnetime(EventType.BackwardFinish, () => { ExitDressRoom(); });
  497. }
  498. );
  499. }
  500. }
  501. public void BuyNavigate(List<CloseUnit> closeUnitList)
  502. {
  503. for (int i = 0; i < closeUnitList.Count; i++)
  504. {
  505. if (closeUnitList[i].Bought)
  506. {
  507. closeUnitList.RemoveAt(i--);
  508. }
  509. else
  510. {
  511. closeUnitList[i].BuyBtn.onClick.Invoke();
  512. closeUnitList.RemoveAt(i--);
  513. ManaReso.Get("Pa_Info").GetTweenCG().AddEventOnetime
  514. (
  515. EventType.BackwardFinish,
  516. () =>
  517. {
  518. if (closeUnitList.Count == 0)
  519. {
  520. Save(false);
  521. }
  522. else
  523. {
  524. BuyNavigate(closeUnitList);
  525. }
  526. }
  527. );
  528. return;
  529. }
  530. }
  531. }
  532. public void ExitDressRoom()
  533. {
  534. ManaCenter.SceneSwitchLock = false;
  535. TweenRoot tweenRoot = ManaReso.Get("I_BlackMask").TweenBacCG();
  536. tweenRoot.AddEventOnetime
  537. (
  538. EventType.BackwardFinish,
  539. () =>
  540. {
  541. transform.SetParent(ManaReso.Get("GardenNormal"));
  542. transform.position = ManaReso.Get("PlayerPosTra").position;
  543. transform.localScale = ManaReso.Get("PlayerPosTra").lossyScale;
  544. ManaReso.Get("Garden").TweenForSr();
  545. ManaReso.Get("DressRoom").TweenBacSr();
  546. ManaReso.Get("C_Main").TweenForCG();
  547. ManaReso.Get("P_DressRoom").TweenBacCG();
  548. }
  549. );
  550. tweenRoot = ManaReso.Get("P_DressRoom").GetTweenCG();
  551. tweenRoot.AddEventOnetime
  552. (
  553. EventType.BackwardFinish,
  554. () =>
  555. {
  556. SetAllCollider(true);
  557. InDressRoom = false;
  558. JumpTimer = 0;
  559. PlayAnim("newAnimation");
  560. ChildDic["Shadow"].GetStreamScale().Pause();
  561. ChildDic["Shadow"].GetStreamScale().InOrigin = true;
  562. ChildDic["ShadowParent"].SetActive(false);
  563. ManaReso.Get("B_SignIn0").TweenForCG();
  564. ManaReso.Get("I_BlackMask").TweenForCG();
  565. }
  566. );
  567. }
  568. public void EnterDressRoom()
  569. {
  570. if (ManaCenter.SceneSwitchLock)
  571. {
  572. return;
  573. }
  574. ChildDic["ShadowParent"].SetActive(true);
  575. ManaReso.Get("B_SignIn0").TweenBacCG();
  576. InDressRoom = true;
  577. JumpTime = Mathf.Lerp(0, 10, Random.Range(0.5f, 1f));
  578. ManaCenter.SceneSwitchLock = true;
  579. ManaReso.Get("C_Main").TweenBacCG();
  580. SetAllCollider(false);
  581. TweenRoot tweenRoot = ManaReso.Get("I_BlackMask").TweenBacCG();
  582. tweenRoot.AddEventOnetime
  583. (
  584. EventType.BackwardFinish,
  585. () =>
  586. {
  587. for (int i = 0; i < ManaGarden.PlantList.Count; i++)
  588. {
  589. ManaGarden.PlantList[i].Flower.RetrieveElf();
  590. }
  591. //ChildDic["ShadowParent"].SetActive(true);
  592. transform.SetParent(ManaReso.Get("DressRoom"));
  593. transform.position = ManaReso.Get("DressRoomPos").position;
  594. transform.localScale = ManaReso.Get("DressRoomPos").lossyScale;
  595. ManaReso.Get("Garden").TweenBacSr();
  596. ManaReso.Get("DressRoom").TweenForSr();
  597. ManaReso.Get("P_DressRoom").TweenForCG();
  598. }
  599. );
  600. tweenRoot = ManaReso.Get("P_DressRoom").GetTweenCG();
  601. tweenRoot.AddEventOnetime
  602. (
  603. EventType.ForwardFinish,
  604. () =>
  605. {
  606. ManaReso.Get("I_BlackMask").TweenForCG();
  607. }
  608. );
  609. }
  610. #region 换装
  611. public UnityArmatureComponent Build()
  612. {
  613. if (!ManaPlayer.Complete)
  614. {
  615. UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("stand_ske", Folder.Config));
  616. UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("stand_tex", Folder.Config), "stand_texture");
  617. ManaPlayer.Complete = true;
  618. }
  619. UAC = UnityFactory.factory.BuildArmatureComponent("Armature");
  620. UAC.transform.parent = transform;
  621. UAC.transform.localScale = new Vector3(1, 1, 1);
  622. UAC.transform.localPosition = new Vector3();
  623. UAC.anim.Play("newAnimation");
  624. UAC.AddEventListener(EventObject.START, OnStart);
  625. Eye = "眼睛1";
  626. Top = "上衣1";
  627. Shoe = "鞋子1";
  628. Head = "脑壳1";
  629. Wing = "Empty";
  630. Dress = "裙子1";
  631. Mouse = "嘴巴1";
  632. HeadWear = "头饰品1";
  633. NeckSlot = UAC.armature.GetSlot("脖子");
  634. LeftHandSlot = UAC.armature.GetSlot("左手");
  635. RightHandSlot = UAC.armature.GetSlot("右手");
  636. LeftLegSlot = UAC.armature.GetSlot("左腿");
  637. RightLegSlot = UAC.armature.GetSlot("右腿");
  638. EyeSlot = UAC.armature.GetSlot("眼睛");
  639. TopSlot = UAC.armature.GetSlot("上衣");
  640. HeadSlot = UAC.armature.GetSlot("脑壳");
  641. WingSlot = UAC.armature.GetSlot("翅膀");
  642. DressSlot = UAC.armature.GetSlot("裙子");
  643. MouseSlot = UAC.armature.GetSlot("嘴巴");
  644. LeftShoeSlot = UAC.armature.GetSlot("鞋子左");
  645. RightShoeSlot = UAC.armature.GetSlot("鞋子右");
  646. HeadWearSlot = UAC.armature.GetSlot("头饰品");
  647. ChangeClose(BodyPart.Eye, "眼睛1", false);
  648. ChangeClose(BodyPart.Top, "上衣1", false);
  649. ChangeClose(BodyPart.Shoe, "鞋子1", false);
  650. ChangeClose(BodyPart.Head, "脑壳1", false);
  651. ChangeClose(BodyPart.Dress, "裙子1", false);
  652. ChangeClose(BodyPart.Mouse, "嘴巴1", false);
  653. ChangeClose(BodyPart.Headwear, "头饰品1", false);
  654. return UAC;
  655. }
  656. public UnityArmatureComponent BuildPink()
  657. {
  658. Build();
  659. ChangeClose(BodyPart.Eye, "眼睛3", false);
  660. ChangeClose(BodyPart.Top, "上衣3", false);
  661. ChangeClose(BodyPart.Shoe, "鞋子3", false);
  662. ChangeClose(BodyPart.Head, "脑壳3", false);
  663. ChangeClose(BodyPart.Wing, "Empty", false);
  664. ChangeClose(BodyPart.Dress, "裙子3", false);
  665. ChangeClose(BodyPart.Mouse, "嘴巴3", false);
  666. ChangeClose(BodyPart.Headwear, "头饰品3", false);
  667. ResetDepth();
  668. return UAC;
  669. }
  670. public UnityArmatureComponent BuildBlond()
  671. {
  672. Build();
  673. ChangeClose(BodyPart.Wing, "Empty", false);
  674. ResetDepth();
  675. return UAC;
  676. }
  677. public UnityArmatureComponent BuildBrown()
  678. {
  679. Build();
  680. ChangeClose(BodyPart.Eye, "眼睛2", false);
  681. ChangeClose(BodyPart.Top, "上衣2", false);
  682. ChangeClose(BodyPart.Shoe, "鞋子2", false);
  683. ChangeClose(BodyPart.Head, "脑壳2", false);
  684. ChangeClose(BodyPart.Wing, "Empty", false);
  685. ChangeClose(BodyPart.Dress, "裙子2", false);
  686. ChangeClose(BodyPart.Mouse, "嘴巴2", false);
  687. ChangeClose(BodyPart.Headwear, "头饰品2", false);
  688. ResetDepth();
  689. return UAC;
  690. }
  691. public void ResetDepth()
  692. {
  693. UAC.transform.SetLZ(2.5f);
  694. if (Wing != "Empty")
  695. {
  696. transform.FindChild("Armature/" + Wing).SetLZ(0.003f);
  697. }
  698. transform.FindChild("Armature/" + Eye).SetLZ(-0.001f);
  699. transform.FindChild("Armature/" + Top).SetLZ(-0.003f);
  700. transform.FindChild("Armature/" + Mouse).SetLZ(-0.001f);
  701. transform.FindChild("Armature/" + HeadWear).SetLZ(-0.001f);
  702. Transform tempTra = transform.FindChild("Armature/" + Head);
  703. tempTra.SetLZ(0);
  704. if (tempTra.childCount > 1)
  705. {
  706. tempTra.GetChild(0).SetLZ(0.002f);
  707. tempTra.GetChild(1).SetLZ(0f);
  708. }
  709. tempTra = transform.FindChild("Armature/" + Dress);
  710. tempTra.SetLZ(-0.002f);
  711. if (tempTra.childCount > 1)
  712. {
  713. tempTra.GetChild(0).SetLZ(0.002f);
  714. tempTra.GetChild(1).SetLZ(0f);
  715. }
  716. tempTra = transform.FindChild("Armature/" + Shoe);
  717. tempTra.SetLZ(-0.001f);
  718. transform.FindChild("Armature").GetChild(tempTra.GetSiblingIndex() + 1).SetLZ(-0.001f);
  719. transform.FindChild("Armature/左腿").SetLZ(0);
  720. transform.FindChild("Armature/右腿").SetLZ(0);
  721. transform.FindChild("Armature/脖子").SetLZ(0.001f);
  722. transform.FindChild("Armature/左手").SetLZ(-0.001f);
  723. transform.FindChild("Armature/右手").SetLZ(-0.001f);
  724. }
  725. public void ChangeClose(BodyPart bodyPart, string armatureName, bool setDepth = true)
  726. {
  727. List<DragonBones.Slot> slotList = new List<DragonBones.Slot>();
  728. if (bodyPart == BodyPart.Eye)
  729. {
  730. Eye = armatureName;
  731. slotList.Add(EyeSlot);
  732. }
  733. else if (bodyPart == BodyPart.Top)
  734. {
  735. Top = armatureName;
  736. slotList.Add(TopSlot);
  737. }
  738. else if (bodyPart == BodyPart.Shoe)
  739. {
  740. Shoe = armatureName;
  741. slotList.Add(LeftShoeSlot);
  742. slotList.Add(RightShoeSlot);
  743. }
  744. else if (bodyPart == BodyPart.Head)
  745. {
  746. Head = armatureName;
  747. slotList.Add(HeadSlot);
  748. }
  749. else if (bodyPart == BodyPart.Wing)
  750. {
  751. if (Wing == armatureName)
  752. {
  753. return;
  754. }
  755. else
  756. {
  757. Wing = armatureName;
  758. slotList.Add(WingSlot);
  759. }
  760. }
  761. else if (bodyPart == BodyPart.Dress)
  762. {
  763. Dress = armatureName;
  764. slotList.Add(DressSlot);
  765. }
  766. else if (bodyPart == BodyPart.Mouse)
  767. {
  768. Mouse = armatureName;
  769. slotList.Add(MouseSlot);
  770. }
  771. else if (bodyPart == BodyPart.Headwear)
  772. {
  773. HeadWear = armatureName;
  774. slotList.Add(HeadWearSlot);
  775. }
  776. else if (bodyPart == BodyPart.Leg)
  777. {
  778. slotList.Add(LeftLegSlot);
  779. slotList.Add(RightLegSlot);
  780. }
  781. else if (bodyPart == BodyPart.LeftHand)
  782. {
  783. slotList.Add(LeftHandSlot);
  784. }
  785. else if (bodyPart == BodyPart.RightHand)
  786. {
  787. slotList.Add(RightHandSlot);
  788. }
  789. else if (bodyPart == BodyPart.Neck)
  790. {
  791. slotList.Add(NeckSlot);
  792. }
  793. else
  794. {
  795. throw new Exception();
  796. }
  797. ChangeClose(slotList, armatureName, setDepth);
  798. if (bodyPart == BodyPart.Wing)
  799. {
  800. 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);
  801. tweenRoot.PingPong = true;
  802. tweenRoot.StartForward();
  803. }
  804. }
  805. public void ChangeClose(List<DragonBones.Slot> slotList, string armatureName, bool setDepth = true)
  806. {
  807. for (int i = 0; i < slotList.Count; i++)
  808. {
  809. slotList[i].childArmature = UnityFactory.factory.BuildArmature(armatureName);
  810. }
  811. if (setDepth)
  812. {
  813. ResetDepth();
  814. }
  815. }
  816. #endregion
  817. }