Player.cs 45 KB

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