Player.cs 26 KB

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