Player.cs 43 KB

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