BigSkill.cs 16 KB

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