Skill.cs 26 KB

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