Skill.cs 23 KB

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