Player.cs 28 KB

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