Player.cs 42 KB

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