Skill.cs 21 KB

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