Player.cs 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601
  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(LabelUtility.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(ObjectLabel.Canvas), false);
  162. if (Type == CloseType.Top)
  163. {
  164. Transform.SetParent(ResourceManager.Get(ObjectLabel.Pb_TopGrid));
  165. }
  166. else if (Type == CloseType.Hair)
  167. {
  168. Transform.SetParent(ResourceManager.Get(ObjectLabel.Pa_HairGrid));
  169. }
  170. else if (Type == CloseType.Dress)
  171. {
  172. Transform.SetParent(ResourceManager.Get(ObjectLabel.Pc_DressGrid));
  173. }
  174. else if (Type == CloseType.Wing)
  175. {
  176. Transform.SetParent(ResourceManager.Get(ObjectLabel.Pe_WingGrid));
  177. }
  178. else if (Type == CloseType.Decarator)
  179. {
  180. Transform.SetParent(ResourceManager.Get(ObjectLabel.Pd_DecaratorGrid));
  181. }
  182. else if (Type == CloseType.Shoe)
  183. {
  184. Transform.SetParent(ResourceManager.Get(ObjectLabel.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(ObjectLabel.Pa_Info).TweenForCG();
  216. SetupUI(newSize, new Vector2(0, 22), ResourceManager.Get<Image>(ObjectLabel.Pa_Icon1), ResourceManager.Get<Image>(ObjectLabel.Pa_Icon3), ResourceManager.Get<Image>(ObjectLabel.Pa_Icon2));
  217. ResourceManager.SetText(ObjectLabel.Pa_Lab, Name);
  218. ResourceManager.SetText(ObjectLabel.Pa_BtnLab, Language.GetStr(LanguageLabel.UI__Pa_BtnLab) + Auxiliary.ImageParse(BuyCurrent) + BuyCost);
  219. ResourceManager.SetButtonEvent
  220. (
  221. ObjectLabel.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(ObjectLabel.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(ObjectLabel.Pa_Info).TweenBacCG();
  412. tweenRoot.AddEventOnetime
  413. (
  414. EventType.BackwardFinish,
  415. () =>
  416. {
  417. PlayerManager.Player.LeaveDressroom();
  418. }
  419. );
  420. ResourceManager.Get(ObjectLabel.B_SignIn0).GetTweenCG().AddEventOnetime
  421. (
  422. EventType.ForwardFinish,
  423. () =>
  424. {
  425. ResourceManager.Get(ObjectLabel.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. }
  857. public void ResetDressDatas()
  858. {
  859. AudioManager.PlayClip(AudioLabel.ClickButton);
  860. List<string> dressData = new List<string>(PlayerManager.DressDatas);
  861. dressData[5] = Eye;
  862. PlayerManager.BuildPlayer(dressData);
  863. }
  864. public void BuyDressNavigate(List<CloseItem> closeUnitList)
  865. {
  866. for (int i = 0; i < closeUnitList.Count; i++)
  867. {
  868. if (closeUnitList[i].IsBought)
  869. {
  870. closeUnitList.RemoveAt(i--);
  871. }
  872. else
  873. {
  874. closeUnitList[i].BuyBtn.onClick.Invoke();
  875. closeUnitList.RemoveAt(i--);
  876. ResourceManager.Get(ObjectLabel.Pa_Info).GetTweenCG().AddEventOnetime
  877. (
  878. EventType.BackwardFinish,
  879. () =>
  880. {
  881. if (closeUnitList.Count == 0)
  882. {
  883. SaveDressDatas(false);
  884. }
  885. else
  886. {
  887. BuyDressNavigate(closeUnitList);
  888. }
  889. }
  890. );
  891. return;
  892. }
  893. }
  894. }
  895. public void LeaveDressroom()
  896. {
  897. bool allSave = true;
  898. bool allBought = true;
  899. List<string> currentDerssData = new List<string>() { Head, Dress, Shoe, HeadWear, Top, Wing };
  900. for (int i = 0; i < currentDerssData.Count; i++)
  901. {
  902. if (!PlayerManager.CloseIDDictionary.ContainsKey(currentDerssData[i]))
  903. {
  904. continue;
  905. }
  906. int id = PlayerManager.CloseIDDictionary[currentDerssData[i]];
  907. allBought = allBought && PlayerManager.CloseItemDictionary[id].IsBought;
  908. //Debug.Log(ManaPlayer.CloseUnitDic[id].Name + " " + ManaPlayer.CloseUnitDic[id].Bought);
  909. allSave = allSave && currentDerssData[i] == PlayerManager.DressDatas[i];
  910. }
  911. if (allBought)
  912. {
  913. if (allSave)
  914. {
  915. ExitDressRoom();
  916. }
  917. else
  918. {
  919. ResetDressDatas();
  920. ExitDressRoom();
  921. }
  922. }
  923. else
  924. {
  925. Bubble.Show
  926. (
  927. null, Language.GetStr(LanguageLabel.UI__P_Return), null, null,
  928. () =>
  929. {
  930. ResetDressDatas();
  931. ResourceManager.Get(ObjectLabel.K_Bubble).GetTweenGra().AddEventOnetime(EventType.BackwardFinish, () => { ExitDressRoom(); });
  932. }
  933. );
  934. }
  935. }
  936. public void ExitDressRoom()
  937. {
  938. Manager.SceneSwitchFlag = false;
  939. TweenRoot tweenRoot = ResourceManager.Get(ObjectLabel.I_BlackMask).TweenBacCG();
  940. tweenRoot.AddEventOnetime
  941. (
  942. EventType.BackwardFinish,
  943. () =>
  944. {
  945. transform.SetParent(ResourceManager.Get(GardenLabel.GardenPivot));
  946. transform.position = ResourceManager.Get(GardenLabel.GardenPlayerPos).position;
  947. transform.localScale = ResourceManager.Get(GardenLabel.GardenPlayerPos).lossyScale;
  948. ResourceManager.Get(ResourceLabel.Garden).TweenForSr();
  949. ResourceManager.Get(DressroomLabel.DressRoom).TweenBacSr();
  950. ResourceManager.Get(ObjectLabel.C_Main).TweenForCG();
  951. ResourceManager.Get(ObjectLabel.P_DressRoom).TweenBacCG();
  952. }
  953. );
  954. tweenRoot = ResourceManager.Get(ObjectLabel.P_DressRoom).GetTweenCG();
  955. tweenRoot.AddEventOnetime
  956. (
  957. EventType.BackwardFinish,
  958. () =>
  959. {
  960. SetAllCollider(true);
  961. InDressRoom = false;
  962. JumpTimer = 0;
  963. PlayAnim(IdleAnimationName);
  964. DeactiveShadow();
  965. ResourceManager.Get(ObjectLabel.B_SignIn0).TweenForCG();
  966. ResourceManager.Get(ObjectLabel.I_BlackMask).TweenForCG();
  967. }
  968. );
  969. }
  970. public void EnterDressRoom()
  971. {
  972. if (Manager.SceneSwitchFlag)
  973. {
  974. return;
  975. }
  976. ResourceManager.Get(ObjectLabel.B_SignIn0).TweenBacCG();
  977. InDressRoom = true;
  978. JumpTime = Mathf.Lerp(0, 10, Random.Range(0.5f, 1f));
  979. Manager.SceneSwitchFlag = true;
  980. ResourceManager.Get(ObjectLabel.C_Main).TweenBacCG();
  981. SetAllCollider(false);
  982. TweenRoot tweenRoot = ResourceManager.Get(ObjectLabel.I_BlackMask).TweenBacCG();
  983. tweenRoot.AddEventOnetime
  984. (
  985. EventType.BackwardFinish,
  986. () =>
  987. {
  988. GardenManager.RetrieveAllElf();
  989. IAPManager.RetrieveADChest();
  990. ActiveShadow();
  991. transform.SetParent(ResourceManager.Get(DressroomLabel.DressRoom));
  992. transform.position = ResourceManager.Get(DressroomLabel.DressRoomPos).position;
  993. transform.localScale = ResourceManager.Get(DressroomLabel.DressRoomPos).lossyScale;
  994. ResourceManager.Get(ResourceLabel.Garden).TweenBacSr();
  995. ResourceManager.Get(DressroomLabel.DressRoom).TweenForSr();
  996. ResourceManager.Get(ObjectLabel.P_DressRoom).TweenForCG();
  997. }
  998. );
  999. tweenRoot = ResourceManager.Get(ObjectLabel.P_DressRoom).GetTweenCG();
  1000. tweenRoot.AddEventOnetime
  1001. (
  1002. EventType.ForwardFinish,
  1003. () =>
  1004. {
  1005. ResourceManager.Get(ObjectLabel.I_BlackMask).TweenForCG();
  1006. }
  1007. );
  1008. }
  1009. public void ActiveShadow()
  1010. {
  1011. ChildDic[PlayerLabel.ShadowParent].SetActive(true);
  1012. ChildDic[PlayerLabel.ShadowParent].SetLZ(3);
  1013. }
  1014. public void DeactiveShadow()
  1015. {
  1016. Shadow.GetStreamScale().Pause();
  1017. Shadow.GetStreamScale().InOrigin = true;
  1018. ChildDic[PlayerLabel.ShadowParent].SetActive(false);
  1019. }
  1020. #region 换装
  1021. public void CorrectPivot()
  1022. {
  1023. List<Transform> children = new List<Transform>();
  1024. while (transform.childCount > 0)
  1025. {
  1026. children.Add(transform.GetChild(0));
  1027. children.Back(0).parent = null;
  1028. }
  1029. Vector3 offset = Pivot.position - transform.position;
  1030. children[0].position += offset;
  1031. children[1].position += offset;
  1032. transform.position += offset;
  1033. foreach (var collider in GetComponents<BoxCollider2D>())
  1034. {
  1035. collider.offset -= new Vector2(offset.x, offset.y);
  1036. }
  1037. for (int i = 0; i < children.Count; i++)
  1038. {
  1039. children[i].parent = transform;
  1040. }
  1041. }
  1042. public UnityArmatureComponent Build()
  1043. {
  1044. if (!PlayerManager.Inited)
  1045. {
  1046. UnityFactory.factory.LoadDragonBonesData(ResourceManager.Load<TextAsset>(ResourceLabel.StandSke, Folder.Config));
  1047. UnityFactory.factory.LoadTextureAtlasData(ResourceManager.Load<TextAsset>(ResourceLabel.StandTex, Folder.Config), ResourceLabel.StandTexture);
  1048. PlayerManager.Inited = true;
  1049. }
  1050. UAC = UnityFactory.factory.BuildArmatureComponent("Armature");
  1051. UAC.transform.parent = transform;
  1052. UAC.transform.localScale = new Vector3(1, 1, 1);
  1053. UAC.transform.localPosition = new Vector3();
  1054. UAC.anim.Play(IdleAnimationName);
  1055. UAC.AddEventListener(EventObject.START, OnAnimStart);
  1056. Eye = "眼睛1";
  1057. Top = "上衣1";
  1058. Shoe = "鞋子1";
  1059. Head = "脑壳1";
  1060. Wing = "Empty";
  1061. Dress = "裙子1";
  1062. Mouse = "嘴巴1";
  1063. HeadWear = "头饰品1";
  1064. NeckSlot = UAC.armature.GetSlot("脖子");
  1065. LeftHandSlot = UAC.armature.GetSlot("左手");
  1066. RightHandSlot = UAC.armature.GetSlot("右手");
  1067. LeftLegSlot = UAC.armature.GetSlot("左腿");
  1068. RightLegSlot = UAC.armature.GetSlot("右腿");
  1069. LeftLongSleeveUAC = UAC.transform.FindChild("长袖9左 (长袖9左)").GetComponent<UnityArmatureComponent>();
  1070. RightLongSleeveUAC = UAC.transform.FindChild("长袖9右 (长袖9右)").GetComponent<UnityArmatureComponent>();
  1071. LeftShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子左");
  1072. RightShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子右");
  1073. EyeSlot = UAC.armature.GetSlot("眼睛");
  1074. TopSlot = UAC.armature.GetSlot("上衣");
  1075. HeadSlot = UAC.armature.GetSlot("脑壳");
  1076. WingSlot = UAC.armature.GetSlot("翅膀");
  1077. DressSlot = UAC.armature.GetSlot("裙子");
  1078. MouseSlot = UAC.armature.GetSlot("嘴巴");
  1079. LeftShoeSlot = UAC.armature.GetSlot("鞋子左");
  1080. RightShoeSlot = UAC.armature.GetSlot("鞋子右");
  1081. HeadWearSlot = UAC.armature.GetSlot("头饰品");
  1082. ChangeClose(BodyPart.Eye, "眼睛1", false);
  1083. ChangeClose(BodyPart.Top, "上衣1", false);
  1084. ChangeClose(BodyPart.Shoe, "鞋子1", false);
  1085. ChangeClose(BodyPart.Head, "脑壳1", false);
  1086. ChangeClose(BodyPart.Dress, "裙子1", false);
  1087. ChangeClose(BodyPart.Mouse, "嘴巴1", false);
  1088. ChangeClose(BodyPart.Headwear, "头饰品1", false);
  1089. ChangeClose(BodyPart.LeftLongSleeve, "Empty", false);
  1090. ChangeClose(BodyPart.RightLongSleeve, "Empty", false);
  1091. ChangeClose(BodyPart.LeftShortSleeve, "短袖2左", false);
  1092. ChangeClose(BodyPart.RightShortSleeve, "短袖2右", false);
  1093. CorrectPivot();
  1094. return UAC;
  1095. }
  1096. public UnityArmatureComponent BuildPink()
  1097. {
  1098. Build();
  1099. ChangeClose(BodyPart.Eye, "眼睛3", false);
  1100. ChangeClose(BodyPart.Top, "上衣3", false);
  1101. ChangeClose(BodyPart.Shoe, "鞋子3", false);
  1102. ChangeClose(BodyPart.Head, "脑壳3", false);
  1103. ChangeClose(BodyPart.Wing, "Empty", false);
  1104. ChangeClose(BodyPart.Dress, "裙子3", false);
  1105. ChangeClose(BodyPart.Mouse, "嘴巴3", false);
  1106. ChangeClose(BodyPart.Headwear, "头饰品3", false);
  1107. ResetDepth();
  1108. return UAC;
  1109. }
  1110. public UnityArmatureComponent BuildBlond()
  1111. {
  1112. Build();
  1113. ChangeClose(BodyPart.Wing, "Empty", false);
  1114. ResetDepth();
  1115. return UAC;
  1116. }
  1117. public UnityArmatureComponent BuildBrown()
  1118. {
  1119. Build();
  1120. ChangeClose(BodyPart.Eye, "眼睛2", false);
  1121. ChangeClose(BodyPart.Top, "上衣2", false);
  1122. ChangeClose(BodyPart.Shoe, "鞋子2", false);
  1123. ChangeClose(BodyPart.Head, "脑壳2", false);
  1124. ChangeClose(BodyPart.Wing, "Empty", false);
  1125. ChangeClose(BodyPart.Dress, "裙子2", false);
  1126. ChangeClose(BodyPart.Mouse, "嘴巴2", false);
  1127. ChangeClose(BodyPart.Headwear, "头饰品2", false);
  1128. ResetDepth();
  1129. return UAC;
  1130. }
  1131. public void ResetDepth()
  1132. {
  1133. UAC.transform.SetLZ(2.5f);
  1134. WingSlot.UnityTransform.SetLZ(0);
  1135. EyeSlot.UnityTransform.SetLZ(0);
  1136. TopSlot.UnityTransform.SetLZ(0);
  1137. MouseSlot.UnityTransform.SetLZ(0);
  1138. HeadWearSlot.UnityTransform.SetLZ(0);
  1139. LeftShoeSlot.UnityTransform.SetLZ(0);
  1140. RightShoeSlot.UnityTransform.SetLZ(0);
  1141. LeftLegSlot.UnityTransform.SetLZ(0);
  1142. RightLegSlot.UnityTransform.SetLZ(0);
  1143. NeckSlot.UnityTransform.SetLZ(0);
  1144. LeftHandSlot.UnityTransform.SetLZ(0);
  1145. RightHandSlot.UnityTransform.SetLZ(0);
  1146. LeftShortSleeveSlot.UnityTransform.SetLZ(0);
  1147. RightShortSleeveSlot.UnityTransform.SetLZ(0);
  1148. WingSlot.SetLZ(0.00003f);
  1149. EyeSlot.SetLZ(-0.00001f);
  1150. TopSlot.SetLZ(-0.00003f);
  1151. MouseSlot.SetLZ(-0.00001f);
  1152. HeadWearSlot.SetLZ(-0.00001f);
  1153. HeadSlot.UnityTransform.SetLZ(0);
  1154. if (HeadSlot.UnityTransform.childCount > 1)
  1155. {
  1156. HeadSlot.UnityTransform.GetChild(0).SetLZ(0.00002f);
  1157. HeadSlot.UnityTransform.GetChild(1).SetLZ(0f);
  1158. }
  1159. DressSlot.UnityTransform.SetLZ(-0.00002f);
  1160. if (DressSlot.UnityTransform.childCount > 1)
  1161. {
  1162. DressSlot.UnityTransform.GetChild(0).SetLZ(0.00002f);
  1163. DressSlot.UnityTransform.GetChild(1).SetLZ(0f);
  1164. }
  1165. LeftShoeSlot.SetLZ(-0.00001f);
  1166. RightShoeSlot.SetLZ(-0.00001f);
  1167. LeftLegSlot.SetLZ(0);
  1168. RightLegSlot.SetLZ(0);
  1169. NeckSlot.SetLZ(0.00001f);
  1170. LeftHandSlot.SetLZ(-0.00001f);
  1171. RightHandSlot.SetLZ(-0.00001f);
  1172. LeftShortSleeveSlot.SetLZ(-0.000015f);
  1173. RightShortSleeveSlot.SetLZ(-0.000015f);
  1174. LeftLongSleeveUAC.transform.SetLZ(-0.000015f);
  1175. RightLongSleeveUAC.transform.SetLZ(-0.000015f);
  1176. }
  1177. public void ChangeClose(BodyPart bodyPart, string armatureName, bool setDepth = true)
  1178. {
  1179. // Debug.Log (bodyPart + " " + armatureName);
  1180. List<DragonBones.Slot> slotList = new List<DragonBones.Slot>();
  1181. if (bodyPart == BodyPart.Eye)
  1182. {
  1183. Eye = armatureName;
  1184. slotList.Add(EyeSlot);
  1185. }
  1186. else if (bodyPart == BodyPart.Top)
  1187. {
  1188. Top = armatureName;
  1189. slotList.Add(TopSlot);
  1190. }
  1191. else if (bodyPart == BodyPart.Shoe)
  1192. {
  1193. Shoe = armatureName;
  1194. slotList.Add(LeftShoeSlot);
  1195. slotList.Add(RightShoeSlot);
  1196. }
  1197. else if (bodyPart == BodyPart.Head)
  1198. {
  1199. Head = armatureName;
  1200. slotList.Add(HeadSlot);
  1201. }
  1202. else if (bodyPart == BodyPart.Wing)
  1203. {
  1204. if (Wing == armatureName)
  1205. {
  1206. return;
  1207. }
  1208. else
  1209. {
  1210. Wing = armatureName;
  1211. slotList.Add(WingSlot);
  1212. }
  1213. }
  1214. else if (bodyPart == BodyPart.Dress)
  1215. {
  1216. Dress = armatureName;
  1217. slotList.Add(DressSlot);
  1218. }
  1219. else if (bodyPart == BodyPart.Mouse)
  1220. {
  1221. Mouse = armatureName;
  1222. slotList.Add(MouseSlot);
  1223. }
  1224. else if (bodyPart == BodyPart.Headwear)
  1225. {
  1226. HeadWear = armatureName;
  1227. slotList.Add(HeadWearSlot);
  1228. }
  1229. else if (bodyPart == BodyPart.Leg)
  1230. {
  1231. slotList.Add(LeftLegSlot);
  1232. slotList.Add(RightLegSlot);
  1233. }
  1234. else if (bodyPart == BodyPart.LeftHand)
  1235. {
  1236. slotList.Add(LeftHandSlot);
  1237. }
  1238. else if (bodyPart == BodyPart.RightHand)
  1239. {
  1240. slotList.Add(RightHandSlot);
  1241. }
  1242. else if (bodyPart == BodyPart.Neck)
  1243. {
  1244. slotList.Add(NeckSlot);
  1245. }
  1246. else if (bodyPart == BodyPart.LeftLongSleeve)
  1247. {
  1248. LeftLongSleeve = armatureName;
  1249. ChangeClose(LeftLongSleeveUAC, armatureName);
  1250. return;
  1251. }
  1252. else if (bodyPart == BodyPart.LeftShortSleeve)
  1253. {
  1254. LeftShortSleeve = armatureName;
  1255. slotList.Add(LeftShortSleeveSlot);
  1256. }
  1257. else if (bodyPart == BodyPart.RightLongSleeve)
  1258. {
  1259. RightLongSleeve = armatureName;
  1260. ChangeClose(RightLongSleeveUAC, armatureName);
  1261. return;
  1262. }
  1263. else if (bodyPart == BodyPart.RightShortSleeve)
  1264. {
  1265. RightShortSleeve = armatureName;
  1266. slotList.Add(RightShortSleeveSlot);
  1267. }
  1268. else
  1269. {
  1270. throw new Exception();
  1271. }
  1272. ChangeClose(slotList, armatureName, setDepth);
  1273. if (bodyPart == BodyPart.Wing)
  1274. {
  1275. 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);
  1276. tweenRoot.PingPong = true;
  1277. tweenRoot.StartForward();
  1278. }
  1279. }
  1280. public void ChangeClose(List<DragonBones.Slot> slotList, string armatureName, bool setDepth = true)
  1281. {
  1282. for (int i = 0; i < slotList.Count; i++)
  1283. {
  1284. slotList[i].childArmature = UnityFactory.factory.BuildArmature(armatureName, null, null, null, true);
  1285. slotList[i].UnityTransform = slotList[i].childArmature.UnityTransform.parent;
  1286. }
  1287. if (setDepth)
  1288. {
  1289. ResetDepth();
  1290. }
  1291. }
  1292. public void ChangeClose(UnityArmatureComponent uac, string armatureName, bool setDepth = true)
  1293. {
  1294. if (armatureName == "Empty")
  1295. {
  1296. uac.SetActive(false);
  1297. }
  1298. else
  1299. {
  1300. uac.SetActive(true);
  1301. }
  1302. if (setDepth)
  1303. {
  1304. ResetDepth();
  1305. }
  1306. }
  1307. #endregion
  1308. }