BigSkill.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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", ImageParse(UnlockCur), UnlockAmt.ToString("0"));
  57. }
  58. else if (ItemStatus_ == SkillStatus.Upgrade)
  59. {
  60. ManaLan.Add(ItemBtnLab, new LanStr("UI", "Fe_BtnLab2"), "\n", 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(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 = Shortcut.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. ItemLab.text = GetDescription(0);
  167. ItemBtn.onClick.RemoveAllListeners();
  168. ItemBtn.onClick.AddListener(OnClick);
  169. for (int i = 0; i < Level - 1; i++)
  170. {
  171. NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString());
  172. }
  173. if (BarStatus_ == SkillStatus.Upgrade)
  174. {
  175. UpgradeValue(ref NewPlus, UpgradePlus, Level - 1);
  176. UpgradeValue(ref NewPersonBuff, UpgradePerson, Level - 1);
  177. UpgradeValue(ref NewCoinOnceBuff, UpgradeCoinOnce, Level - 1);
  178. UpgradeSkillCdBuff(ref NewSkillCdBuff, UpgradeCD, Level - 1);
  179. UpgradeValue(ref NewPerson, Person, UpgradePerson, Level - 1);
  180. UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, Level - 1);
  181. UpgradeValue(ref NewDuration, Duration, UpgradeDuration, Level - 1);
  182. UpgradeValue(ref NewCoinOnce, CoinOnce, UpgradeCoinOnce, Level - 1);
  183. UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, Level - 1);
  184. }
  185. }
  186. if (BarStatus_ == SkillStatus.Use)
  187. {
  188. UseA();
  189. if (UseTimer < elapse)
  190. {
  191. if (useList.Count > 0)
  192. {
  193. if (UseTimer < ManaCenter.CircleTimer)
  194. {
  195. useList[0].UniqueAdd(this);
  196. }
  197. else
  198. {
  199. int circle = 1 + Mathf.FloorToInt((UseTimer - ManaCenter.CircleTimer) / ManaCenter.CircleTime);
  200. useList[circle].UniqueAdd(this);
  201. }
  202. }
  203. }
  204. else
  205. {
  206. UseTimer -= elapse;
  207. BarBk1.SetActive(true);
  208. }
  209. }
  210. else if (BarStatus_ == SkillStatus.Cool)
  211. {
  212. CoolTimer -= elapse;
  213. ManaCenter.CoolList.Add(this);
  214. }
  215. if (BarStatus_ != SkillStatus.UnLock)
  216. {
  217. BarBk1.material = null;
  218. }
  219. if (ItemStatus_ == SkillStatus.UnLock)
  220. {
  221. ManaUI.UpdateHint();
  222. }
  223. BarStatus = BarStatus;
  224. ItemStatus = ItemStatus;
  225. }
  226. public override void ReceiveCool(float amt, bool current, bool buff)
  227. {
  228. if (!CoolLock)
  229. {
  230. return;
  231. }
  232. if (current)
  233. {
  234. if (BarStatus != SkillStatus.Cool)
  235. {
  236. return;
  237. }
  238. if (buff)
  239. {
  240. CoolTimer -= CD * amt;
  241. }
  242. else
  243. {
  244. CoolTimer -= amt;
  245. }
  246. }
  247. else
  248. {
  249. if (buff)
  250. {
  251. CdBuff = 1 - amt;
  252. }
  253. else
  254. {
  255. CD -= amt;
  256. }
  257. }
  258. }
  259. public override void UpdateStatus()
  260. {
  261. if (!ManaCenter.Complete)
  262. {
  263. return;
  264. }
  265. if (ManaCenter.Level >= UnlockLv)
  266. {
  267. if (SkillTab == SkillTab.Null)
  268. {
  269. if (BarStatus == SkillStatus.UnLock)
  270. {
  271. Unlock();
  272. }
  273. }
  274. else
  275. {
  276. if (ItemStatus == SkillStatus.Lock)
  277. {
  278. if (UnlockCur == Current.Free)
  279. {
  280. Unlock();
  281. }
  282. else
  283. {
  284. ItemStatus = SkillStatus.UnLock;
  285. ManaUI.UpdateHint();
  286. }
  287. }
  288. }
  289. }
  290. }
  291. public override void RegistReference()
  292. {
  293. base.RegistReference();
  294. BarLab = ManaReso.Get<Text>(string.Format("F_SkillLab{0}", BarIndex));
  295. BarBk0 = ManaReso.Get<Image>(string.Format("F_SkillBk{0}0", BarIndex));
  296. BarBk1 = ManaReso.Get<Image>(string.Format("F_SkillBk{0}1", BarIndex));
  297. BarBtn = BarBk1.GetComponent<Button>();
  298. }
  299. protected void Unlock()
  300. {
  301. ManaCenter.Pay
  302. (
  303. ID,
  304. UnlockAmt,
  305. UnlockCur,
  306. () =>
  307. {
  308. ManaAudio.PlayClip(Clip.SkillClip);
  309. BarStatus = SkillStatus.Buy;
  310. ItemStatus = SkillStatus.Upgrade;
  311. if (UnlockCur != Current.Free)
  312. {
  313. ManaUI.UpdateHint();
  314. }
  315. Level = 1;
  316. BarBk1.material = null;
  317. }
  318. );
  319. }
  320. protected void Upgrade()
  321. {
  322. ManaCenter.Pay
  323. (
  324. ID,
  325. NewUpgradeAmt,
  326. UpgradeCur,
  327. () =>
  328. {
  329. ManaAudio.PlayClip(Clip.SkillClip);
  330. Level++;
  331. if (BarStatus == SkillStatus.Use)
  332. {
  333. AnnulB();
  334. }
  335. NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString("0.00"));
  336. UpgradeValue(ref NewPlus, UpgradePlus, 1);
  337. UpgradeValue(ref NewPersonBuff, UpgradePerson, 1);
  338. UpgradeValue(ref NewCoinOnceBuff, UpgradeCoinOnce, 1);
  339. UpgradeSkillCdBuff(ref NewSkillCdBuff, UpgradeCD, 1);
  340. UpgradeValue(ref NewPerson, Person, UpgradePerson, 1);
  341. UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, 1);
  342. UpgradeValue(ref NewDuration, Duration, UpgradeDuration, 1);
  343. UpgradeValue(ref NewCoinOnce, CoinOnce, UpgradeCoinOnce, 1);
  344. UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, 1);
  345. if (BarStatus == SkillStatus.Use)
  346. {
  347. UseA();
  348. }
  349. }
  350. );
  351. }
  352. protected override void Buy()
  353. {
  354. if (!ManaServer.Connect)
  355. {
  356. ManaReso.Get("Fg_Reconnect").TweenForCG();
  357. return;
  358. }
  359. ManaCenter.Pay
  360. (
  361. ID,
  362. UseAmt,
  363. BuyCur,
  364. () =>
  365. {
  366. ManaAudio.PlayClip(Clip.SkillClip);
  367. ManaReso.GetLightwall();
  368. ManaCenter.SkillAmt++;
  369. UseTimer = NewDuration - 1;
  370. UseA();
  371. UseB();
  372. ManaInfo.Show(string.Format("{0}{1}", Language.GetStr("UI", "J_Info1"), Language.GetStr("SkillName", ID)), 10f);
  373. }
  374. );
  375. }
  376. protected override void UseA()
  377. {
  378. BarBtn.interactable = false;
  379. if (UseTimer.Equal(-1))
  380. {
  381. AnnulA();
  382. }
  383. else
  384. {
  385. BarStatus = SkillStatus.Use;
  386. ManaCenter.UseList.Add(this);
  387. }
  388. ManaCenter.SkillPlus += NewPlus;
  389. ManaCenter.SkillPerson += NewPerson;
  390. ManaCenter.SkillPersonBuff += NewPersonBuff;
  391. ManaCenter.SkillCoinPerson += NewCoinPerson;
  392. if (!NewSkillCD.Equal(0))
  393. {
  394. for (int i = 0; i < ManaCenter.SkillList.Count; i++)
  395. {
  396. ManaCenter.SkillList[i].ReceiveCool(NewSkillCD, true, false);
  397. }
  398. }
  399. if (!NewSkillCdBuff.Equal(0))
  400. {
  401. for (int i = 0; i < ManaCenter.SkillList.Count; i++)
  402. {
  403. ManaCenter.SkillList[i].ReceiveCool(NewSkillCdBuff, true, true);
  404. }
  405. }
  406. }
  407. protected override void OnClick()
  408. {
  409. ManaAudio.PlayClip(Clip.BtnClip);
  410. ManaReso.Get("Fe_Info").TweenForCG();
  411. ManaReso.SetText("Fe_Tit", Name);
  412. ManaReso.SetSprite("Fe_Icon", Icon);
  413. if (ItemStatus == SkillStatus.Lock)
  414. {
  415. ManaReso.SetText("Fe_Lab0", "");
  416. ManaReso.SetText("Fe_Lab1", GetDescription(0));
  417. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab0"), ImageParse(UnlockAheadCur), UnlockAheadAmt));
  418. ManaReso.SetButtonEvent
  419. (
  420. "Fe_Btn",
  421. () =>
  422. {
  423. UnlockAhead();
  424. ManaReso.Get("Fe_Info").TweenBacCG();
  425. }
  426. );
  427. }
  428. else if (ItemStatus == SkillStatus.UnLock)
  429. {
  430. ManaReso.SetText("Fe_Lab0", "");
  431. ManaReso.SetText("Fe_Lab1", GetDescription(0));
  432. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab1"), ImageParse(UnlockCur), UnlockAmt));
  433. ManaReso.SetButtonEvent
  434. (
  435. "Fe_Btn",
  436. () =>
  437. {
  438. Unlock();
  439. ManaReso.Get("Fe_Info").TweenBacCG();
  440. }
  441. );
  442. }
  443. else if (ItemStatus == SkillStatus.Upgrade)
  444. {
  445. ManaReso.SetText("Fe_Lab0", GetDescription(0));
  446. ManaReso.SetText("Fe_Lab1", GetDescription(1));
  447. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt)));
  448. ManaReso.SetButtonEvent
  449. (
  450. "Fe_Btn",
  451. () =>
  452. {
  453. Upgrade();
  454. ItemLab.text = GetDescription(0);
  455. ItemBtnLab.text = Language.GetStr("UI", "Fe_BtnLab2") + "\n" + ImageParse(UpgradeCur) + Auxiliary.ShrinkNumberStr(NewUpgradeAmt);
  456. ManaReso.SetText("Fe_Tit", Name);
  457. ManaReso.SetText("Fe_Lab0", GetDescription(0));
  458. ManaReso.SetText("Fe_Lab1", GetDescription(1));
  459. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt)));
  460. }
  461. );
  462. }
  463. }
  464. protected override void UnlockAhead()
  465. {
  466. ManaCenter.Pay
  467. (
  468. ID,
  469. UnlockAheadAmt,
  470. UnlockAheadCur,
  471. () =>
  472. {
  473. if (UnlockCur == Current.Free)
  474. {
  475. Unlock();
  476. }
  477. else
  478. {
  479. ManaAudio.PlayClip(Clip.SkillClip);
  480. ItemStatus = SkillStatus.UnLock;
  481. }
  482. }
  483. );
  484. }
  485. }