Ability.cs 25 KB

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