BigSkill.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  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. public class BigSkill : Skill
  9. {
  10. #region 变量
  11. public int BarIndex;
  12. public Text BarLab;
  13. public Image BarBk0;
  14. public Image BarBk1;
  15. public Button BarBtn;
  16. public SkillStatus BarStatus
  17. {
  18. get { return BarStatus_; }
  19. set
  20. {
  21. BarStatus_ = value;
  22. if (BarStatus_ == SkillStatus.Cool)
  23. {
  24. BarBk0.SetActive(true);
  25. BarBk1.SetActive(false);
  26. }
  27. else if (BarStatus_ == SkillStatus.UnLock)
  28. {
  29. BarBk0.SetActive(false);
  30. BarBk1.SetActive(true);
  31. }
  32. else if (BarStatus_ == SkillStatus.Buy)
  33. {
  34. BarBk0.SetActive(false);
  35. BarBk1.SetActive(true);
  36. BarBtn.interactable = true;
  37. }
  38. }
  39. }
  40. public override SkillStatus ItemStatus
  41. {
  42. get { return ItemStatus_; }
  43. set
  44. {
  45. ItemStatus_ = value;
  46. if (SkillTab == SkillTab.Null)
  47. {
  48. return;
  49. }
  50. if (ItemStatus_ == SkillStatus.Lock)
  51. {
  52. ManaLan.Add(ItemBtnLab, new LanStr("UI", "Fe_BtnLab0"), "\n", new LanStr("UI", "Fe_BtnLab4"), UnlockLv);
  53. }
  54. else if (ItemStatus_ == SkillStatus.UnLock)
  55. {
  56. ManaLan.Add(ItemBtnLab, new LanStr("UI", "Fe_BtnLab1"), "\n", Auxiliary.ImageParse(UnlockCur), UnlockAmt.ToString("0"));
  57. }
  58. else if (ItemStatus_ == SkillStatus.Upgrade)
  59. {
  60. ManaLan.Add(ItemBtnLab, new LanStr("UI", "Fe_BtnLab2"), "\n", Auxiliary.ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt));
  61. }
  62. }
  63. }
  64. public SkillStatus BarStatus_;
  65. #endregion
  66. public BigSkill(XmlAttributeCollection attribute) : base(attribute)
  67. {
  68. BarIndex = Auxiliary.IntParse(attribute[4].Value,0);
  69. SkillType = SkillType.BigSkill;
  70. }
  71. public override void AnnulA()
  72. {
  73. CoolTimer = CD * CdBuff - 1;
  74. BarStatus = SkillStatus.Cool;
  75. ManaCenter.CoolList.Add(this);
  76. AnnulB();
  77. }
  78. public override void AnnulB()
  79. {
  80. ManaCenter.SkillPlus -= NewPlus;
  81. ManaCenter.SkillPerson -= NewPerson;
  82. ManaCenter.SkillPersonBuff -= NewPersonBuff;
  83. ManaCenter.SkillCoinPerson -= NewCoinPerson;
  84. }
  85. public override bool DoUse()
  86. {
  87. UseTimer -= Time.deltaTime;
  88. TimeSpan timeSpan = new TimeSpan(0, 0, 0, Mathf.CeilToInt(UseTimer));
  89. if (timeSpan.Hours >= 1)
  90. {
  91. BarLab.text = string.Format("{0} : {1}", timeSpan.Hours.ToString("00"), timeSpan.Minutes.ToString("00"));
  92. }
  93. else
  94. {
  95. BarLab.text = string.Format("{0} : {1}", timeSpan.Minutes.ToString("00"), timeSpan.Seconds.ToString("00"));
  96. }
  97. if (UseTimer <= 0)
  98. {
  99. AnnulA();
  100. return true;
  101. }
  102. else
  103. {
  104. return false;
  105. }
  106. }
  107. public override bool DoCool()
  108. {
  109. CoolTimer -= Time.deltaTime;
  110. TimeSpan timeSpan = new TimeSpan(0, 0, 0, Mathf.CeilToInt(CoolTimer));
  111. if (timeSpan.Hours >= 1)
  112. {
  113. BarLab.text = string.Format("{0} : {1}", timeSpan.Hours.ToString("00"), timeSpan.Minutes.ToString("00"));
  114. }
  115. else
  116. {
  117. BarLab.text = string.Format("{0} : {1}", timeSpan.Minutes.ToString("00"), timeSpan.Seconds.ToString("00"));
  118. }
  119. BarBk0.fillAmount = CoolTimer / CD;
  120. if (CoolTimer <= 0)
  121. {
  122. BarLab.text = "";
  123. BarStatus = SkillStatus.Buy;
  124. return true;
  125. }
  126. else
  127. {
  128. return false;
  129. }
  130. }
  131. public override void Reactive()
  132. {
  133. if (BarStatus == SkillStatus.Use)
  134. {
  135. AnnulB();
  136. ManaCenter.UseList.Remove(this);
  137. }
  138. else if (BarStatus == SkillStatus.Cool)
  139. {
  140. ManaCenter.CoolList.Remove(this);
  141. }
  142. }
  143. public override void RegistValue(bool firstRegist, float elapse, List<List<Skill>> useList, XmlAttributeCollection attribute)
  144. {
  145. Level = int.Parse(attribute[4].Value);
  146. UseTimer = float.Parse(attribute[6].Value);
  147. CoolTimer = float.Parse(attribute[5].Value);
  148. BarBk1.material = Lib.GrayMat;
  149. BarStatus_ = (SkillStatus)Enum.Parse(typeof(SkillStatus), attribute[3].Value);
  150. ItemStatus_ = (SkillStatus)Enum.Parse(typeof(SkillStatus), attribute[2].Value);
  151. NewPlus = Plus;
  152. NewPerson = Person;
  153. NewSkillCD = SkillCD;
  154. NewDuration = Duration;
  155. NewCoinOnce = CoinOnce;
  156. NewSkillCdBuff = SkillCdBuff;
  157. NewPersonBuff = PersonBuff;
  158. NewCoinPerson = CoinPerson;
  159. NewUpgradeAmt = UpgradeAmt;
  160. NewCoinOnceBuff = CoinOnceBuff;
  161. BarBk1.sprite = Icon;
  162. BarBtn.onClick.RemoveAllListeners();
  163. BarBtn.onClick.AddListener(Buy);
  164. if (SkillTab != SkillTab.Null)
  165. {
  166. for (int i = 0; i < Level - 1; i++)
  167. {
  168. NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString());
  169. }
  170. if (BarStatus_ != SkillStatus.Lock && BarStatus_ != SkillStatus.UnLock)
  171. {
  172. ItemIcon.material = null;
  173. UpgradeValue(ref NewPlus, UpgradePlus, Level - 1);
  174. UpgradeValue(ref NewPersonBuff, UpgradePerson, Level - 1);
  175. UpgradeValue(ref NewCoinOnceBuff, UpgradeCoinOnce, Level - 1);
  176. UpgradeSkillCdBuff(ref NewSkillCdBuff, UpgradeCD, Level - 1);
  177. UpgradeValue(ref NewPerson, Person, UpgradePerson, Level - 1);
  178. UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, Level - 1);
  179. UpgradeValue(ref NewDuration, Duration, UpgradeDuration, Level - 1);
  180. UpgradeValue(ref NewCoinOnce, CoinOnce, UpgradeCoinOnce, Level - 1);
  181. UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, Level - 1);
  182. }
  183. else
  184. {
  185. ItemIcon.material = Lib.GrayMat;
  186. }
  187. ItemBtn.onClick.RemoveAllListeners();
  188. ItemBtn.onClick.AddListener(OnClick);
  189. ItemLab.text = GetDescription(0);
  190. }
  191. if (BarStatus_ == SkillStatus.Use)
  192. {
  193. UseA();
  194. if (UseTimer < elapse)
  195. {
  196. ManaCenter.UseList.Remove(this);
  197. if (useList.Count > 0)
  198. {
  199. if (UseTimer < ManaCenter.CircleTimer)
  200. {
  201. useList[0].UniqueAdd(this);
  202. }
  203. else
  204. {
  205. int circle = 1 + Mathf.FloorToInt((UseTimer - ManaCenter.CircleTimer) / ManaCenter.CircleTime);
  206. useList[circle].UniqueAdd(this);
  207. }
  208. }
  209. }
  210. else
  211. {
  212. UseTimer -= elapse;
  213. BarBk1.SetActive(true);
  214. }
  215. }
  216. else if (BarStatus_ == SkillStatus.Cool)
  217. {
  218. CoolTimer -= elapse;
  219. ManaCenter.CoolList.Add(this);
  220. }
  221. if (BarStatus_ != SkillStatus.UnLock)
  222. {
  223. BarBk1.material = null;
  224. }
  225. if (ItemStatus_ == SkillStatus.UnLock)
  226. {
  227. ManaUI.UpdateHint();
  228. }
  229. BarStatus = BarStatus;
  230. ItemStatus = ItemStatus;
  231. }
  232. public override void ReceiveCool(float amt, bool current, bool buff)
  233. {
  234. if (!CoolLock)
  235. {
  236. return;
  237. }
  238. if (current)
  239. {
  240. if (BarStatus != SkillStatus.Cool)
  241. {
  242. return;
  243. }
  244. if (buff)
  245. {
  246. CoolTimer -= CD * amt;
  247. }
  248. else
  249. {
  250. CoolTimer -= amt;
  251. }
  252. }
  253. else
  254. {
  255. if (buff)
  256. {
  257. CdBuff = 1 - amt;
  258. }
  259. else
  260. {
  261. CD -= amt;
  262. }
  263. }
  264. }
  265. public override void UpdateStatus()
  266. {
  267. if (!ManaCenter.Complete)
  268. {
  269. return;
  270. }
  271. if (ManaCenter.Level >= UnlockLv)
  272. {
  273. if (SkillTab == SkillTab.Null)
  274. {
  275. if (BarStatus == SkillStatus.UnLock)
  276. {
  277. Unlock();
  278. }
  279. }
  280. else
  281. {
  282. if (ItemStatus == SkillStatus.Lock)
  283. {
  284. if (UnlockCur == Current.Free)
  285. {
  286. Unlock();
  287. }
  288. else
  289. {
  290. ItemStatus = SkillStatus.UnLock;
  291. ManaUI.UpdateHint();
  292. }
  293. }
  294. }
  295. }
  296. }
  297. public override void RegistReference()
  298. {
  299. base.RegistReference();
  300. BarLab = ManaReso.Get<Text>(string.Format("F_SkillLab{0}", BarIndex));
  301. BarBk0 = ManaReso.Get<Image>(string.Format("F_SkillBk{0}0", BarIndex));
  302. BarBk1 = ManaReso.Get<Image>(string.Format("F_SkillBk{0}1", BarIndex));
  303. BarBtn = BarBk1.GetComponent<Button>();
  304. }
  305. protected void Unlock()
  306. {
  307. ManaCenter.Pay
  308. (
  309. ID,
  310. UnlockAmt,
  311. UnlockCur,
  312. () =>
  313. {
  314. ManaAudio.PlayClip(Clip.SkillClip);
  315. BarStatus = SkillStatus.Buy;
  316. ItemStatus = SkillStatus.Upgrade;
  317. if (SkillTab != SkillTab.Null)
  318. {
  319. ItemIcon.material = null;
  320. }
  321. if (UnlockCur != Current.Free)
  322. {
  323. ManaUI.UpdateHint();
  324. }
  325. Level = 1;
  326. BarBk1.material = null;
  327. },
  328. StaticsManager.ItemID.解锁技能,
  329. StaticsManager.ConsumeModule.Shop
  330. );
  331. }
  332. protected void Upgrade()
  333. {
  334. ManaCenter.Pay
  335. (
  336. ID,
  337. NewUpgradeAmt,
  338. UpgradeCur,
  339. () =>
  340. {
  341. ManaAudio.PlayClip(Clip.SkillClip);
  342. Level++;
  343. if (BarStatus == SkillStatus.Use)
  344. {
  345. AnnulB();
  346. ManaCenter.UseList.Remove(this);
  347. }
  348. NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString("0.00"));
  349. UpgradeValue(ref NewPlus, UpgradePlus, 1);
  350. UpgradeValue(ref NewPersonBuff, UpgradePerson, 1);
  351. UpgradeValue(ref NewCoinOnceBuff, UpgradeCoinOnce, 1);
  352. UpgradeSkillCdBuff(ref NewSkillCdBuff, UpgradeCD, 1);
  353. UpgradeValue(ref NewPerson, Person, UpgradePerson, 1);
  354. UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, 1);
  355. UpgradeValue(ref NewDuration, Duration, UpgradeDuration, 1);
  356. UpgradeValue(ref NewCoinOnce, CoinOnce, UpgradeCoinOnce, 1);
  357. UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, 1);
  358. if (BarStatus == SkillStatus.Use)
  359. {
  360. UseA();
  361. }
  362. },
  363. StaticsManager.ItemID.升级技能,
  364. StaticsManager.ConsumeModule.Shop
  365. );
  366. }
  367. protected override void Buy()
  368. {
  369. if (!ManaServer.Connect)
  370. {
  371. ManaReso.Get("Fg_Reconnect").TweenForCG();
  372. return;
  373. }
  374. ManaCenter.Pay
  375. (
  376. ID,
  377. UseAmt,
  378. BuyCur,
  379. () =>
  380. {
  381. ManaAudio.PlayClip(Clip.SkillClip);
  382. ManaReso.GetLightwall();
  383. ManaCenter.SkillAmt++;
  384. UseTimer = NewDuration - 1;
  385. UseA();
  386. UseB();
  387. ManaInfo.Show(string.Format("{0}{1}", Language.GetStr("UI", "J_Info1"), Language.GetStr("SkillName", ID)), 10f);
  388. },
  389. StaticsManager.ItemID.使用技能,
  390. StaticsManager.ConsumeModule.Shop
  391. );
  392. }
  393. protected override void UseA()
  394. {
  395. BarBtn.interactable = false;
  396. if (UseTimer.Equal(-1))
  397. {
  398. AnnulA();
  399. }
  400. else
  401. {
  402. BarStatus = SkillStatus.Use;
  403. ManaCenter.UseList.Add(this);
  404. }
  405. ManaCenter.SkillPlus += NewPlus;
  406. ManaCenter.SkillPerson += NewPerson;
  407. ManaCenter.SkillPersonBuff += NewPersonBuff;
  408. ManaCenter.SkillCoinPerson += NewCoinPerson;
  409. if (!NewSkillCD.Equal(0))
  410. {
  411. for (int i = 0; i < ManaCenter.SkillList.Count; i++)
  412. {
  413. ManaCenter.SkillList[i].ReceiveCool(NewSkillCD, true, false);
  414. }
  415. }
  416. if (!NewSkillCdBuff.Equal(0))
  417. {
  418. for (int i = 0; i < ManaCenter.SkillList.Count; i++)
  419. {
  420. ManaCenter.SkillList[i].ReceiveCool(NewSkillCdBuff, true, true);
  421. }
  422. }
  423. }
  424. protected override void OnClick()
  425. {
  426. ManaAudio.PlayClip(Clip.BtnClip);
  427. ManaReso.Get("Fe_Info").TweenForCG();
  428. ManaReso.SetText("Fe_Tit", Name);
  429. ManaReso.SetSprite("Fe_Icon", Icon);
  430. if (ItemStatus == SkillStatus.Lock)
  431. {
  432. ManaReso.SetText("Fe_Lab0", "");
  433. ManaReso.SetText("Fe_Lab1", GetDescription(0));
  434. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab0"), Auxiliary.ImageParse(UnlockAheadCur), UnlockAheadAmt.ToString("0")));
  435. ManaReso.SetButtonEvent
  436. (
  437. "Fe_Btn",
  438. () =>
  439. {
  440. UnlockAhead();
  441. ManaReso.Get("Fe_Info").TweenBacCG();
  442. }
  443. );
  444. }
  445. else if (ItemStatus == SkillStatus.UnLock)
  446. {
  447. ManaReso.SetText("Fe_Lab0", "");
  448. ManaReso.SetText("Fe_Lab1", GetDescription(0));
  449. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab1"), Auxiliary.ImageParse(UnlockCur), UnlockAmt));
  450. ManaReso.SetButtonEvent
  451. (
  452. "Fe_Btn",
  453. () =>
  454. {
  455. Unlock();
  456. ManaReso.Get("Fe_Info").TweenBacCG();
  457. }
  458. );
  459. }
  460. else if (ItemStatus == SkillStatus.Upgrade)
  461. {
  462. ManaReso.SetText("Fe_Lab0", GetDescription(0));
  463. ManaReso.SetText("Fe_Lab1", GetDescription(1));
  464. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), Auxiliary.ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt)));
  465. ManaReso.SetButtonEvent
  466. (
  467. "Fe_Btn",
  468. () =>
  469. {
  470. Upgrade();
  471. ItemLab.text = GetDescription(0);
  472. ItemBtnLab.text = Language.GetStr("UI", "Fe_BtnLab2") + "\n" + Auxiliary.ImageParse(UpgradeCur) + Auxiliary.ShrinkNumberStr(NewUpgradeAmt);
  473. ManaReso.SetText("Fe_Tit", Name);
  474. ManaReso.SetText("Fe_Lab0", GetDescription(0));
  475. ManaReso.SetText("Fe_Lab1", GetDescription(1));
  476. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), Auxiliary.ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt)));
  477. }
  478. );
  479. }
  480. }
  481. protected override void UnlockAhead()
  482. {
  483. ManaCenter.Pay
  484. (
  485. ID,
  486. UnlockAheadAmt,
  487. UnlockAheadCur,
  488. () =>
  489. {
  490. if (UnlockCur == Current.Free)
  491. {
  492. Unlock();
  493. }
  494. else
  495. {
  496. ManaAudio.PlayClip(Clip.SkillClip);
  497. ItemStatus = SkillStatus.UnLock;
  498. }
  499. },
  500. StaticsManager.ItemID.提前解锁技能,
  501. StaticsManager.ConsumeModule.Shop
  502. );
  503. }
  504. }