BigSkill.cs 16 KB

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