Skill.cs 22 KB

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