Player.cs 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575
  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 Animation = DragonBones.Animation;
  11. using Slot = DragonBones.Slot;
  12. using Random = UnityEngine.Random;
  13. using Transform = UnityEngine.Transform;
  14. public enum BodyPart
  15. {
  16. Leg = 0,
  17. LeftHand = 1,
  18. RightHand = 2,
  19. LeftLongSleeve = 3,
  20. LeftShortSleeve = 4,
  21. RightLongSleeve = 5,
  22. RightShortSleeve = 6,
  23. Neck = 7,
  24. Eye = 8,
  25. Top = 9,
  26. Shoe = 10,
  27. Head = 11,
  28. Wing = 12,
  29. Dress = 13,
  30. Mouse = 14,
  31. Headwear = 15,
  32. }
  33. public class ExchangeInfo
  34. {
  35. public float Rate;
  36. public double Value;
  37. public Current Current;
  38. public static void GetExchangeValue(ExchangeInfo info, StaticsManager.ConsumeModule consumeModule)
  39. {
  40. if (info.Current == Current.Coin)
  41. {
  42. Manager.AddCoin(info.Value, StaticsManager.ItemID.获得金币, consumeModule);
  43. }
  44. else if (info.Current == Current.Diamond)
  45. {
  46. Manager.AddDiamond(info.Value, StaticsManager.ItemID.获得钻石, consumeModule);
  47. }
  48. }
  49. public static ExchangeInfo GetExchangeInfo(Current current, double amt, float rate)
  50. {
  51. ExchangeInfo info = new ExchangeInfo();
  52. info.Rate = rate;
  53. info.Value = amt * rate;
  54. info.Current = current;
  55. return info;
  56. }
  57. }
  58. public class CloseItem
  59. {
  60. public enum CloseType
  61. {
  62. Top,
  63. Hair,
  64. Wing,
  65. Dress,
  66. Decarator,
  67. Shoe,
  68. }
  69. #region Var
  70. public string Name
  71. {
  72. get { return LabelUtility.CombineLanguageLabel(LanguageLabel.DressRoom, FullID); }
  73. }
  74. public static string IDPrefix = "Armature";
  75. public string FullID
  76. {
  77. get { return IDPrefix + id; }
  78. }
  79. public int id;
  80. public int Index;
  81. public int BuyLevel;
  82. public int PixelSize;
  83. public bool Possess;
  84. public string ArmatureName;
  85. public string[] ExtraArmatureNames;
  86. public BodyPart[] ExtraBodyParts;
  87. public float SpriteAlpha;
  88. public float IconOffset;
  89. public Text BuyBtnLab;
  90. public Sprite[] Sprites;
  91. public Image Icon1;
  92. public Image Icon2;
  93. public Image Icon3;
  94. public Button BuyBtn;
  95. public Button DressBtn;
  96. public Vector2 IconOffset1;
  97. public Vector2 IconOffset2;
  98. public BodyPart BodyPart;
  99. public Transform Transform;
  100. public CloseType Type;
  101. public bool Ignore;
  102. public double BuyAmt;
  103. public double BuyAdvanceAmt;
  104. public Current BuyCurrent;
  105. public Current BuyAdvanceCurrent;
  106. public Dictionary<string, Transform> ChildDic = new Dictionary<string, Transform>();
  107. #endregion
  108. public CloseItem(XmlAttributeCollection attribute)
  109. {
  110. Ignore = Auxiliary.StringToBool(attribute[19].Value, false);
  111. id = Auxiliary.StringToInt(attribute[0].Value, -1);
  112. BodyPart = BodyPartParse(attribute[4].Value);
  113. ArmatureName = attribute[16].Value;
  114. PlayerManager.CloseIDDic.Add(ArmatureName, id);
  115. PlayerManager.CloseItemDic.Add(id, this);
  116. if (Ignore)
  117. {
  118. return;
  119. }
  120. Type = TypeParse(attribute[2].Value);
  121. Index = Auxiliary.StringToInt(attribute[3].Value, -1);
  122. BuyLevel = Auxiliary.StringToInt(attribute[5].Value, 0);
  123. BuyCurrent = Auxiliary.CurrentParse(attribute[6].Value);
  124. BuyAmt = Auxiliary.StringToDouble(attribute[7].Value, 0);
  125. BuyAdvanceCurrent = Auxiliary.CurrentParse(attribute[8].Value);
  126. BuyAdvanceAmt = Auxiliary.StringToDouble(attribute[9].Value, 0);
  127. PixelSize = Auxiliary.StringToInt(attribute[10].Value, 100);
  128. IconOffset = Auxiliary.StringToFloat(attribute[11].Value, 0);
  129. IconOffset1 = Auxiliary.StringToVector(',', attribute[12].Value, new Vector3());
  130. IconOffset2 = Auxiliary.StringToVector(',', attribute[13].Value, new Vector3());
  131. Sprites = SpriteParse(attribute[14].Value);
  132. SpriteAlpha = Auxiliary.StringToFloat(attribute[15].Value, 1);
  133. ExtraBodyParts = BodyPartParses(attribute[17].Value);
  134. ExtraArmatureNames = Auxiliary.StringToStrings(',', attribute[18].Value, new List<string>()).ToArray();
  135. CreateItem();
  136. }
  137. protected void CreateItem()
  138. {
  139. Transform = ResourceManager.Get(ResourceLabel.CloseItem, Folder.UI, false, ResourceManager.Get(ObjectLabel.Canvas), false);
  140. if (Type == CloseType.Top)
  141. {
  142. Transform.SetParent(ResourceManager.Get(ObjectLabel.Pb_TopGrid));
  143. }
  144. else if (Type == CloseType.Hair)
  145. {
  146. Transform.SetParent(ResourceManager.Get(ObjectLabel.Pa_HairGrid));
  147. }
  148. else if (Type == CloseType.Dress)
  149. {
  150. Transform.SetParent(ResourceManager.Get(ObjectLabel.Pc_DressGrid));
  151. }
  152. else if (Type == CloseType.Wing)
  153. {
  154. Transform.SetParent(ResourceManager.Get(ObjectLabel.Pe_WingGrid));
  155. }
  156. else if (Type == CloseType.Decarator)
  157. {
  158. Transform.SetParent(ResourceManager.Get(ObjectLabel.Pd_DecaratorGrid));
  159. }
  160. else if (Type == CloseType.Shoe)
  161. {
  162. Transform.SetParent(ResourceManager.Get(ObjectLabel.Pf_ShoeGrid));
  163. }
  164. else
  165. {
  166. throw new Exception();
  167. }
  168. Transform.SetSiblingIndex(Index);
  169. Auxiliary.CompileDic(Transform, ChildDic);
  170. Icon1 = ChildDic["Icon1"].GetComponent<Image>();
  171. Icon2 = ChildDic["Icon2"].GetComponent<Image>();
  172. Icon3 = ChildDic["Icon3"].GetComponent<Image>();
  173. DressBtn = ChildDic["CloseItem"].GetComponent<Button>();
  174. BuyBtn = ChildDic["BuyBtn"].GetComponent<Button>();
  175. BuyBtnLab = ChildDic["BuyBtnLab"].GetComponent<Text>();
  176. BuyBtnLab.GetComponent<TextPlus>().SetY = true;
  177. float newSize = PixelSize / Sprites[0].rect.width;
  178. SetUpUI(newSize, new Vector2(), Icon1, Icon2, Icon3);
  179. if (BuyCurrent != Current.Free)
  180. {
  181. BuyBtnLab.text = Auxiliary.ImageParse(BuyCurrent) + Auxiliary.ShrinkNumberStr(BuyAmt);
  182. }
  183. if (BuyLevel > Manager.Level)
  184. {
  185. BuyBtn.interactable = false;
  186. BuyBtn.image.material = Lib.GrayMat;
  187. }
  188. BuyBtn.onClick.AddListener
  189. (
  190. () =>
  191. {
  192. AudioManager.PlayClip(Clip.BtnClip);
  193. ResourceManager.Get(ObjectLabel.Pa_Info).TweenForCG();
  194. SetUpUI(newSize, new Vector2(0, 22), ResourceManager.Get<Image>(ObjectLabel.Pa_Icon1), ResourceManager.Get<Image>(ObjectLabel.Pa_Icon3), ResourceManager.Get<Image>(ObjectLabel.Pa_Icon2));
  195. ResourceManager.SetText(ObjectLabel.Pa_Lab, Name);
  196. ResourceManager.SetText(ObjectLabel.Pa_BtnLab, Language.GetStr(LanguageLabel.UI__Pa_BtnLab) + Auxiliary.ImageParse(BuyCurrent) + BuyAmt);
  197. ResourceManager.SetButtonEvent
  198. (
  199. ObjectLabel.Pa_Btn,
  200. OnBuy
  201. );
  202. }
  203. );
  204. DressBtn.onClick.AddListener
  205. (
  206. () =>
  207. {
  208. AudioManager.PlayClip(Clip.BtnClip);
  209. if (BuyLevel > Manager.Level)
  210. {
  211. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__P_Unlock));
  212. return;
  213. }
  214. ChangeDress(PlayerManager.Player);
  215. }
  216. );
  217. }
  218. protected Sprite[] SpriteParse(string str)
  219. {
  220. string[] spriteNames = str.Split(',');
  221. Sprite[] sprites = new Sprite[spriteNames.Length];
  222. for (int i = 0; i < spriteNames.Length; i++)
  223. {
  224. if (!PlayerManager.CloseSpriteDic.ContainsKey(spriteNames[i]))
  225. {
  226. Debug.Log(spriteNames[i]);
  227. }
  228. sprites[i] = PlayerManager.CloseSpriteDic[spriteNames[i]];
  229. }
  230. return sprites;
  231. }
  232. protected BodyPart BodyPartParse(string str)
  233. {
  234. int type = Auxiliary.StringToInt(str, -1);
  235. if (type == 1)
  236. {
  237. return BodyPart.Head;
  238. }
  239. else if (type == 2)
  240. {
  241. return BodyPart.Dress;
  242. }
  243. else if (type == 3)
  244. {
  245. return BodyPart.Shoe;
  246. }
  247. else if (type == 4)
  248. {
  249. return BodyPart.Headwear;
  250. }
  251. else if (type == 5)
  252. {
  253. return BodyPart.Top;
  254. }
  255. else if (type == 6)
  256. {
  257. return BodyPart.Wing;
  258. }
  259. else if (type == 7)
  260. {
  261. return BodyPart.LeftLongSleeve;
  262. }
  263. else if (type == 8)
  264. {
  265. return BodyPart.RightLongSleeve;
  266. }
  267. else if (type == 9)
  268. {
  269. return BodyPart.LeftShortSleeve;
  270. }
  271. else if (type == 10)
  272. {
  273. return BodyPart.RightShortSleeve;
  274. }
  275. else if (type == 11)
  276. {
  277. return BodyPart.Eye;
  278. }
  279. else if (type == 12)
  280. {
  281. return BodyPart.Mouse;
  282. }
  283. else
  284. {
  285. throw new Exception();
  286. }
  287. }
  288. protected BodyPart[] BodyPartParses(string str)
  289. {
  290. List<string> typeIDs = Auxiliary.StringToStrings(',', str, new List<string>());
  291. BodyPart[] bodyParts = new BodyPart[typeIDs.Count];
  292. for (int i = 0; i < typeIDs.Count; i++)
  293. {
  294. bodyParts[i] = BodyPartParse(typeIDs[i]);
  295. }
  296. return bodyParts;
  297. }
  298. protected CloseType TypeParse(string str)
  299. {
  300. int type = Auxiliary.StringToInt(str, -1);
  301. if (type == 1)
  302. {
  303. return CloseType.Hair;
  304. }
  305. else if (type == 2)
  306. {
  307. return CloseType.Top;
  308. }
  309. else if (type == 3)
  310. {
  311. return CloseType.Dress;
  312. }
  313. else if (type == 4)
  314. {
  315. return CloseType.Decarator;
  316. }
  317. else if (type == 5)
  318. {
  319. return CloseType.Wing;
  320. }
  321. else if (type == 6)
  322. {
  323. return CloseType.Shoe;
  324. }
  325. else
  326. {
  327. throw new Exception();
  328. }
  329. }
  330. public void SetUpUI(float newSize, Vector2 offset, Image icon1, Image icon2, Image icon3)
  331. {
  332. icon1.SetActive(false);
  333. icon3.SetActive(false);
  334. icon2.SetActive(true);
  335. icon2.sprite = Sprites[0];
  336. icon2.Resize(true, new Vector2(newSize, newSize));
  337. icon2.SetAlpha(SpriteAlpha);
  338. icon2.transform.localPosition = offset + new Vector2(0, IconOffset);
  339. if (Sprites.Length >= 2)
  340. {
  341. icon1.SetActive(true);
  342. icon1.sprite = Sprites[1];
  343. icon1.Resize(true, new Vector2(newSize, newSize));
  344. icon1.SetAlpha(SpriteAlpha);
  345. icon1.transform.localPosition = IconOffset1 * newSize + offset + new Vector2(0, IconOffset);
  346. }
  347. if (Sprites.Length >= 3)
  348. {
  349. icon3.SetActive(true);
  350. icon3.sprite = Sprites[2];
  351. icon3.Resize(true, new Vector2(newSize, newSize));
  352. icon3.SetAlpha(SpriteAlpha);
  353. icon3.transform.localPosition = IconOffset2 * newSize + offset + new Vector2(0, IconOffset);
  354. }
  355. }
  356. public void Unlock()
  357. {
  358. if (Ignore)
  359. {
  360. return;
  361. }
  362. Possess = true;
  363. BuyBtn.interactable = false;
  364. BuyBtn.image.material = Lib.GrayMat;
  365. BuyBtnLab.text = Language.GetStr(LanguageLabel.UI__P_BtnLab2);
  366. Manager.CloseAmt++;
  367. }
  368. public void OnBuy()
  369. {
  370. Manager.Pay
  371. (
  372. "",
  373. BuyAmt,
  374. BuyCurrent,
  375. () =>
  376. {
  377. OnBuySucceed();
  378. ResourceManager.Get(ObjectLabel.Pa_Info).TweenBacCG();
  379. ChangeDress(PlayerManager.Player);
  380. SaveDressData();
  381. },
  382. StaticsManager.ItemID.解锁服装,
  383. StaticsManager.ConsumeModule.Shop,
  384. true,
  385. false,
  386. () =>
  387. {
  388. PlayerManager.Player.Reset();
  389. TweenRoot tweenRoot = ResourceManager.Get(ObjectLabel.Pa_Info).TweenBacCG();
  390. tweenRoot.AddEventOnetime
  391. (
  392. EventType.BackwardFinish,
  393. () =>
  394. {
  395. PlayerManager.Player.Return();
  396. }
  397. );
  398. ResourceManager.Get(ObjectLabel.B_SignIn0).GetTweenCG().AddEventOnetime
  399. (
  400. EventType.ForwardFinish,
  401. () =>
  402. {
  403. ResourceManager.Get(ObjectLabel.F_Manage0).TweenForVec();
  404. }
  405. );
  406. }
  407. );
  408. }
  409. public void OnBuySucceed()
  410. {
  411. Unlock();
  412. AudioManager.PlayClip(Clip.CurrentClip);
  413. PlayerManager.BoughtCloseList.UniqueAdd(id);
  414. HttpManager.Save();
  415. }
  416. public void ChangeDress(Player player)
  417. {
  418. player.ChangeClose(BodyPart, ArmatureName);
  419. if (Ignore)
  420. {
  421. return;
  422. }
  423. if (ExtraBodyParts.Length > 0)
  424. {
  425. player.ChangeClose(BodyPart.LeftLongSleeve, "Empty");
  426. player.ChangeClose(BodyPart.LeftShortSleeve, "Empty");
  427. player.ChangeClose(BodyPart.RightLongSleeve, "Empty");
  428. player.ChangeClose(BodyPart.RightShortSleeve, "Empty");
  429. }
  430. for (int i = 0; i < ExtraArmatureNames.Length; i++)
  431. {
  432. player.ChangeClose(ExtraBodyParts[i], ExtraArmatureNames[i]);
  433. }
  434. }
  435. public void SaveDressData() //仅在购买完成时调用
  436. {
  437. SaveDressData(BodyPart);
  438. if (BodyPart == BodyPart.Top)
  439. {
  440. PlayerManager.DressData[8] = "Empty";
  441. PlayerManager.DressData[9] = "Empty";
  442. PlayerManager.DressData[10] = "Empty";
  443. PlayerManager.DressData[11] = "Empty";
  444. foreach (var bodyPart in ExtraBodyParts)
  445. {
  446. SaveDressData(bodyPart);
  447. }
  448. }
  449. }
  450. public void SaveDressData(BodyPart bodyPart) //仅在购买完成时调用
  451. {
  452. if (bodyPart == BodyPart.LeftLongSleeve)
  453. {
  454. PlayerManager.DressData[8] = PlayerManager.Player.LeftLongSleeve;
  455. }
  456. else if (bodyPart == BodyPart.LeftShortSleeve)
  457. {
  458. PlayerManager.DressData[9] = PlayerManager.Player.LeftShortSleeve;
  459. }
  460. else if (bodyPart == BodyPart.RightLongSleeve)
  461. {
  462. PlayerManager.DressData[10] = PlayerManager.Player.RightLongSleeve;
  463. }
  464. else if (bodyPart == BodyPart.RightShortSleeve)
  465. {
  466. PlayerManager.DressData[11] = PlayerManager.Player.RightShortSleeve;
  467. }
  468. else if (bodyPart == BodyPart.Top)
  469. {
  470. PlayerManager.DressData[4] = PlayerManager.Player.Top;
  471. }
  472. else if (bodyPart == BodyPart.Shoe)
  473. {
  474. PlayerManager.DressData[2] = PlayerManager.Player.Shoe;
  475. }
  476. else if (bodyPart == BodyPart.Head)
  477. {
  478. PlayerManager.DressData[0] = PlayerManager.Player.Head;
  479. }
  480. else if (bodyPart == BodyPart.Wing)
  481. {
  482. PlayerManager.DressData[7] = PlayerManager.Player.Wing;
  483. }
  484. else if (bodyPart == BodyPart.Dress)
  485. {
  486. PlayerManager.DressData[1] = PlayerManager.Player.Dress;
  487. }
  488. else if (bodyPart == BodyPart.Headwear)
  489. {
  490. PlayerManager.DressData[3] = PlayerManager.Player.HeadWear;
  491. }
  492. else
  493. {
  494. throw new Exception();
  495. }
  496. }
  497. public void OnLevelChange()
  498. {
  499. if (Ignore)
  500. {
  501. return;
  502. }
  503. if (Possess)
  504. {
  505. return;
  506. }
  507. if (BuyLevel < Manager.Level)
  508. {
  509. BuyBtn.interactable = true;
  510. BuyBtn.image.material = null;
  511. }
  512. }
  513. public ExchangeInfo GetExchangeValue(float rate, StaticsManager.ConsumeModule consumeModule)
  514. {
  515. ExchangeInfo info = ExchangeInfo.GetExchangeInfo(BuyCurrent, BuyAmt, rate);
  516. ExchangeInfo.GetExchangeValue(info, consumeModule);
  517. return info;
  518. }
  519. }
  520. public enum PlayerDirection
  521. {
  522. Left = 0,
  523. Right = 1,
  524. }
  525. public class Player : Regist , IPointerClickHandler
  526. {
  527. #region 变量
  528. public static string IdleAnimationName = "newAnimation";
  529. public static string JumpAnimationName = "newAnimation1";
  530. public static string WalkAnimationName = "newAnimation2";
  531. public static string RunAnimationName = "newAnimation3";
  532. public static bool InDressRoom;
  533. public static float JumpFrequency;
  534. public PlayerDirection PlayerDirection
  535. {
  536. get { return playerDirection; }
  537. set
  538. {
  539. playerDirection = value;
  540. Flip(playerDirection);
  541. }
  542. }
  543. private PlayerDirection playerDirection = PlayerDirection.Left;
  544. public bool AnimLock1;
  545. public bool AnimLock2;
  546. public float JumpTime;
  547. public float JumpTimer;
  548. public MeshFilter ExpressionMeshFilter;
  549. public Dictionary<string, Transform> ChildDic = new Dictionary<string, Transform>();
  550. public static Dictionary<string, Vector3> LeftExpressionPositionDictionary = new Dictionary<string, Vector3>
  551. {
  552. {"郁闷", new Vector3(0, -0.22f, -0.00001f)},
  553. {"汗颜", new Vector3(0.35f, 0.91f, -0.00001f)},
  554. {"惊讶", new Vector3(0.09f, -0.07f, -0.00001f)},
  555. {"开心", new Vector3(0.1f, -0.22f, -0.00001f)},
  556. {"哭", new Vector3(0.07f, -0.64f, -0.00001f)},
  557. {"期待", new Vector3(0.04f, -0.20f, -0.00001f)},
  558. {"色咪咪", new Vector3(0.03f, -0.09f, -0.00001f)},
  559. {"委屈", new Vector3(0f, -0.27f, -0.00001f)},
  560. };
  561. public static Dictionary<string, Vector3> RightExpressionPositionDictionary = new Dictionary<string, Vector3>
  562. {
  563. {"郁闷", new Vector3(0, -0.22f, -0.00001f)},
  564. {"汗颜", new Vector3(-0.22f, 0.91f, -0.00001f)},
  565. {"惊讶", new Vector3(-0.09f, -0.07f, -0.00001f)},
  566. {"开心", new Vector3(-0.1f, -0.22f, -0.00001f)},
  567. {"哭", new Vector3(-0.07f, -0.64f, -0.00001f)},
  568. {"期待", new Vector3(-0.04f, -0.20f, -0.00001f)},
  569. {"色咪咪", new Vector3(-0.03f, -0.09f, -0.00001f)},
  570. {"委屈", new Vector3(0f, -0.27f, -0.00001f)},
  571. };
  572. #region 换装
  573. public Transform Shadow;
  574. private Transform Pivot
  575. {
  576. get
  577. {
  578. if (pivot == null)
  579. {
  580. pivot = UAC.transform.FindChild("Pivot");
  581. }
  582. return pivot;
  583. }
  584. }
  585. private Transform pivot;
  586. public string Eye;
  587. public string Top;
  588. public string Shoe;
  589. public string Head;
  590. public string Wing;
  591. public string Dress;
  592. public string Mouse;
  593. public string HeadWear;
  594. public string LeftLongSleeve;
  595. public string LeftShortSleeve;
  596. public string RightLongSleeve;
  597. public string RightShortSleeve;
  598. private string TempClose;
  599. public DragonBones.Slot NeckSlot;
  600. public DragonBones.Slot LeftHandSlot;
  601. public DragonBones.Slot RightHandSlot;
  602. public DragonBones.Slot LeftLegSlot;
  603. public DragonBones.Slot RightLegSlot;
  604. public DragonBones.Slot LeftShortSleeveSlot;
  605. public DragonBones.Slot RightShortSleeveSlot;
  606. public DragonBones.Slot EyeSlot;
  607. public DragonBones.Slot TopSlot;
  608. public DragonBones.Slot HeadSlot;
  609. public DragonBones.Slot DressSlot;
  610. public DragonBones.Slot WingSlot;
  611. public DragonBones.Slot MouseSlot;
  612. public DragonBones.Slot LeftShoeSlot;
  613. public DragonBones.Slot RightShoeSlot;
  614. public DragonBones.Slot HeadWearSlot;
  615. public UnityArmatureComponent UAC;
  616. public UnityArmatureComponent LeftLongSleeveUAC;
  617. public UnityArmatureComponent RightLongSleeveUAC;
  618. #endregion
  619. #endregion
  620. public override bool InitAtOnce()
  621. {
  622. if (base.InitAtOnce())
  623. {
  624. return true;
  625. }
  626. enabled = true;
  627. Auxiliary.CompileDic(transform, ChildDic);
  628. Vector3 bigShadowScale = new Vector3(1.820952f, 2.418199f, 1.820952f);
  629. Vector3 smallShadowScale = new Vector3(1.081191f, 1.435807f, 1.081191f);
  630. Shadow = ChildDic["Shadow"];
  631. Shadow.CreateStreamScale
  632. (
  633. new List<float>() {0, 0, 0},
  634. new List<float>() {0.33f, 0.33f, 0.33f, 0.33f},
  635. new List<VecPair>() {new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale), new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale)},
  636. true,
  637. true,
  638. Curve.EaseOutQuad
  639. );
  640. MeshFilter meshFilter = Shadow.GetComponent<MeshFilter>();
  641. meshFilter.mesh = SpriteUtility.CreateMesh(ResourceManager.LoadSprite(ResourceLabel.FlowerShadow, Folder.Scene));
  642. meshFilter.mesh.SetUVs(1, Enumerable.Repeat(new Vector2(0, 1), meshFilter.mesh.vertices.Length).ToList());
  643. Shadow.GetComponent<MeshRenderer>().sharedMaterial = UnityFactory.Materials[0];
  644. ExpressionMeshFilter = ChildDic["ExpressionMeshFilter"].GetComponent<MeshFilter>();
  645. ExpressionMeshFilter.GetComponent<MeshRenderer>().sharedMaterial = UnityFactory.Materials[0];
  646. return false;
  647. }
  648. public void Update()
  649. {
  650. if (InDressRoom)
  651. {
  652. JumpTimer += Time.deltaTime;
  653. if (JumpTimer > JumpTime)
  654. {
  655. if (!AnimLock1 && !AnimLock2)
  656. {
  657. PlayAnim(JumpAnimationName);
  658. }
  659. AnimLock2 = true;
  660. }
  661. if (JumpTimer > JumpFrequency)
  662. {
  663. AnimLock2 = false;
  664. JumpTime = Mathf.Lerp(0, JumpFrequency, Random.Range(0f, 1f));
  665. JumpTimer = 0;
  666. }
  667. }
  668. //if (GardenSmartFoxManager.GardenSmartFox.PlazaRoomManager.InPlazaRoom)
  669. //{
  670. // MoveThread();
  671. //}
  672. }
  673. public void OnStart(string str, EventObject eventObject)
  674. {
  675. if (eventObject.animationState.name == JumpAnimationName)
  676. {
  677. Shadow.StreamReForScale();
  678. AnimLock1 = true;
  679. TempClose = Eye;
  680. ChangeClose(BodyPart.Eye, "眼睛表情1");
  681. }
  682. else if (eventObject.animationState.name == IdleAnimationName)
  683. {
  684. AnimLock1 = false;
  685. if (TempClose != null)
  686. {
  687. ChangeClose(BodyPart.Eye, TempClose);
  688. }
  689. }
  690. }
  691. public string CurrentAnimationName;
  692. public void PlayAnim(string animName)
  693. {
  694. if (AnimLock1)
  695. {
  696. return;
  697. }
  698. if (UAC.anim.lastAnimationName == animName)
  699. {
  700. return;
  701. }
  702. if (SFSManager.GardenSmartFox.PlazaRoomController.JoinedPlazaRoom)
  703. {
  704. CurrentAnimationName = animName;
  705. }
  706. UAC.anim.FadeIn(animName, GetFadeInTime(UAC.anim.lastAnimationName, animName));
  707. }
  708. public float GetFadeInTime(string lastAnimation, string targetAnimation)
  709. {
  710. if (lastAnimation == JumpAnimationName && targetAnimation == IdleAnimationName)
  711. return -1f;
  712. else
  713. return 0.1f;
  714. //throw new Exception();
  715. }
  716. public void SetAllCollider(bool enable)
  717. {
  718. BoxCollider2D[] colliders = GetComponentsInChildren<BoxCollider2D>();
  719. for (int i = 0; i < colliders.Length; i++)
  720. {
  721. colliders[i].enabled = enable;
  722. }
  723. }
  724. public void OnPointerClick(PointerEventData eventData)
  725. {
  726. AudioManager.PlayClip(Clip.CurrentClip);
  727. PlayAnim(JumpAnimationName);
  728. }
  729. public void ResetExpression()
  730. {
  731. ExpressionMeshFilter.SetActive(false);
  732. EyeSlot.UnityTransform.GetChild(0).SetActive(true);
  733. MouseSlot.UnityTransform.GetChild(0).SetActive(true);
  734. }
  735. private string ExpressionName;
  736. private Coroutine ResetExpressionCoroutine;
  737. public void ChangeExpression(string expressionName, float duration)
  738. {
  739. ExpressionName = expressionName;
  740. ExpressionMeshFilter.sharedMesh = SpriteUtility.CreateMesh(ResourceManager.LoadSprite(expressionName, Folder.Scene));
  741. ExpressionMeshFilter.mesh.SetUVs(1, Enumerable.Repeat(new Vector2(0, 1), ExpressionMeshFilter.mesh.vertices.Length).ToList());
  742. ExpressionMeshFilter.transform.parent = EyeSlot.UnityTransform;
  743. ExpressionMeshFilter.SetActive(true);
  744. EyeSlot.UnityTransform.GetChild(0).SetActive(false);
  745. MouseSlot.UnityTransform.GetChild(0).SetActive(false);
  746. FlipExpression(expressionName, PlayerDirection);
  747. if (ResetExpressionCoroutine != null)
  748. Auxiliary.Instance.StopCoroutine(ResetExpressionCoroutine);
  749. ResetExpressionCoroutine = Auxiliary.Instance.DelayCall
  750. (
  751. () =>
  752. {
  753. ResetExpression();
  754. },
  755. duration
  756. );
  757. }
  758. public void Flip(PlayerDirection direction)
  759. {
  760. FlipExpression(ExpressionName, direction);
  761. if (direction == PlayerDirection.Left)
  762. {
  763. UAC.armature.flipX = false;
  764. playerDirection = PlayerDirection.Left;
  765. }
  766. else if (direction == PlayerDirection.Right)
  767. {
  768. UAC.armature.flipX = true;
  769. playerDirection = PlayerDirection.Right;
  770. }
  771. else
  772. {
  773. throw new Exception();
  774. }
  775. DelayCall.Call(1, () => Shadow.SetX(Pivot.position.x));
  776. }
  777. public void FlipExpression(string expressionName, PlayerDirection direction)
  778. {
  779. if (string.IsNullOrEmpty(ExpressionName))
  780. {
  781. return;
  782. }
  783. if (direction == PlayerDirection.Left)
  784. {
  785. ExpressionMeshFilter.transform.eulerAngles = new Vector3();
  786. ExpressionMeshFilter.transform.localPosition = LeftExpressionPositionDictionary[ExpressionName];
  787. }
  788. else if (direction == PlayerDirection.Right)
  789. {
  790. UAC.armature.flipX = true;
  791. ExpressionMeshFilter.transform.eulerAngles = new Vector3(0, 180, 0);
  792. ExpressionMeshFilter.transform.localPosition = RightExpressionPositionDictionary[ExpressionName];
  793. playerDirection = PlayerDirection.Right;
  794. }
  795. else
  796. {
  797. throw new Exception();
  798. }
  799. }
  800. public void Save(bool showNavigate)
  801. {
  802. AudioManager.PlayClip(Clip.BtnClip);
  803. List<CloseItem> closeUnitList = new List<CloseItem>();
  804. closeUnitList.Add(PlayerManager.CloseItemDic[PlayerManager.CloseIDDic[Head]]);
  805. closeUnitList.Add(PlayerManager.CloseItemDic[PlayerManager.CloseIDDic[Dress]]);
  806. closeUnitList.Add(PlayerManager.CloseItemDic[PlayerManager.CloseIDDic[Shoe]]);
  807. closeUnitList.Add(PlayerManager.CloseItemDic[PlayerManager.CloseIDDic[HeadWear]]);
  808. closeUnitList.Add(PlayerManager.CloseItemDic[PlayerManager.CloseIDDic[Top]]);
  809. if (Wing != "Empty")
  810. {
  811. closeUnitList.Add(PlayerManager.CloseItemDic[PlayerManager.CloseIDDic[Wing]]);
  812. }
  813. for (int i = 0; i < closeUnitList.Count; i++)
  814. {
  815. if (!closeUnitList[i].Possess)
  816. {
  817. if (showNavigate)
  818. {
  819. BuyNavigate(closeUnitList);
  820. }
  821. return;
  822. }
  823. }
  824. PlayerManager.DressData[0] = Head;
  825. PlayerManager.DressData[1] = Dress;
  826. PlayerManager.DressData[2] = Shoe;
  827. PlayerManager.DressData[3] = HeadWear;
  828. PlayerManager.DressData[4] = Top;
  829. PlayerManager.DressData[7] = Wing;
  830. PlayerManager.DressData[8] = LeftLongSleeve;
  831. PlayerManager.DressData[9] = LeftShortSleeve;
  832. PlayerManager.DressData[10] = RightLongSleeve;
  833. PlayerManager.DressData[11] = RightShortSleeve;
  834. }
  835. public void Reset()
  836. {
  837. AudioManager.PlayClip(Clip.BtnClip);
  838. List<string> dressData = new List<string>(PlayerManager.DressData);
  839. dressData[5] = Eye;
  840. PlayerManager.BuildPlayer(dressData);
  841. }
  842. public void Return()
  843. {
  844. bool allSave = true;
  845. bool allBought = true;
  846. List<string> currentDerssData = new List<string>() {Head, Dress, Shoe, HeadWear, Top, Wing};
  847. for (int i = 0; i < currentDerssData.Count; i++)
  848. {
  849. if (!PlayerManager.CloseIDDic.ContainsKey(currentDerssData[i]))
  850. {
  851. continue;
  852. }
  853. int id = PlayerManager.CloseIDDic[currentDerssData[i]];
  854. allBought = allBought && PlayerManager.CloseItemDic[id].Possess;
  855. //Debug.Log(ManaPlayer.CloseUnitDic[id].Name + " " + ManaPlayer.CloseUnitDic[id].Bought);
  856. allSave = allSave && currentDerssData[i] == PlayerManager.DressData[i];
  857. }
  858. if (allBought)
  859. {
  860. if (allSave)
  861. {
  862. ExitDressRoom();
  863. }
  864. else
  865. {
  866. Reset();
  867. ExitDressRoom();
  868. }
  869. }
  870. else
  871. {
  872. Bubble.Show
  873. (
  874. null, Language.GetStr(LanguageLabel.UI__P_Return), null, null,
  875. () =>
  876. {
  877. Reset();
  878. ResourceManager.Get(ObjectLabel.K_Bubble).GetTweenGra().AddEventOnetime(EventType.BackwardFinish, () => { ExitDressRoom(); });
  879. }
  880. );
  881. }
  882. }
  883. public void BuyNavigate(List<CloseItem> closeUnitList)
  884. {
  885. for (int i = 0; i < closeUnitList.Count; i++)
  886. {
  887. if (closeUnitList[i].Possess)
  888. {
  889. closeUnitList.RemoveAt(i--);
  890. }
  891. else
  892. {
  893. closeUnitList[i].BuyBtn.onClick.Invoke();
  894. closeUnitList.RemoveAt(i--);
  895. ResourceManager.Get(ObjectLabel.Pa_Info).GetTweenCG().AddEventOnetime
  896. (
  897. EventType.BackwardFinish,
  898. () =>
  899. {
  900. if (closeUnitList.Count == 0)
  901. {
  902. Save(false);
  903. }
  904. else
  905. {
  906. BuyNavigate(closeUnitList);
  907. }
  908. }
  909. );
  910. return;
  911. }
  912. }
  913. }
  914. public void ExitDressRoom()
  915. {
  916. Manager.SceneSwitchLock = false;
  917. TweenRoot tweenRoot = ResourceManager.Get(ObjectLabel.I_BlackMask).TweenBacCG();
  918. tweenRoot.AddEventOnetime
  919. (
  920. EventType.BackwardFinish,
  921. () =>
  922. {
  923. transform.SetParent(ResourceManager.Get("GardenNormal"));
  924. transform.position = ResourceManager.Get("PlayerPosTra").position;
  925. transform.localScale = ResourceManager.Get("PlayerPosTra").lossyScale;
  926. ResourceManager.Get(ResourceLabel.Garden).TweenForSr();
  927. ResourceManager.Get("DressRoom").TweenBacSr();
  928. ResourceManager.Get(ObjectLabel.C_Main).TweenForCG();
  929. ResourceManager.Get(ObjectLabel.P_DressRoom).TweenBacCG();
  930. }
  931. );
  932. tweenRoot = ResourceManager.Get(ObjectLabel.P_DressRoom).GetTweenCG();
  933. tweenRoot.AddEventOnetime
  934. (
  935. EventType.BackwardFinish,
  936. () =>
  937. {
  938. SetAllCollider(true);
  939. InDressRoom = false;
  940. JumpTimer = 0;
  941. PlayAnim(IdleAnimationName);
  942. DeactiveShadow();
  943. ResourceManager.Get(ObjectLabel.B_SignIn0).TweenForCG();
  944. ResourceManager.Get(ObjectLabel.I_BlackMask).TweenForCG();
  945. }
  946. );
  947. }
  948. public void EnterDressRoom()
  949. {
  950. if (Manager.SceneSwitchLock)
  951. {
  952. return;
  953. }
  954. ResourceManager.Get(ObjectLabel.B_SignIn0).TweenBacCG();
  955. InDressRoom = true;
  956. JumpTime = Mathf.Lerp(0, 10, Random.Range(0.5f, 1f));
  957. Manager.SceneSwitchLock = true;
  958. ResourceManager.Get(ObjectLabel.C_Main).TweenBacCG();
  959. SetAllCollider(false);
  960. TweenRoot tweenRoot = ResourceManager.Get(ObjectLabel.I_BlackMask).TweenBacCG();
  961. tweenRoot.AddEventOnetime
  962. (
  963. EventType.BackwardFinish,
  964. () =>
  965. {
  966. GardenManager.RetrieveAllElf();
  967. IAPManager.RetrieveADChest();
  968. ActiveShadow();
  969. transform.SetParent(ResourceManager.Get("DressRoom"));
  970. transform.position = ResourceManager.Get("DressRoomPos").position;
  971. transform.localScale = ResourceManager.Get("DressRoomPos").lossyScale;
  972. ResourceManager.Get(ResourceLabel.Garden).TweenBacSr();
  973. ResourceManager.Get("DressRoom").TweenForSr();
  974. ResourceManager.Get(ObjectLabel.P_DressRoom).TweenForCG();
  975. }
  976. );
  977. tweenRoot = ResourceManager.Get(ObjectLabel.P_DressRoom).GetTweenCG();
  978. tweenRoot.AddEventOnetime
  979. (
  980. EventType.ForwardFinish,
  981. () =>
  982. {
  983. ResourceManager.Get(ObjectLabel.I_BlackMask).TweenForCG();
  984. }
  985. );
  986. }
  987. public void ActiveShadow()
  988. {
  989. ChildDic["ShadowParent"].SetActive(true);
  990. ChildDic["ShadowParent"].SetLZ(3);
  991. }
  992. public void DeactiveShadow()
  993. {
  994. Shadow.GetStreamScale().Pause();
  995. Shadow.GetStreamScale().InOrigin = true;
  996. ChildDic["ShadowParent"].SetActive(false);
  997. }
  998. #region 换装
  999. public void CorrectPivot()
  1000. {
  1001. List<Transform> children = new List<Transform>();
  1002. while (transform.childCount > 0)
  1003. {
  1004. children.Add(transform.GetChild(0));
  1005. children.Back(0).parent = null;
  1006. }
  1007. Vector3 offset = Pivot.position - transform.position;
  1008. children[0].position += offset;
  1009. children[1].position += offset;
  1010. transform.position += offset;
  1011. foreach (var collider in GetComponents<BoxCollider2D>())
  1012. {
  1013. collider.offset -= new Vector2(offset.x, offset.y);
  1014. }
  1015. for (int i = 0; i < children.Count; i++)
  1016. {
  1017. children[i].parent = transform;
  1018. }
  1019. }
  1020. public UnityArmatureComponent Build()
  1021. {
  1022. if (!PlayerManager.Complete)
  1023. {
  1024. UnityFactory.factory.LoadDragonBonesData(ResourceManager.Load<TextAsset>(ResourceLabel.StandSke, Folder.Config));
  1025. UnityFactory.factory.LoadTextureAtlasData(ResourceManager.Load<TextAsset>(ResourceLabel.StandTex, Folder.Config), ResourceLabel.StandTexture);
  1026. PlayerManager.Complete = true;
  1027. }
  1028. UAC = UnityFactory.factory.BuildArmatureComponent("Armature");
  1029. UAC.transform.parent = transform;
  1030. UAC.transform.localScale = new Vector3(1, 1, 1);
  1031. UAC.transform.localPosition = new Vector3();
  1032. UAC.anim.Play(IdleAnimationName);
  1033. UAC.AddEventListener(EventObject.START, OnStart);
  1034. Eye = "眼睛1";
  1035. Top = "上衣1";
  1036. Shoe = "鞋子1";
  1037. Head = "脑壳1";
  1038. Wing = "Empty";
  1039. Dress = "裙子1";
  1040. Mouse = "嘴巴1";
  1041. HeadWear = "头饰品1";
  1042. NeckSlot = UAC.armature.GetSlot("脖子");
  1043. LeftHandSlot = UAC.armature.GetSlot("左手");
  1044. RightHandSlot = UAC.armature.GetSlot("右手");
  1045. LeftLegSlot = UAC.armature.GetSlot("左腿");
  1046. RightLegSlot = UAC.armature.GetSlot("右腿");
  1047. LeftLongSleeveUAC = UAC.transform.FindChild("长袖9左 (长袖9左)").GetComponent<UnityArmatureComponent>();
  1048. RightLongSleeveUAC = UAC.transform.FindChild("长袖9右 (长袖9右)").GetComponent<UnityArmatureComponent>();
  1049. LeftShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子左");
  1050. RightShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子右");
  1051. EyeSlot = UAC.armature.GetSlot("眼睛");
  1052. TopSlot = UAC.armature.GetSlot("上衣");
  1053. HeadSlot = UAC.armature.GetSlot("脑壳");
  1054. WingSlot = UAC.armature.GetSlot("翅膀");
  1055. DressSlot = UAC.armature.GetSlot("裙子");
  1056. MouseSlot = UAC.armature.GetSlot("嘴巴");
  1057. LeftShoeSlot = UAC.armature.GetSlot("鞋子左");
  1058. RightShoeSlot = UAC.armature.GetSlot("鞋子右");
  1059. HeadWearSlot = UAC.armature.GetSlot("头饰品");
  1060. ChangeClose(BodyPart.Eye, "眼睛1", false);
  1061. ChangeClose(BodyPart.Top, "上衣1", false);
  1062. ChangeClose(BodyPart.Shoe, "鞋子1", false);
  1063. ChangeClose(BodyPart.Head, "脑壳1", false);
  1064. ChangeClose(BodyPart.Dress, "裙子1", false);
  1065. ChangeClose(BodyPart.Mouse, "嘴巴1", false);
  1066. ChangeClose(BodyPart.Headwear, "头饰品1", false);
  1067. ChangeClose(BodyPart.LeftLongSleeve, "Empty", false);
  1068. ChangeClose(BodyPart.RightLongSleeve, "Empty", false);
  1069. ChangeClose(BodyPart.LeftShortSleeve, "短袖2左", false);
  1070. ChangeClose(BodyPart.RightShortSleeve, "短袖2右", false);
  1071. CorrectPivot();
  1072. return UAC;
  1073. }
  1074. public UnityArmatureComponent BuildPink()
  1075. {
  1076. Build();
  1077. ChangeClose(BodyPart.Eye, "眼睛3", false);
  1078. ChangeClose(BodyPart.Top, "上衣3", false);
  1079. ChangeClose(BodyPart.Shoe, "鞋子3", false);
  1080. ChangeClose(BodyPart.Head, "脑壳3", false);
  1081. ChangeClose(BodyPart.Wing, "Empty", false);
  1082. ChangeClose(BodyPart.Dress, "裙子3", false);
  1083. ChangeClose(BodyPart.Mouse, "嘴巴3", false);
  1084. ChangeClose(BodyPart.Headwear, "头饰品3", false);
  1085. ResetDepth();
  1086. return UAC;
  1087. }
  1088. public UnityArmatureComponent BuildBlond()
  1089. {
  1090. Build();
  1091. ChangeClose(BodyPart.Wing, "Empty", false);
  1092. ResetDepth();
  1093. return UAC;
  1094. }
  1095. public UnityArmatureComponent BuildBrown()
  1096. {
  1097. Build();
  1098. ChangeClose(BodyPart.Eye, "眼睛2", false);
  1099. ChangeClose(BodyPart.Top, "上衣2", false);
  1100. ChangeClose(BodyPart.Shoe, "鞋子2", false);
  1101. ChangeClose(BodyPart.Head, "脑壳2", false);
  1102. ChangeClose(BodyPart.Wing, "Empty", false);
  1103. ChangeClose(BodyPart.Dress, "裙子2", false);
  1104. ChangeClose(BodyPart.Mouse, "嘴巴2", false);
  1105. ChangeClose(BodyPart.Headwear, "头饰品2", false);
  1106. ResetDepth();
  1107. return UAC;
  1108. }
  1109. public void ResetDepth()
  1110. {
  1111. UAC.transform.SetLZ(2.5f);
  1112. WingSlot.UnityTransform.SetLZ(0);
  1113. EyeSlot.UnityTransform.SetLZ(0);
  1114. TopSlot.UnityTransform.SetLZ(0);
  1115. MouseSlot.UnityTransform.SetLZ(0);
  1116. HeadWearSlot.UnityTransform.SetLZ(0);
  1117. LeftShoeSlot.UnityTransform.SetLZ(0);
  1118. RightShoeSlot.UnityTransform.SetLZ(0);
  1119. LeftLegSlot.UnityTransform.SetLZ(0);
  1120. RightLegSlot.UnityTransform.SetLZ(0);
  1121. NeckSlot.UnityTransform.SetLZ(0);
  1122. LeftHandSlot.UnityTransform.SetLZ(0);
  1123. RightHandSlot.UnityTransform.SetLZ(0);
  1124. LeftShortSleeveSlot.UnityTransform.SetLZ(0);
  1125. RightShortSleeveSlot.UnityTransform.SetLZ(0);
  1126. WingSlot.SetLZ(0.00003f);
  1127. EyeSlot.SetLZ(-0.00001f);
  1128. TopSlot.SetLZ(-0.00003f);
  1129. MouseSlot.SetLZ(-0.00001f);
  1130. HeadWearSlot.SetLZ(-0.00001f);
  1131. HeadSlot.UnityTransform.SetLZ(0);
  1132. if (HeadSlot.UnityTransform.childCount > 1)
  1133. {
  1134. HeadSlot.UnityTransform.GetChild(0).SetLZ(0.00002f);
  1135. HeadSlot.UnityTransform.GetChild(1).SetLZ(0f);
  1136. }
  1137. DressSlot.UnityTransform.SetLZ(-0.00002f);
  1138. if (DressSlot.UnityTransform.childCount > 1)
  1139. {
  1140. DressSlot.UnityTransform.GetChild(0).SetLZ(0.00002f);
  1141. DressSlot.UnityTransform.GetChild(1).SetLZ(0f);
  1142. }
  1143. LeftShoeSlot.SetLZ(-0.00001f);
  1144. RightShoeSlot.SetLZ(-0.00001f);
  1145. LeftLegSlot.SetLZ(0);
  1146. RightLegSlot.SetLZ(0);
  1147. NeckSlot.SetLZ(0.00001f);
  1148. LeftHandSlot.SetLZ(-0.00001f);
  1149. RightHandSlot.SetLZ(-0.00001f);
  1150. LeftShortSleeveSlot.SetLZ(-0.000015f);
  1151. RightShortSleeveSlot.SetLZ(-0.000015f);
  1152. LeftLongSleeveUAC.transform.SetLZ(-0.000015f);
  1153. RightLongSleeveUAC.transform.SetLZ(-0.000015f);
  1154. }
  1155. public void ChangeClose(BodyPart bodyPart, string armatureName, bool setDepth = true)
  1156. {
  1157. // Debug.Log (bodyPart + " " + armatureName);
  1158. List<DragonBones.Slot> slotList = new List<DragonBones.Slot>();
  1159. if (bodyPart == BodyPart.Eye)
  1160. {
  1161. Eye = armatureName;
  1162. slotList.Add(EyeSlot);
  1163. }
  1164. else if (bodyPart == BodyPart.Top)
  1165. {
  1166. Top = armatureName;
  1167. slotList.Add(TopSlot);
  1168. }
  1169. else if (bodyPart == BodyPart.Shoe)
  1170. {
  1171. Shoe = armatureName;
  1172. slotList.Add(LeftShoeSlot);
  1173. slotList.Add(RightShoeSlot);
  1174. }
  1175. else if (bodyPart == BodyPart.Head)
  1176. {
  1177. Head = armatureName;
  1178. slotList.Add(HeadSlot);
  1179. }
  1180. else if (bodyPart == BodyPart.Wing)
  1181. {
  1182. if (Wing == armatureName)
  1183. {
  1184. return;
  1185. }
  1186. else
  1187. {
  1188. Wing = armatureName;
  1189. slotList.Add(WingSlot);
  1190. }
  1191. }
  1192. else if (bodyPart == BodyPart.Dress)
  1193. {
  1194. Dress = armatureName;
  1195. slotList.Add(DressSlot);
  1196. }
  1197. else if (bodyPart == BodyPart.Mouse)
  1198. {
  1199. Mouse = armatureName;
  1200. slotList.Add(MouseSlot);
  1201. }
  1202. else if (bodyPart == BodyPart.Headwear)
  1203. {
  1204. HeadWear = armatureName;
  1205. slotList.Add(HeadWearSlot);
  1206. }
  1207. else if (bodyPart == BodyPart.Leg)
  1208. {
  1209. slotList.Add(LeftLegSlot);
  1210. slotList.Add(RightLegSlot);
  1211. }
  1212. else if (bodyPart == BodyPart.LeftHand)
  1213. {
  1214. slotList.Add(LeftHandSlot);
  1215. }
  1216. else if (bodyPart == BodyPart.RightHand)
  1217. {
  1218. slotList.Add(RightHandSlot);
  1219. }
  1220. else if (bodyPart == BodyPart.Neck)
  1221. {
  1222. slotList.Add(NeckSlot);
  1223. }
  1224. else if (bodyPart == BodyPart.LeftLongSleeve)
  1225. {
  1226. LeftLongSleeve = armatureName;
  1227. ChangeClose(LeftLongSleeveUAC, armatureName);
  1228. return;
  1229. }
  1230. else if (bodyPart == BodyPart.LeftShortSleeve)
  1231. {
  1232. LeftShortSleeve = armatureName;
  1233. slotList.Add(LeftShortSleeveSlot);
  1234. }
  1235. else if (bodyPart == BodyPart.RightLongSleeve)
  1236. {
  1237. RightLongSleeve = armatureName;
  1238. ChangeClose(RightLongSleeveUAC, armatureName);
  1239. return;
  1240. }
  1241. else if (bodyPart == BodyPart.RightShortSleeve)
  1242. {
  1243. RightShortSleeve = armatureName;
  1244. slotList.Add(RightShortSleeveSlot);
  1245. }
  1246. else
  1247. {
  1248. throw new Exception();
  1249. }
  1250. ChangeClose(slotList, armatureName, setDepth);
  1251. if (bodyPart == BodyPart.Wing)
  1252. {
  1253. 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);
  1254. tweenRoot.PingPong = true;
  1255. tweenRoot.StartForward();
  1256. }
  1257. }
  1258. public void ChangeClose(List<DragonBones.Slot> slotList, string armatureName, bool setDepth = true)
  1259. {
  1260. for (int i = 0; i < slotList.Count; i++)
  1261. {
  1262. slotList[i].childArmature = UnityFactory.factory.BuildArmature(armatureName, null, null, null, true);
  1263. slotList[i].UnityTransform = slotList[i].childArmature.UnityTransform.parent;
  1264. }
  1265. if (setDepth)
  1266. {
  1267. ResetDepth();
  1268. }
  1269. }
  1270. public void ChangeClose(UnityArmatureComponent uac, string armatureName, bool setDepth = true)
  1271. {
  1272. if (armatureName == "Empty")
  1273. {
  1274. uac.SetActive(false);
  1275. }
  1276. else
  1277. {
  1278. uac.SetActive(true);
  1279. }
  1280. if (setDepth)
  1281. {
  1282. ResetDepth();
  1283. }
  1284. }
  1285. #endregion
  1286. }