Skill.cs 21 KB

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