Skill.cs 26 KB

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