BigSkill.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  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.ConsumeModule.Shop
  329. );
  330. }
  331. protected void Upgrade()
  332. {
  333. ManaCenter.Pay
  334. (
  335. ID,
  336. NewUpgradeAmt,
  337. UpgradeCur,
  338. () =>
  339. {
  340. ManaAudio.PlayClip(Clip.SkillClip);
  341. Level++;
  342. if (BarStatus == SkillStatus.Use)
  343. {
  344. AnnulB();
  345. ManaCenter.UseList.Remove(this);
  346. }
  347. NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString("0.00"));
  348. UpgradeValue(ref NewPlus, UpgradePlus, 1);
  349. UpgradeValue(ref NewPersonBuff, UpgradePerson, 1);
  350. UpgradeValue(ref NewCoinOnceBuff, UpgradeCoinOnce, 1);
  351. UpgradeSkillCdBuff(ref NewSkillCdBuff, UpgradeCD, 1);
  352. UpgradeValue(ref NewPerson, Person, UpgradePerson, 1);
  353. UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, 1);
  354. UpgradeValue(ref NewDuration, Duration, UpgradeDuration, 1);
  355. UpgradeValue(ref NewCoinOnce, CoinOnce, UpgradeCoinOnce, 1);
  356. UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, 1);
  357. if (BarStatus == SkillStatus.Use)
  358. {
  359. UseA();
  360. }
  361. },
  362. StaticsManager.ConsumeModule.Shop
  363. );
  364. }
  365. protected override void Buy()
  366. {
  367. if (!ManaServer.Connect)
  368. {
  369. ManaReso.Get("Fg_Reconnect").TweenForCG();
  370. return;
  371. }
  372. ManaCenter.Pay
  373. (
  374. ID,
  375. UseAmt,
  376. BuyCur,
  377. () =>
  378. {
  379. ManaAudio.PlayClip(Clip.SkillClip);
  380. ManaReso.GetLightwall();
  381. ManaCenter.SkillAmt++;
  382. UseTimer = NewDuration - 1;
  383. UseA();
  384. UseB();
  385. ManaInfo.Show(string.Format("{0}{1}", Language.GetStr("UI", "J_Info1"), Language.GetStr("SkillName", ID)), 10f);
  386. },
  387. StaticsManager.ConsumeModule.Shop
  388. );
  389. }
  390. protected override void UseA()
  391. {
  392. BarBtn.interactable = false;
  393. if (UseTimer.Equal(-1))
  394. {
  395. AnnulA();
  396. }
  397. else
  398. {
  399. BarStatus = SkillStatus.Use;
  400. ManaCenter.UseList.Add(this);
  401. }
  402. ManaCenter.SkillPlus += NewPlus;
  403. ManaCenter.SkillPerson += NewPerson;
  404. ManaCenter.SkillPersonBuff += NewPersonBuff;
  405. ManaCenter.SkillCoinPerson += NewCoinPerson;
  406. if (!NewSkillCD.Equal(0))
  407. {
  408. for (int i = 0; i < ManaCenter.SkillList.Count; i++)
  409. {
  410. ManaCenter.SkillList[i].ReceiveCool(NewSkillCD, true, false);
  411. }
  412. }
  413. if (!NewSkillCdBuff.Equal(0))
  414. {
  415. for (int i = 0; i < ManaCenter.SkillList.Count; i++)
  416. {
  417. ManaCenter.SkillList[i].ReceiveCool(NewSkillCdBuff, true, true);
  418. }
  419. }
  420. }
  421. protected override void OnClick()
  422. {
  423. ManaAudio.PlayClip(Clip.BtnClip);
  424. ManaReso.Get("Fe_Info").TweenForCG();
  425. ManaReso.SetText("Fe_Tit", Name);
  426. ManaReso.SetSprite("Fe_Icon", Icon);
  427. if (ItemStatus == SkillStatus.Lock)
  428. {
  429. ManaReso.SetText("Fe_Lab0", "");
  430. ManaReso.SetText("Fe_Lab1", GetDescription(0));
  431. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab0"), Auxiliary.ImageParse(UnlockAheadCur), UnlockAheadAmt.ToString("0")));
  432. ManaReso.SetButtonEvent
  433. (
  434. "Fe_Btn",
  435. () =>
  436. {
  437. UnlockAhead();
  438. ManaReso.Get("Fe_Info").TweenBacCG();
  439. }
  440. );
  441. }
  442. else if (ItemStatus == SkillStatus.UnLock)
  443. {
  444. ManaReso.SetText("Fe_Lab0", "");
  445. ManaReso.SetText("Fe_Lab1", GetDescription(0));
  446. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab1"), Auxiliary.ImageParse(UnlockCur), UnlockAmt));
  447. ManaReso.SetButtonEvent
  448. (
  449. "Fe_Btn",
  450. () =>
  451. {
  452. Unlock();
  453. ManaReso.Get("Fe_Info").TweenBacCG();
  454. }
  455. );
  456. }
  457. else if (ItemStatus == SkillStatus.Upgrade)
  458. {
  459. ManaReso.SetText("Fe_Lab0", GetDescription(0));
  460. ManaReso.SetText("Fe_Lab1", GetDescription(1));
  461. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), Auxiliary.ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt)));
  462. ManaReso.SetButtonEvent
  463. (
  464. "Fe_Btn",
  465. () =>
  466. {
  467. Upgrade();
  468. ItemLab.text = GetDescription(0);
  469. ItemBtnLab.text = Language.GetStr("UI", "Fe_BtnLab2") + "\n" + Auxiliary.ImageParse(UpgradeCur) + Auxiliary.ShrinkNumberStr(NewUpgradeAmt);
  470. ManaReso.SetText("Fe_Tit", Name);
  471. ManaReso.SetText("Fe_Lab0", GetDescription(0));
  472. ManaReso.SetText("Fe_Lab1", GetDescription(1));
  473. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), Auxiliary.ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt)));
  474. }
  475. );
  476. }
  477. }
  478. protected override void UnlockAhead()
  479. {
  480. ManaCenter.Pay
  481. (
  482. ID,
  483. UnlockAheadAmt,
  484. UnlockAheadCur,
  485. () =>
  486. {
  487. if (UnlockCur == Current.Free)
  488. {
  489. Unlock();
  490. }
  491. else
  492. {
  493. ManaAudio.PlayClip(Clip.SkillClip);
  494. ItemStatus = SkillStatus.UnLock;
  495. }
  496. },
  497. StaticsManager.ConsumeModule.Shop
  498. );
  499. }
  500. }