Player.cs 26 KB

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