Skill.cs 26 KB

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