Ability.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System;
  4. using System.Xml;
  5. using System.Text;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. public class Ability : SkillRoot
  9. {
  10. #region 变量
  11. #region 配置
  12. protected float Person;
  13. protected float SkillCD;
  14. protected float CoinPerson;
  15. protected double UpgradeAmt;
  16. protected float Plus;
  17. protected float PersonBuff;
  18. protected float SkillCdBuff;
  19. protected int UnlockLv;
  20. protected float UnlockAmt;
  21. protected float UnlockAheadAmt;
  22. protected string UnlockPos;
  23. protected Current UnlockCur;
  24. protected Current UpgradeCur;
  25. protected Current UnlockAheadCur;
  26. protected bool ValidSlot;
  27. protected bool ValidAnim;
  28. protected string Label;
  29. protected string Anim;
  30. protected string UpgradeCD;
  31. protected string UpgradeFml;
  32. protected string UpgradePlus;
  33. protected string UpgradePerson;
  34. #endregion
  35. protected float NewPlus;
  36. protected float NewPerson;
  37. protected float NewSkillCD;
  38. protected float NewSkillCdBuff;
  39. protected float NewPersonBuff;
  40. protected float NewCoinPerson;
  41. protected double NewUpgradeAmt;
  42. public SkillStatus ItemStatus
  43. {
  44. get { return _ItemStatus; }
  45. set
  46. {
  47. _ItemStatus = value;
  48. if (_ItemStatus == SkillStatus.Lock)
  49. {
  50. if (UnlockAheadCur == Current.Free)
  51. {
  52. ItemBtn.interactable = false;
  53. ManaText.Add(ItemBtnLab, new LanStr("UI", "Fe_BtnLab4"), UnlockLv.ToString());
  54. }
  55. else
  56. {
  57. ItemBtn.interactable = true;
  58. ManaText.Add(ItemBtnLab, new LanStr("UI", "Fe_BtnLab0"), "\n", new LanStr("UI", "Fe_BtnLab4"), UnlockLv.ToString());
  59. }
  60. }
  61. else if (_ItemStatus == SkillStatus.UnLock)
  62. {
  63. ItemBtn.interactable = true;
  64. ManaText.Add(ItemBtnLab, new LanStr("UI", "Fe_BtnLab1"));
  65. }
  66. else if (_ItemStatus == SkillStatus.Upgrade)
  67. {
  68. ItemBtn.interactable = true;
  69. ManaText.Add(ItemTit, new LanStr("SkillName", _Name), " ", Level .ToString());
  70. ManaText.Add(ItemBtnLab, new LanStr("UI", "Fe_BtnLab2"));
  71. }
  72. else
  73. {
  74. throw new Exception(_ItemStatus.ToString());
  75. }
  76. }
  77. }
  78. public SkillStatus _ItemStatus;
  79. #endregion
  80. public Ability(XmlAttributeCollection attribute)
  81. {
  82. #region 配置
  83. ID = int.Parse(attribute[0].Value);
  84. Icon = attribute[20].Value;
  85. Anim = attribute[21].Value;
  86. Label = attribute[22].Value;
  87. _Name = "Ability" + ID;
  88. UnlockPos = attribute[12].Value;
  89. UpgradeCD = attribute[18].Value;
  90. UpgradeFml = attribute[15].Value;
  91. UpgradePlus = attribute[16].Value;
  92. UpgradePerson = attribute[17].Value;
  93. ClassID = IntParse(attribute[3].Value);
  94. UnlockLv = IntParse(attribute[7].Value);
  95. UnlockAmt = FloatParse(attribute[11].Value);
  96. UnlockAheadAmt = FloatParse(attribute[9].Value);
  97. SkillTab = SkillClassParse(attribute[2].Value);
  98. UpgradeAmt = UpgradeAmtParse(attribute[14].Value);
  99. UnlockCur = CurrentParse(attribute[10].Value);
  100. UpgradeCur = CurrentParse(attribute[13].Value);
  101. UnlockAheadCur = CurrentParse(attribute[8].Value);
  102. ValueBuffParse(out Person, out PersonBuff, attribute[5].Value);
  103. ValueBuffParse(out SkillCD, out SkillCdBuff, attribute[6].Value);
  104. ValueBuffParse(out CoinPerson, out Plus, attribute[4].Value);
  105. #endregion
  106. ValueBuffParse(out NewPerson, out NewPersonBuff, UpgradePerson);
  107. ValueBuffParse(out NewSkillCD, out NewSkillCdBuff, UpgradeCD);
  108. ValueBuffParse(out NewCoinPerson, out NewPlus, UpgradePlus);
  109. SkillType = SkillType.Ability;
  110. }
  111. public override void Annul()
  112. {
  113. if (_Name == "Ability1")
  114. {
  115. ManaData.Person -= NewPerson;
  116. ManaData.CoinPerson -= NewCoinPerson;
  117. }
  118. else
  119. {
  120. ManaData.SkillPerson -= NewPerson;
  121. ManaData.SkillCoinPerson -= NewCoinPerson;
  122. }
  123. ManaData.SkillPlus -= NewPlus;
  124. ManaData.SkillPersonBuff -= NewPersonBuff;
  125. if (Math.Abs(NewSkillCD) > 0.0005f)
  126. {
  127. for (int i = 0; i < ManaData.SkillList.Count; i++)
  128. {
  129. ManaData.SkillList[i].ReceiveCool(-NewSkillCD, false, false);
  130. }
  131. }
  132. if (Math.Abs(NewSkillCdBuff) > 0.0005f)
  133. {
  134. for (int i = 0; i < ManaData.SkillList.Count; i++)
  135. {
  136. ManaData.SkillList[i].ReceiveCool(-NewSkillCdBuff, false, true);
  137. }
  138. }
  139. }
  140. public override void RegistValue(float elapse, List<List<Skill>> ffList, XmlAttributeCollection attribute)
  141. {
  142. Level = int.Parse(attribute[3].Value);
  143. _ItemStatus = (SkillStatus)Enum.Parse(typeof(SkillStatus), attribute[2].Value);
  144. NewPlus = Plus;
  145. NewPerson = Person;
  146. NewSkillCD = SkillCD;
  147. NewSkillCdBuff = SkillCdBuff;
  148. NewPersonBuff = PersonBuff;
  149. NewCoinPerson = CoinPerson;
  150. NewUpgradeAmt = UpgradeAmt;
  151. ManaText.Add(ItemTit, new LanStr("SkillName", _Name));
  152. ItemLab.text = Description(0);
  153. ItemBtn.onClick.AddListener(OnClick);
  154. if (_ItemStatus == SkillStatus.Upgrade)
  155. {
  156. ManaDebug.Log(string.Format("技能<color=red>{0}</color>已解锁 等级 : {1}", Name, Level));
  157. for (int i = 0; i < Level; i++)
  158. {
  159. NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString());
  160. }
  161. UpgradeValue(ref NewPlus, Plus, UpgradePlus, Level);
  162. UpgradeValue(ref NewSkillCdBuff, UpgradeCD, Level);
  163. UpgradeValue(ref NewPersonBuff, PersonBuff, UpgradePerson, Level);
  164. UpgradeValue(ref NewPerson, Person, UpgradePerson, Level);
  165. UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, Level);
  166. UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, Level);
  167. if (Level > 0)
  168. {
  169. UseConti();
  170. }
  171. }
  172. ItemStatus = ItemStatus;
  173. }
  174. public override void UpdateStatus()
  175. {
  176. if (ManaData.Level >= UnlockLv)
  177. {
  178. if (ItemStatus == SkillStatus.Lock)
  179. {
  180. if (UnlockCur == Current.Free)
  181. {
  182. Unlock();
  183. }
  184. else
  185. {
  186. ItemStatus = SkillStatus.UnLock;
  187. }
  188. }
  189. }
  190. }
  191. protected void Unlock()
  192. {
  193. if (ManaData.Pay(UnlockAmt, UnlockCur))
  194. {
  195. ManaData.Elf++;
  196. ManaDebug.Log(string.Format("技能<color=red>{0}</color>已解锁", Name));
  197. if (UpgradeCur != Current.Free)
  198. {
  199. ItemStatus = SkillStatus.Upgrade;
  200. }
  201. else
  202. {
  203. throw new Exception();
  204. }
  205. }
  206. }
  207. protected void OnClick()
  208. {
  209. if (ManaTutorial.TutorialA || ManaTutorial.TutorialB && ManaData.Level >= 200)
  210. {
  211. TutorialClick();
  212. }
  213. else
  214. {
  215. RegularClick();
  216. }
  217. }
  218. protected void Upgrade()
  219. {
  220. if (ManaTutorial.TutorialA)
  221. {
  222. TutorialUpgrade();
  223. }
  224. else
  225. {
  226. RegularUpgrade();
  227. }
  228. }
  229. protected void UseConti()
  230. {
  231. if (ValidAnim == false)
  232. {
  233. if (!string.IsNullOrEmpty(Anim))
  234. {
  235. string[] strings = Anim.Split(',');
  236. if (strings.Length == 1)
  237. {
  238. ManaGarden.AnimList.Add((ObjType) Enum.Parse(typeof(ObjType), strings[0]));
  239. }
  240. else if (strings.Length > 1)
  241. {
  242. ManaReso.Get(strings[0], Folder.Character, true, ManaReso.Get(strings[1]), false);
  243. }
  244. }
  245. }
  246. if (ValidSlot == false)
  247. {
  248. ValidSlot = true;
  249. if (!string.IsNullOrEmpty(UnlockPos))
  250. {
  251. for (int i = 0; i < int.Parse(UnlockPos); i++)
  252. {
  253. ManaGarden.UnlockSlot();
  254. }
  255. }
  256. }
  257. ManaData.Person += NewPerson;
  258. ManaData.CoinPerson += NewCoinPerson;
  259. ManaData.SkillPlus += NewPlus;
  260. ManaData.SkillPersonBuff += NewPersonBuff;
  261. if (Math.Abs(NewSkillCD) > 0.0005f)
  262. {
  263. for (int i = 0; i < ManaData.SkillList.Count; i++)
  264. {
  265. ManaData.SkillList[i].ReceiveCool(NewSkillCD, false, false);
  266. }
  267. }
  268. if (Math.Abs(NewSkillCdBuff) > 0.0005f)
  269. {
  270. for (int i = 0; i < ManaData.SkillList.Count; i++)
  271. {
  272. ManaData.SkillList[i].ReceiveCool(NewSkillCdBuff, false, true);
  273. }
  274. }
  275. #region 调试输出
  276. StringBuilder strb = new StringBuilder();
  277. strb.AppendFormat("使用技能 : <color=red>{0}</color>", Name);
  278. if (Math.Abs(NewPlus) > 0.0005f)
  279. {
  280. strb.AppendFormat(" 收入加成<color=red>+{0}%</color>", NewPlus * 100);
  281. }
  282. if (Math.Abs(NewPerson) > 0.0005f)
  283. {
  284. strb.AppendFormat(" 参观人次<color=red>+{0}</color>", NewPerson);
  285. }
  286. if (Math.Abs(NewPersonBuff) > 0.0005f)
  287. {
  288. strb.AppendFormat(" 参观人次<color=red>+{0}%</color>", NewPersonBuff * 100);
  289. }
  290. if (Math.Abs(NewCoinPerson) > 0.0005f)
  291. {
  292. strb.AppendFormat(" 每次金币<color=red>+{0}</color>", NewCoinPerson);
  293. }
  294. if (Math.Abs(SkillCD) > 0.0005f)
  295. {
  296. strb.AppendFormat(" 减少冷却上限<color=red>{0}</color>", SkillCD);
  297. }
  298. if (Math.Abs(SkillCdBuff) > 0.0005f)
  299. {
  300. strb.AppendFormat(" 减少冷却上限<color=red>{0}%</color>", SkillCdBuff * 100);
  301. }
  302. if (!string.IsNullOrEmpty(UnlockPos))
  303. {
  304. int amt = int.Parse(UnlockPos);
  305. strb.AppendFormat(" 解锁了<color=red>{0}</color>块土地", amt);
  306. }
  307. strb.Append(" <color=red>永久有效</color>");
  308. ManaDebug.Log(strb.ToString());
  309. #endregion
  310. }
  311. protected void UnlockAhead()
  312. {
  313. if (ItemStatus != SkillStatus.Lock)
  314. {
  315. ManaDebug.Log("您并不需要提前解锁");
  316. return;
  317. }
  318. if (ManaData.Pay(UnlockAheadAmt, UnlockAheadCur))
  319. {
  320. ManaData.Elf++;
  321. ManaDebug.Log(string.Format("技能<color=red>{0}</color>已解锁", Name));
  322. if (UpgradeCur != Current.Free)
  323. {
  324. ItemStatus = SkillStatus.Upgrade;
  325. }
  326. else
  327. {
  328. throw new Exception();
  329. }
  330. }
  331. }
  332. private void TutorialClick()
  333. {
  334. ManaReso.Get("Fe_Info").TweenForCG();
  335. ManaReso.SetText("Fe_Tit", Name);
  336. ManaReso.SetSprite("Fe_Icon", ItemIcon.sprite);
  337. if (ItemStatus == SkillStatus.Lock)
  338. {
  339. ManaReso.SetText("Fe_Lab0", "");
  340. ManaReso.SetText("Fe_Lab1", Description(0));
  341. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab0"), ImageParse(UnlockAheadCur), UnlockAheadAmt));
  342. ManaReso.SetButtonEvent
  343. (
  344. "Fe_Btn",
  345. () =>
  346. {
  347. UnlockAhead();
  348. ManaReso.Get("Fe_Info").TweenBacCG();
  349. }
  350. );
  351. }
  352. else if (ItemStatus == SkillStatus.UnLock)
  353. {
  354. ManaReso.SetText("Fe_Lab0", "");
  355. ManaReso.SetText("Fe_Lab1", Description(0));
  356. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab1"), ImageParse(UnlockCur), UnlockAmt));
  357. ManaReso.SetButtonEvent
  358. (
  359. "Fe_Btn",
  360. () =>
  361. {
  362. Unlock();
  363. ManaReso.Get("Fe_Info").TweenBacCG();
  364. }
  365. );
  366. }
  367. else if (ItemStatus == SkillStatus.Upgrade)
  368. {
  369. Tutorial.HightDisable(0, true);
  370. ManaReso.SetText("Fe_Lab0", Description(0));
  371. ManaReso.SetText("Fe_Lab1", Description(1));
  372. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), ImageParse(UpgradeCur), NewUpgradeAmt));
  373. ManaReso.AddButtonEventOnetime
  374. (
  375. "Fe_Btn",
  376. () =>
  377. {
  378. TutorialUpgrade();
  379. ManaReso.Get("Fe_Info").TweenBacCG();
  380. if (ManaTutorial.TutorialA)
  381. {
  382. ManaTutorial.EndStep7();
  383. }
  384. else if (ManaTutorial.TutorialB)
  385. {
  386. ManaTutorial.EndStep10();
  387. }
  388. }
  389. );
  390. }
  391. else
  392. {
  393. throw new Exception();
  394. }
  395. }
  396. private void RegularClick()
  397. {
  398. if (ManaData.Connect == false)
  399. {
  400. ManaReso.Get("Fg_Reconnect").TweenForCG();
  401. return;
  402. }
  403. ManaReso.Get("Fe_Info").TweenForCG();
  404. ManaReso.SetText("Fe_Tit", Name);
  405. ManaReso.SetSprite("Fe_Icon", ItemIcon.sprite);
  406. if (ItemStatus == SkillStatus.Lock)
  407. {
  408. ManaReso.SetText("Fe_Lab0", "");
  409. ManaReso.SetText("Fe_Lab1", Description(0));
  410. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab0"), ImageParse(UnlockAheadCur), UnlockAheadAmt));
  411. ManaReso.SetButtonEvent
  412. (
  413. "Fe_Btn",
  414. () =>
  415. {
  416. UnlockAhead();
  417. ManaReso.Get("Fe_Info").TweenBacCG();
  418. }
  419. );
  420. }
  421. else if (ItemStatus == SkillStatus.UnLock)
  422. {
  423. ManaReso.SetText("Fe_Lab0", "");
  424. ManaReso.SetText("Fe_Lab1", Description(0));
  425. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab1"), ImageParse(UnlockCur), UnlockAmt));
  426. ManaReso.SetButtonEvent
  427. (
  428. "Fe_Btn",
  429. () =>
  430. {
  431. Unlock();
  432. ManaReso.Get("Fe_Info").TweenBacCG();
  433. }
  434. );
  435. }
  436. else if (ItemStatus == SkillStatus.Upgrade)
  437. {
  438. ManaReso.SetText("Fe_Lab0", Description(0));
  439. ManaReso.SetText("Fe_Lab1", Description(1));
  440. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), ImageParse(UpgradeCur), NewUpgradeAmt));
  441. ManaReso.SetButtonEvent
  442. (
  443. "Fe_Btn",
  444. () =>
  445. {
  446. Upgrade();
  447. }
  448. );
  449. }
  450. else
  451. {
  452. throw new Exception();
  453. }
  454. }
  455. private void TutorialUpgrade()
  456. {
  457. if (_Name == "Ability1")
  458. {
  459. Level += 20;
  460. ManaData.Level += 20;
  461. }
  462. else
  463. {
  464. Level++;
  465. }
  466. ManaData.Elf++;
  467. Annul();
  468. NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString());
  469. UpgradeValue(ref NewPerson, Person, UpgradePerson, 1);
  470. UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, 1);
  471. UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, 1);
  472. UpgradeValue(ref NewPlus, Plus, UpgradePlus, 1);
  473. UpgradeValue(ref NewSkillCdBuff, UpgradeCD, 1);
  474. UpgradeValue(ref NewPersonBuff, PersonBuff, UpgradePerson, 1);
  475. ManaText.Add(ItemTit, new LanStr("SkillName", _Name), " ", Level.ToString());
  476. ItemLab.text = Description(0);
  477. ManaReso.SetText("Fe_Lab0", Description(0));
  478. ManaReso.SetText("Fe_Lab1", Description(1));
  479. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), ImageParse(UpgradeCur), NewUpgradeAmt));
  480. ManaDebug.Log(string.Format("<color=red>{0}</color> 升级 : {1}", Name, Level));
  481. UseConti();
  482. if (ValidAnim == false)
  483. {
  484. ValidAnim = true;
  485. if (!string.IsNullOrEmpty(Anim))
  486. {
  487. string[] strings = Anim.Split(',');
  488. if (strings.Length == 1)
  489. {
  490. if (ManaGarden.PlantList.Count == 0)
  491. {
  492. return;
  493. }
  494. Flower flower = ManaGarden.PlantList.Random().Flower;
  495. flower.PlayAnim(ManaGarden.AnimList.Last(0));
  496. ManaReso.Get<Button>("F_Close").onClick.Invoke();
  497. Tween tween = ManaReso.Get("F_Manage0").GetTweenVec();
  498. ManaReso.Get("MainCamera").CreateZoom2D();
  499. tween.AddEventOnetime
  500. (
  501. EventType.BackwardFinish,
  502. () =>
  503. {
  504. ManaReso.Get("MainCamera").Zoom2D(1.5f, 1f, 1, flower.transform.GetChild(4), Curve.EaseOutQuad);
  505. }
  506. );
  507. }
  508. else if (strings.Length > 1)
  509. {
  510. ManaReso.Get<Button>("F_Close").onClick.Invoke();
  511. ManaReso.Get("MainCamera").CreateZoom2D();
  512. Tween tween0 = ManaReso.Get(strings[0]).CreateTweenSr(0, 1, 1, true, true, Curve.EaseOutQuad, false, true);
  513. tween0.InOrigin = true;
  514. Tween tween1 = ManaReso.Get("F_Manage0").GetTweenVec();
  515. tween1.AddEventOnetime
  516. (
  517. EventType.BackwardFinish,
  518. () =>
  519. {
  520. tween0.StartForward();
  521. ManaReso.Get("MainCamera").Zoom2D(3.5f, 1f, 1, ManaReso.Get(strings[0]), Curve.EaseOutQuad);
  522. }
  523. );
  524. }
  525. }
  526. }
  527. }
  528. private void RegularUpgrade()
  529. {
  530. if (ManaData.Pay(NewUpgradeAmt, UpgradeCur))
  531. {
  532. if (_Name == "Ability1")
  533. {
  534. ManaData.Level+= 20;
  535. }
  536. Level++;
  537. ManaData.Elf++;
  538. Annul();
  539. NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString());
  540. UpgradeValue(ref NewPerson, Person, UpgradePerson, 1);
  541. UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, 1);
  542. UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, 1);
  543. UpgradeValue(ref NewPlus, Plus, UpgradePlus, 1);
  544. UpgradeValue(ref NewSkillCdBuff, UpgradeCD, 1);
  545. UpgradeValue(ref NewPersonBuff, PersonBuff, UpgradePerson, 1);
  546. ManaText.Add(ItemTit, new LanStr("SkillName", _Name), " ", Level.ToString());
  547. ItemLab.text = Description(0);
  548. ManaReso.SetText("Fe_Lab0", Description(0));
  549. ManaReso.SetText("Fe_Lab1", Description(1));
  550. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), ImageParse(UpgradeCur), NewUpgradeAmt));
  551. ManaDebug.Log(string.Format("<color=red>{0}</color> 升级 : {1}", Name, Level));
  552. UseConti();
  553. if (ValidAnim == false)
  554. {
  555. ValidAnim = true;
  556. if (!string.IsNullOrEmpty(Anim))
  557. {
  558. string[] strings = Anim.Split(',');
  559. if (strings.Length == 1)
  560. {
  561. if (ManaGarden.PlantList.Count == 0)
  562. {
  563. return;
  564. }
  565. Flower flower = ManaGarden.PlantList.Random().Flower;
  566. flower.PlayAnim(ManaGarden.AnimList.Last(0));
  567. ManaReso.Get<Button>("F_Close").onClick.Invoke();
  568. Tween tween = ManaReso.Get("F_Manage0").GetTweenVec();
  569. ManaReso.Get("MainCamera").CreateZoom2D();
  570. tween.AddEventOnetime
  571. (
  572. EventType.BackwardFinish,
  573. () =>
  574. {
  575. ManaReso.Get("MainCamera").Zoom2D(1.5f, 1f, 1, flower.transform.GetChild(4), Curve.EaseOutQuad);
  576. }
  577. );
  578. }
  579. else if (strings.Length > 1)
  580. {
  581. ManaReso.Get<Button>("F_Close").onClick.Invoke();
  582. Tween tween0 = ManaReso.Get(strings[0]).CreateTweenSr(0, 1, 1, true, true, Curve.EaseOutQuad, false, true);
  583. tween0.InOrigin = true;
  584. Tween tween1 = ManaReso.Get("F_Manage0").GetTweenVec();
  585. ManaReso.Get("MainCamera").CreateZoom2D();
  586. tween1.AddEventOnetime
  587. (
  588. EventType.BackwardFinish,
  589. () =>
  590. {
  591. tween0.StartForward();
  592. ManaReso.Get("MainCamera").Zoom2D(3.5f, 1f, 1, ManaReso.Get(strings[0]), Curve.EaseOutQuad);
  593. }
  594. );
  595. }
  596. }
  597. }
  598. }
  599. }
  600. #region 解读器
  601. protected override string Description(int offset)
  602. {
  603. float temp;
  604. string[] strings = Desc.Split('[', ']');
  605. StringBuilder stringBuilder = new StringBuilder();
  606. for (int i = 0; i < strings.Length; i++)
  607. {
  608. if (strings[i].Contains("lv"))
  609. {
  610. }
  611. else if (strings[i].Contains("&person&"))
  612. {
  613. #region MyRegion
  614. if (Math.Abs(Person) > 0.0005f)
  615. {
  616. temp = NewPerson;
  617. UpgradeValue(ref temp, Person, UpgradePerson, offset);
  618. UpgradeUnit(ref temp, strings[i]);
  619. stringBuilder.Append(temp.ToString("0"));
  620. }
  621. else if (Math.Abs(PersonBuff) > 0.0005f)
  622. {
  623. temp = NewPersonBuff;
  624. UpgradeValue(ref temp, PersonBuff, UpgradePerson, offset);
  625. stringBuilder.Append(string.Format("{0:0}%", temp * 100));
  626. }
  627. #endregion
  628. }
  629. else if (strings[i].Contains("&skill_cd&"))
  630. {
  631. #region MyRegion
  632. if (Math.Abs(SkillCD) > 0.0005f)
  633. {
  634. temp = NewSkillCD;
  635. UpgradeValue(ref temp, SkillCD, UpgradeCD, offset);
  636. UpgradeUnit(ref temp, strings[i]);
  637. stringBuilder.Append(temp.ToString("0"));
  638. }
  639. else if (Math.Abs(SkillCdBuff) > 0.0005f)
  640. {
  641. temp = NewSkillCdBuff;
  642. UpgradeValue(ref temp, UpgradeCD, offset);
  643. stringBuilder.Append(string.Format("{0:0}%", temp * 100));
  644. }
  645. #endregion
  646. }
  647. else if (strings[i].Contains("&coin_person&"))
  648. {
  649. #region MyRegion
  650. if (Math.Abs(CoinPerson) > 0.0005f)
  651. {
  652. temp = NewCoinPerson;
  653. UpgradeValue(ref temp, CoinPerson, UpgradePlus, offset);
  654. UpgradeUnit(ref temp, strings[i]);
  655. stringBuilder.Append(temp.ToString("0.0"));
  656. }
  657. else if (Math.Abs(Plus) > 0.0005f)
  658. {
  659. temp = NewPlus;
  660. UpgradeValue(ref temp, Plus, UpgradePlus, offset);
  661. stringBuilder.Append(string.Format("{0:0}%", temp * 100));
  662. }
  663. #endregion
  664. }
  665. else
  666. {
  667. stringBuilder.Append(strings[i]);
  668. }
  669. }
  670. return stringBuilder.ToString();
  671. }
  672. protected double UpgradeAmtParse(string str)
  673. {
  674. if (string.IsNullOrEmpty(str))
  675. {
  676. return UnlockAmt;
  677. }
  678. else
  679. {
  680. return double.Parse(str);
  681. }
  682. }
  683. #endregion
  684. }