Player.cs 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124
  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 LeftLongSleeve;
  328. // private string LeftShortSleeve;
  329. // private string RightLongSleeve;
  330. // private string RightShortSleeve;
  331. private string TempClose;
  332. public Armature NeckSlot;
  333. public Armature LeftHandSlot;
  334. public Armature RightHandSlot;
  335. public Armature LeftLegSlot;
  336. public Armature RightLegSlot;
  337. public Armature LeftLongSleeveSlot;
  338. public Armature LeftShortSleeveSlot;
  339. public Armature RightLongSleeveSlot;
  340. public Armature RightShortSleeveSlot;
  341. public Armature EyeArmature;
  342. public Armature TopArmature;
  343. public Armature HeadArmature;
  344. public Armature DressArmature;
  345. public Armature WingArmature;
  346. public Armature MouseArmature;
  347. public Armature LeftShoeArmature;
  348. public Armature RightShoeArmature;
  349. public Armature HeadWearArmature;
  350. public UnityArmatureComponent UAC;
  351. #endregion
  352. #endregion
  353. public override bool RegistImmed()
  354. {
  355. if (base.RegistImmed())
  356. {
  357. return true;
  358. }
  359. enabled = true;
  360. Auxiliary.CompileDic(transform, ChildDic);
  361. Vector3 bigShadowScale = new Vector3(1.820952f, 2.418199f, 1.820952f);
  362. Vector3 smallShadowScale = new Vector3(1.081191f, 1.435807f, 1.081191f);
  363. ChildDic["Shadow"].CreateStreamScale
  364. (
  365. new List<float>() {0, 0, 0},
  366. new List<float>() {0.33f, 0.33f, 0.33f, 0.33f},
  367. new List<VecPair>() {new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale), new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale)},
  368. true,
  369. true,
  370. Curve.EaseOutQuad
  371. );
  372. return false;
  373. }
  374. public void Update()
  375. {
  376. if (InDressRoom)
  377. {
  378. JumpTimer += Time.deltaTime;
  379. if (JumpTimer > JumpTime)
  380. {
  381. if (!AnimLock1 && !AnimLock2)
  382. {
  383. PlayAnim("newAnimation1");
  384. }
  385. AnimLock2 = true;
  386. }
  387. if (JumpTimer > JumpFrequency)
  388. {
  389. AnimLock2 = false;
  390. JumpTime = Mathf.Lerp(0, JumpFrequency, Random.Range(0f, 1f));
  391. JumpTimer = 0;
  392. }
  393. }
  394. }
  395. public void OnStart(string str, EventObject eventObject)
  396. {
  397. if (eventObject.animationState.name == "newAnimation1")
  398. {
  399. ChildDic["Shadow"].StreamReForScale();
  400. AnimLock1 = true;
  401. TempClose = Eye;
  402. ChangeClose(BodyPart.Eye, "眼睛表情1");
  403. }
  404. else if (eventObject.animationState.name == "newAnimation")
  405. {
  406. AnimLock1 = false;
  407. if (TempClose != null)
  408. {
  409. ChangeClose(BodyPart.Eye, TempClose);
  410. }
  411. }
  412. }
  413. public void PlayAnim(string animName)
  414. {
  415. if (AnimLock1)
  416. {
  417. return;
  418. }
  419. UAC.anim.Play(animName);
  420. }
  421. public void SetAllCollider(bool enable)
  422. {
  423. BoxCollider2D[] colliders = GetComponentsInChildren<BoxCollider2D>();
  424. for (int i = 0; i < colliders.Length; i++)
  425. {
  426. colliders[i].enabled = enable;
  427. }
  428. }
  429. public void OnPointerClick(PointerEventData eventData)
  430. {
  431. ManaAudio.PlayClip(Clip.CurrentClip);
  432. //ManaNickName.ShowNickNameSettingPanel();
  433. PlayAnim("newAnimation1");
  434. }
  435. public void Save(bool showNavigate)
  436. {
  437. ManaAudio.PlayClip(Clip.BtnClip);
  438. List<CloseUnit> closeUnitList = new List<CloseUnit>();
  439. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Head]]);
  440. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Dress]]);
  441. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Shoe]]);
  442. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[HeadWear]]);
  443. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Top]]);
  444. if (Wing != "Empty")
  445. {
  446. closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Wing]]);
  447. }
  448. for (int i = 0; i < closeUnitList.Count; i++)
  449. {
  450. if (!closeUnitList[i].Bought)
  451. {
  452. if (showNavigate)
  453. {
  454. BuyNavigate(closeUnitList);
  455. }
  456. return;
  457. }
  458. }
  459. ManaPlayer.DressData[0] = Head;
  460. ManaPlayer.DressData[1] = Dress;
  461. ManaPlayer.DressData[2] = Shoe;
  462. ManaPlayer.DressData[3] = HeadWear;
  463. ManaPlayer.DressData[4] = Top;
  464. ManaPlayer.DressData[7] = Wing;
  465. }
  466. public void Reset()
  467. {
  468. ManaAudio.PlayClip(Clip.BtnClip);
  469. List<string> dressData = new List<string>(ManaPlayer.DressData);
  470. dressData[5] = Eye;
  471. ManaPlayer.BuildPlayer(dressData);
  472. }
  473. public void Return()
  474. {
  475. bool allSave = true;
  476. bool allBought = true;
  477. List<string> currentDerssData = new List<string>() {Head, Dress, Shoe, HeadWear, Top, Eye, Mouse, Wing};
  478. for (int i = 0; i < currentDerssData.Count; i++)
  479. {
  480. if (!ManaPlayer.CloseIDDic.ContainsKey(currentDerssData[i]))
  481. {
  482. continue;
  483. }
  484. int id = ManaPlayer.CloseIDDic[currentDerssData[i]];
  485. allBought = allBought && ManaPlayer.CloseUnitDic[id].Bought;
  486. allSave = allSave && currentDerssData[i] == ManaPlayer.DressData[i];
  487. }
  488. if (allBought)
  489. {
  490. if (allSave)
  491. {
  492. ExitDressRoom();
  493. }
  494. else
  495. {
  496. Reset();
  497. ExitDressRoom();
  498. }
  499. }
  500. else
  501. {
  502. Bubble.Show
  503. (
  504. null, Language.GetStr("UI", "P_Return"), null, null,
  505. () =>
  506. {
  507. Reset();
  508. ManaReso.Get("K_Bubble").GetTweenGra().AddEventOnetime(EventType.BackwardFinish, () => { ExitDressRoom(); });
  509. }
  510. );
  511. }
  512. }
  513. public void BuyNavigate(List<CloseUnit> closeUnitList)
  514. {
  515. for (int i = 0; i < closeUnitList.Count; i++)
  516. {
  517. if (closeUnitList[i].Bought)
  518. {
  519. closeUnitList.RemoveAt(i--);
  520. }
  521. else
  522. {
  523. closeUnitList[i].BuyBtn.onClick.Invoke();
  524. closeUnitList.RemoveAt(i--);
  525. ManaReso.Get("Pa_Info").GetTweenCG().AddEventOnetime
  526. (
  527. EventType.BackwardFinish,
  528. () =>
  529. {
  530. if (closeUnitList.Count == 0)
  531. {
  532. Save(false);
  533. }
  534. else
  535. {
  536. BuyNavigate(closeUnitList);
  537. }
  538. }
  539. );
  540. return;
  541. }
  542. }
  543. }
  544. public void ExitDressRoom()
  545. {
  546. ManaCenter.SceneSwitchLock = false;
  547. TweenRoot tweenRoot = ManaReso.Get("I_BlackMask").TweenBacCG();
  548. tweenRoot.AddEventOnetime
  549. (
  550. EventType.BackwardFinish,
  551. () =>
  552. {
  553. transform.SetParent(ManaReso.Get("GardenNormal"));
  554. transform.position = ManaReso.Get("PlayerPosTra").position;
  555. transform.localScale = ManaReso.Get("PlayerPosTra").lossyScale;
  556. ManaReso.Get("Garden").TweenForSr();
  557. ManaReso.Get("DressRoom").TweenBacSr();
  558. ManaReso.Get("C_Main").TweenForCG();
  559. ManaReso.Get("P_DressRoom").TweenBacCG();
  560. }
  561. );
  562. tweenRoot = ManaReso.Get("P_DressRoom").GetTweenCG();
  563. tweenRoot.AddEventOnetime
  564. (
  565. EventType.BackwardFinish,
  566. () =>
  567. {
  568. SetAllCollider(true);
  569. InDressRoom = false;
  570. JumpTimer = 0;
  571. PlayAnim("newAnimation");
  572. ChildDic["Shadow"].GetStreamScale().Pause();
  573. ChildDic["Shadow"].GetStreamScale().InOrigin = true;
  574. ChildDic["ShadowParent"].SetActive(false);
  575. ManaReso.Get("B_SignIn0").TweenForCG();
  576. ManaReso.Get("I_BlackMask").TweenForCG();
  577. }
  578. );
  579. }
  580. public void EnterDressRoom()
  581. {
  582. if (ManaCenter.SceneSwitchLock)
  583. {
  584. return;
  585. }
  586. ChildDic["ShadowParent"].SetActive(true);
  587. ManaReso.Get("B_SignIn0").TweenBacCG();
  588. InDressRoom = true;
  589. JumpTime = Mathf.Lerp(0, 10, Random.Range(0.5f, 1f));
  590. ManaCenter.SceneSwitchLock = true;
  591. ManaReso.Get("C_Main").TweenBacCG();
  592. SetAllCollider(false);
  593. TweenRoot tweenRoot = ManaReso.Get("I_BlackMask").TweenBacCG();
  594. tweenRoot.AddEventOnetime
  595. (
  596. EventType.BackwardFinish,
  597. () =>
  598. {
  599. for (int i = 0; i < ManaGarden.PlantList.Count; i++)
  600. {
  601. ManaGarden.PlantList[i].Flower.RetrieveElf();
  602. }
  603. //ChildDic["ShadowParent"].SetActive(true);
  604. transform.SetParent(ManaReso.Get("DressRoom"));
  605. transform.position = ManaReso.Get("DressRoomPos").position;
  606. transform.localScale = ManaReso.Get("DressRoomPos").lossyScale;
  607. ManaReso.Get("Garden").TweenBacSr();
  608. ManaReso.Get("DressRoom").TweenForSr();
  609. ManaReso.Get("P_DressRoom").TweenForCG();
  610. }
  611. );
  612. tweenRoot = ManaReso.Get("P_DressRoom").GetTweenCG();
  613. tweenRoot.AddEventOnetime
  614. (
  615. EventType.ForwardFinish,
  616. () =>
  617. {
  618. ManaReso.Get("I_BlackMask").TweenForCG();
  619. }
  620. );
  621. }
  622. #region 换装
  623. public UnityArmatureComponent Build()
  624. {
  625. if (!ManaPlayer.Complete)
  626. {
  627. UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("stand_ske", Folder.Config));
  628. UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("stand_tex", Folder.Config), "stand_texture");
  629. ManaPlayer.Complete = true;
  630. }
  631. UAC = UnityFactory.factory.BuildArmatureComponent("Armature");
  632. UAC.transform.parent = transform;
  633. UAC.transform.localScale = new Vector3(1, 1, 1);
  634. UAC.transform.localPosition = new Vector3();
  635. UAC.anim.Play("newAnimation");
  636. UAC.AddEventListener(EventObject.START, OnStart);
  637. Eye = "眼睛1";
  638. Top = "上衣1";
  639. Shoe = "鞋子1";
  640. Head = "脑壳1";
  641. Wing = "Empty";
  642. Dress = "裙子1";
  643. Mouse = "嘴巴1";
  644. HeadWear = "头饰品1";
  645. NeckSlot = UAC.armature.GetSlot("脖子");
  646. LeftHandSlot = UAC.armature.GetSlot("左手");
  647. RightHandSlot = UAC.armature.GetSlot("右手");
  648. LeftLegSlot = UAC.armature.GetSlot("左腿");
  649. RightLegSlot = UAC.armature.GetSlot("右腿");
  650. LeftLongSleeveSlot = UAC.armature.GetSlot("长袖左9");
  651. LeftShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子左");
  652. RightLongSleeveSlot = UAC.armature.GetSlot("长袖右9");
  653. RightShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子右");
  654. EyeArmature = UAC.armature.GetSlot("眼睛");
  655. TopArmature = UAC.armature.GetSlot("上衣");
  656. HeadArmature = UAC.armature.GetSlot("脑壳");
  657. WingArmature = UAC.armature.GetSlot("翅膀");
  658. DressArmature = UAC.armature.GetSlot("裙子");
  659. MouseArmature = UAC.armature.GetSlot("嘴巴");
  660. LeftShoeArmature = UAC.armature.GetSlot("鞋子左");
  661. RightShoeArmature = UAC.armature.GetSlot("鞋子右");
  662. HeadWearArmature = UAC.armature.GetSlot("头饰品");
  663. ChangeClose(BodyPart.LeftLongSleeve, "Empty", false);
  664. ChangeClose(BodyPart.LeftShortSleeve, "Empty", false);
  665. ChangeClose(BodyPart.RightLongSleeve, "Empty", false);
  666. ChangeClose(BodyPart.RightShortSleeve, "Empty", false);
  667. ChangeClose(BodyPart.Eye, "眼睛1", false);
  668. ChangeClose(BodyPart.Top, "上衣1", false);
  669. ChangeClose(BodyPart.Shoe, "鞋子1", false);
  670. ChangeClose(BodyPart.Head, "脑壳1", false);
  671. ChangeClose(BodyPart.Dress, "裙子1", false);
  672. ChangeClose(BodyPart.Mouse, "嘴巴1", false);
  673. ChangeClose(BodyPart.Headwear, "头饰品1", false);
  674. //Debug.LogError("123");
  675. return UAC;
  676. }
  677. public UnityArmatureComponent BuildPink()
  678. {
  679. Build();
  680. ChangeClose(BodyPart.Eye, "眼睛3", false);
  681. ChangeClose(BodyPart.Top, "上衣3", false);
  682. ChangeClose(BodyPart.Shoe, "鞋子3", false);
  683. ChangeClose(BodyPart.Head, "脑壳3", false);
  684. ChangeClose(BodyPart.Wing, "Empty", false);
  685. ChangeClose(BodyPart.Dress, "裙子3", false);
  686. ChangeClose(BodyPart.Mouse, "嘴巴3", false);
  687. ChangeClose(BodyPart.Headwear, "头饰品3", false);
  688. ResetDepth();
  689. return UAC;
  690. }
  691. public UnityArmatureComponent BuildBlond()
  692. {
  693. Build();
  694. ChangeClose(BodyPart.Wing, "Empty", false);
  695. ResetDepth();
  696. return UAC;
  697. }
  698. public UnityArmatureComponent BuildBrown()
  699. {
  700. Build();
  701. ChangeClose(BodyPart.Eye, "眼睛2", false);
  702. ChangeClose(BodyPart.Top, "上衣2", false);
  703. ChangeClose(BodyPart.Shoe, "鞋子2", false);
  704. ChangeClose(BodyPart.Head, "脑壳2", false);
  705. ChangeClose(BodyPart.Wing, "Empty", false);
  706. ChangeClose(BodyPart.Dress, "裙子2", false);
  707. ChangeClose(BodyPart.Mouse, "嘴巴2", false);
  708. ChangeClose(BodyPart.Headwear, "头饰品2", false);
  709. ResetDepth();
  710. return UAC;
  711. }
  712. public void ResetDepth()
  713. {
  714. UAC.transform.SetLZ(2.5f);
  715. // WingSlot.UnityTransform.SetLZ(0.003f);
  716. //
  717. // EyeSlot.UnityTransform.SetLZ(-0.001f);
  718. // TopSlot.UnityTransform.SetLZ(-0.003f);
  719. // MouseSlot.UnityTransform.SetLZ(-0.001f);
  720. // HeadWearSlot.UnityTransform.SetLZ(-0.001f);
  721. //
  722. // HeadSlot.UnityTransform.SetLZ(0);
  723. // if (HeadSlot.UnityTransform.childCount > 1)
  724. // {
  725. // HeadSlot.UnityTransform.GetChild(0).SetLZ(0.002f);
  726. // HeadSlot.UnityTransform.GetChild(1).SetLZ(0f);
  727. // }
  728. //
  729. // DressSlot.UnityTransform.SetLZ(-0.002f);
  730. // if (DressSlot.UnityTransform.childCount > 1)
  731. // {
  732. // DressSlot.UnityTransform.GetChild(0).SetLZ(0.002f);
  733. // DressSlot.UnityTransform.GetChild(1).SetLZ(0f);
  734. // }
  735. //
  736. // LeftShoeSlot.UnityTransform.SetLZ(-0.001f);
  737. // RightShoeSlot.UnityTransform.SetLZ(-0.001f);
  738. //
  739. // LeftLegSlot.UnityTransform.SetLZ(0);
  740. // RightLegSlot.UnityTransform.SetLZ(0);
  741. // NeckSlot.UnityTransform.SetLZ(0.001f);
  742. // LeftHandSlot.UnityTransform.SetLZ(-0.001f);
  743. // RightHandSlot.UnityTransform.SetLZ(-0.001f);
  744. //
  745. // LeftLongSleeveSlot.UnityTransform.SetLZ(-0.0015f);
  746. // LeftShortSleeveSlot.UnityTransform.SetLZ(-0.0015f);
  747. // RightLongSleeveSlot.UnityTransform.SetLZ(-0.0015f);
  748. // RightShortSleeveSlot.UnityTransform.SetLZ(-0.0015f);
  749. // Debug.Log (LeftLongSleeveSlot.armature.UnityTransform.name);
  750. // Debug.Log (LeftShortSleeveSlot.armature.UnityTransform.name);
  751. // Debug.Log (RightLongSleeveSlot.armature.UnityTransform.name);
  752. // Debug.Log (RightShortSleeveSlot.armature.UnityTransform.name);
  753. //
  754. // UAC.transform.SetLZ(2.5f);
  755. //
  756. // if (Wing != "Empty")
  757. // {
  758. // transform.FindChild("Armature/" + Wing).SetLZ(0.003f);
  759. // }
  760. //
  761. // transform.FindChild("Armature/" + Eye).SetLZ(-0.001f);
  762. // transform.FindChild("Armature/" + Top).SetLZ(-0.003f);
  763. // transform.FindChild("Armature/" + Mouse).SetLZ(-0.001f);
  764. // transform.FindChild("Armature/" + HeadWear).SetLZ(-0.001f);
  765. //
  766. // Transform tempTra = transform.FindChild("Armature/" + Head);
  767. //
  768. // tempTra.SetLZ(0);
  769. // if (tempTra.childCount > 1)
  770. // {
  771. // tempTra.GetChild(0).SetLZ(0.002f);
  772. // tempTra.GetChild(1).SetLZ(0f);
  773. // }
  774. //
  775. //
  776. // tempTra = transform.FindChild("Armature/" + Dress);
  777. //
  778. // tempTra.SetLZ(-0.002f);
  779. // if (tempTra.childCount > 1)
  780. // {
  781. // tempTra.GetChild(0).SetLZ(0.002f);
  782. // tempTra.GetChild(1).SetLZ(0f);
  783. // }
  784. //
  785. //
  786. // tempTra = transform.FindChild("Armature/" + Shoe);
  787. // tempTra.SetLZ(-0.001f);
  788. //
  789. // transform.FindChild("Armature").GetChild(tempTra.GetSiblingIndex() + 1).SetLZ(-0.001f);
  790. //
  791. //
  792. // transform.FindChild("Armature/左腿").SetLZ(0);
  793. // transform.FindChild("Armature/右腿").SetLZ(0);
  794. // transform.FindChild("Armature/脖子").SetLZ(0.001f);
  795. // transform.FindChild("Armature/左手").SetLZ(-0.001f);
  796. // transform.FindChild("Armature/右手").SetLZ(-0.001f);
  797. }
  798. public void ChangeClose(BodyPart bodyPart, string armatureName, bool setDepth = true)
  799. {
  800. // Debug.Log (bodyPart);
  801. List<DragonBones.Slot> slotList = new List<DragonBones.Slot>();
  802. if (bodyPart == BodyPart.Eye)
  803. {
  804. Eye = armatureName;
  805. slotList.Add(EyeArmature);
  806. }
  807. else if (bodyPart == BodyPart.Top)
  808. {
  809. Top = armatureName;
  810. slotList.Add(TopArmature);
  811. }
  812. else if (bodyPart == BodyPart.Shoe)
  813. {
  814. Shoe = armatureName;
  815. slotList.Add(LeftShoeArmature);
  816. slotList.Add(RightShoeArmature);
  817. }
  818. else if (bodyPart == BodyPart.Head)
  819. {
  820. Head = armatureName;
  821. slotList.Add(HeadArmature);
  822. }
  823. else if (bodyPart == BodyPart.Wing)
  824. {
  825. if (Wing == armatureName)
  826. {
  827. return;
  828. }
  829. else
  830. {
  831. Wing = armatureName;
  832. slotList.Add(WingArmature);
  833. }
  834. }
  835. else if (bodyPart == BodyPart.Dress)
  836. {
  837. Dress = armatureName;
  838. slotList.Add(DressArmature);
  839. }
  840. else if (bodyPart == BodyPart.Mouse)
  841. {
  842. Mouse = armatureName;
  843. slotList.Add(MouseArmature);
  844. }
  845. else if (bodyPart == BodyPart.Headwear)
  846. {
  847. HeadWear = armatureName;
  848. slotList.Add(HeadWearArmature);
  849. }
  850. else if (bodyPart == BodyPart.Leg)
  851. {
  852. slotList.Add(LeftLegSlot);
  853. slotList.Add(RightLegSlot);
  854. }
  855. else if (bodyPart == BodyPart.LeftHand)
  856. {
  857. slotList.Add(LeftHandSlot);
  858. }
  859. else if (bodyPart == BodyPart.RightHand)
  860. {
  861. slotList.Add(RightHandSlot);
  862. }
  863. else if (bodyPart == BodyPart.Neck)
  864. {
  865. slotList.Add(NeckSlot);
  866. }
  867. else if (bodyPart == BodyPart.LeftLongSleeve)
  868. {
  869. // LeftLongSleeve = armatureName;
  870. slotList.Add(LeftLongSleeveSlot);
  871. }
  872. else if (bodyPart == BodyPart.LeftShortSleeve)
  873. {
  874. // LeftShortSleeve = armatureName;
  875. slotList.Add(LeftShortSleeveSlot);
  876. }
  877. else if (bodyPart == BodyPart.RightLongSleeve)
  878. {
  879. // RightLongSleeve = armatureName;
  880. slotList.Add(RightLongSleeveSlot);
  881. }
  882. else if (bodyPart == BodyPart.RightShortSleeve)
  883. {
  884. // RightShortSleeve = armatureName;
  885. slotList.Add(RightShortSleeveSlot);
  886. }
  887. else
  888. {
  889. throw new Exception();
  890. }
  891. ChangeClose(slotList, armatureName, setDepth);
  892. if (bodyPart == BodyPart.Wing)
  893. {
  894. 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);
  895. tweenRoot.PingPong = true;
  896. tweenRoot.StartForward();
  897. }
  898. }
  899. public void ChangeClose(List<DragonBones.Slot> slotList, string armatureName, bool setDepth = true)
  900. {
  901. for (int i = 0; i < slotList.Count; i++)
  902. {
  903. slotList[i].childArmature = UnityFactory.factory.BuildArmature(armatureName, null, null, null, true);
  904. }
  905. if (setDepth)
  906. {
  907. ResetDepth();
  908. }
  909. }
  910. #endregion
  911. }