Player.cs 35 KB

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