BigSkill.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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;
  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. BarLab.text = string.Format("{0} : {1}", timeSpan.Minutes.ToString("00"), timeSpan.Seconds.ToString("00"));
  90. if (UseTimer <= 0)
  91. {
  92. AnnulA();
  93. return true;
  94. }
  95. else
  96. {
  97. return false;
  98. }
  99. }
  100. public override bool DoCool()
  101. {
  102. CoolTimer -= Time.deltaTime;
  103. TimeSpan timeSpan = new TimeSpan(0, 0, 0, Mathf.CeilToInt(CoolTimer));
  104. BarLab.text = string.Format("{0} : {1}", timeSpan.Minutes.ToString("00"), timeSpan.Seconds.ToString("00"));
  105. BarBk0.fillAmount = CoolTimer / CD;
  106. if (CoolTimer <= 0)
  107. {
  108. BarLab.text = "";
  109. BarStatus = SkillStatus.Buy;
  110. return true;
  111. }
  112. else
  113. {
  114. return false;
  115. }
  116. }
  117. public override void Reactive()
  118. {
  119. if (BarStatus == SkillStatus.Use)
  120. {
  121. AnnulB();
  122. ManaCenter.UseList.Remove(this);
  123. }
  124. else if (BarStatus == SkillStatus.Cool)
  125. {
  126. ManaCenter.CoolList.Remove(this);
  127. }
  128. }
  129. public override void RegistValue(float elapse, List<List<Skill>> useList, XmlAttributeCollection attribute)
  130. {
  131. Level = int.Parse(attribute[4].Value);
  132. UseTimer = float.Parse(attribute[6].Value);
  133. CoolTimer = float.Parse(attribute[5].Value);
  134. BarBk1.material = Shortcut.GrayMat;
  135. BarStatus_ = (SkillStatus)Enum.Parse(typeof(SkillStatus), attribute[3].Value);
  136. ItemStatus_ = (SkillStatus)Enum.Parse(typeof(SkillStatus), attribute[2].Value);
  137. NewPlus = Plus;
  138. NewPerson = Person;
  139. NewSkillCD = SkillCD;
  140. NewDuration = Duration;
  141. NewCoinOnce = CoinOnce;
  142. NewSkillCdBuff = SkillCdBuff;
  143. NewPersonBuff = PersonBuff;
  144. NewCoinPerson = CoinPerson;
  145. NewUpgradeAmt = UpgradeAmt;
  146. NewCoinOnceBuff = CoinOnceBuff;
  147. BarBk1.sprite = Icon;
  148. BarBtn.onClick.RemoveAllListeners();
  149. BarBtn.onClick.AddListener(Buy);
  150. if (SkillTab != SkillTab.Null)
  151. {
  152. ItemLab.text = GetDescription(0);
  153. ItemBtn.onClick.RemoveAllListeners();
  154. ItemBtn.onClick.AddListener(OnClick);
  155. for (int i = 0; i < Level - 1; i++)
  156. {
  157. NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString());
  158. }
  159. UpgradeValue(ref NewPlus, Plus, UpgradePlus, Level - 1);
  160. UpgradeValue(ref NewPersonBuff, PersonBuff, UpgradePerson, Level - 1);
  161. UpgradeValue(ref NewCoinOnceBuff, UpgradeCoinOnce, Level - 1);
  162. UpgradeSkillCdBuff(ref NewSkillCdBuff, UpgradeCD, Level - 1);
  163. UpgradeValue(ref NewPerson, Person, UpgradePerson, Level - 1);
  164. UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, Level - 1);
  165. UpgradeValue(ref NewDuration, Duration, UpgradeDuration, Level - 1);
  166. UpgradeValue(ref NewCoinOnce, CoinOnce, UpgradeCoinOnce, Level - 1);
  167. UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, Level - 1);
  168. }
  169. if (BarStatus_ == SkillStatus.Use)
  170. {
  171. UseA();
  172. if (UseTimer < elapse)
  173. {
  174. if (useList.Count > 0)
  175. {
  176. if (UseTimer < ManaCenter.CircleTimer)
  177. {
  178. useList[0].UniqueAdd(this);
  179. }
  180. else
  181. {
  182. int circle = 1 + Mathf.FloorToInt((UseTimer - ManaCenter.CircleTimer) / ManaCenter.CircleTime);
  183. useList[circle].UniqueAdd(this);
  184. }
  185. }
  186. }
  187. else
  188. {
  189. UseTimer -= elapse;
  190. BarBk1.SetActive(true);
  191. }
  192. }
  193. else if (BarStatus_ == SkillStatus.Cool)
  194. {
  195. CoolTimer -= elapse;
  196. ManaCenter.CoolList.Add(this);
  197. }
  198. if (BarStatus_ != SkillStatus.UnLock)
  199. {
  200. BarBk1.material = null;
  201. }
  202. if (ItemStatus_ == SkillStatus.UnLock)
  203. {
  204. ManaUI.UpdateHint();
  205. }
  206. BarStatus = BarStatus;
  207. ItemStatus = ItemStatus;
  208. }
  209. public override void ReceiveCool(float amt, bool current, bool buff)
  210. {
  211. if (!CoolLock)
  212. {
  213. return;
  214. }
  215. if (current)
  216. {
  217. if (BarStatus != SkillStatus.Cool)
  218. {
  219. return;
  220. }
  221. if (buff)
  222. {
  223. CoolTimer -= CD * amt;
  224. }
  225. else
  226. {
  227. CoolTimer -= amt;
  228. }
  229. }
  230. else
  231. {
  232. if (buff)
  233. {
  234. CdBuff = 1 - amt;
  235. }
  236. else
  237. {
  238. CD -= amt;
  239. }
  240. }
  241. }
  242. public override void UpdateStatus()
  243. {
  244. if (!ManaCenter.Complete)
  245. {
  246. return;
  247. }
  248. if (ManaCenter.Level >= UnlockLv)
  249. {
  250. if (SkillTab == SkillTab.Null)
  251. {
  252. if (BarStatus == SkillStatus.UnLock)
  253. {
  254. Unlock();
  255. }
  256. }
  257. else
  258. {
  259. if (ItemStatus == SkillStatus.Lock)
  260. {
  261. if (UnlockCur == Current.Free)
  262. {
  263. Unlock();
  264. }
  265. else
  266. {
  267. ItemStatus = SkillStatus.UnLock;
  268. ManaUI.UpdateHint();
  269. }
  270. }
  271. }
  272. }
  273. }
  274. public override void RegistReference()
  275. {
  276. base.RegistReference();
  277. BarLab = ManaReso.Get<Text>(string.Format("F_SkillLab{0}", BarIndex));
  278. BarBk0 = ManaReso.Get<Image>(string.Format("F_SkillBk{0}0", BarIndex));
  279. BarBk1 = ManaReso.Get<Image>(string.Format("F_SkillBk{0}1", BarIndex));
  280. BarBtn = BarBk1.GetComponent<Button>();
  281. }
  282. protected void Unlock()
  283. {
  284. ManaCenter.Pay
  285. (
  286. ID,
  287. UnlockAmt,
  288. UnlockCur,
  289. () =>
  290. {
  291. ManaAudio.PlayClip(Clip.SkillClip);
  292. BarStatus = SkillStatus.Buy;
  293. ItemStatus = SkillStatus.Upgrade;
  294. if (UnlockCur != Current.Free)
  295. {
  296. ManaUI.UpdateHint();
  297. }
  298. Level = 1;
  299. BarBk1.material = null;
  300. }
  301. );
  302. }
  303. protected void Upgrade()
  304. {
  305. ManaCenter.Pay
  306. (
  307. ID,
  308. NewUpgradeAmt,
  309. UpgradeCur,
  310. () =>
  311. {
  312. ManaAudio.PlayClip(Clip.SkillClip);
  313. Level++;
  314. if (BarStatus == SkillStatus.Use)
  315. {
  316. AnnulB();
  317. }
  318. NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString("0.00"));
  319. UpgradeValue(ref NewPlus, Plus, UpgradePlus, 1);
  320. UpgradeValue(ref NewPersonBuff, PersonBuff, UpgradePerson, 1);
  321. UpgradeValue(ref NewCoinOnceBuff, UpgradeCoinOnce, 1);
  322. UpgradeSkillCdBuff(ref NewSkillCdBuff, UpgradeCD, 1);
  323. UpgradeValue(ref NewPerson, Person, UpgradePerson, 1);
  324. UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, 1);
  325. UpgradeValue(ref NewDuration, Duration, UpgradeDuration, 1);
  326. UpgradeValue(ref NewCoinOnce, CoinOnce, UpgradeCoinOnce, 1);
  327. UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, 1);
  328. if (BarStatus == SkillStatus.Use)
  329. {
  330. UseA();
  331. }
  332. }
  333. );
  334. }
  335. protected override void Buy()
  336. {
  337. if (!ManaServer.Connect)
  338. {
  339. ManaReso.Get("Fg_Reconnect").TweenForCG();
  340. return;
  341. }
  342. ManaCenter.Pay
  343. (
  344. ID,
  345. UseAmt,
  346. BuyCur,
  347. () =>
  348. {
  349. ManaAudio.PlayClip(Clip.SkillClip);
  350. ManaReso.GetLightwall();
  351. ManaCenter.SkillAmt++;
  352. UseTimer = NewDuration;
  353. BarStatus = SkillStatus.Use;
  354. UseA();
  355. UseB();
  356. ManaInfo.Show(string.Format("{0}{1}", Language.GetStr("UI", "J_Info1"), Language.GetStr("SkillName", ID)), 10f);
  357. }
  358. );
  359. }
  360. protected override void UseA()
  361. {
  362. BarBtn.interactable = false;
  363. ManaCenter.UseList.Add(this);
  364. ManaCenter.SkillPlus += NewPlus;
  365. ManaCenter.SkillPerson += NewPerson;
  366. ManaCenter.SkillPersonBuff += NewPersonBuff;
  367. ManaCenter.SkillCoinPerson += NewCoinPerson;
  368. if (!NewSkillCD.Equal(0))
  369. {
  370. for (int i = 0; i < ManaCenter.SkillList.Count; i++)
  371. {
  372. ManaCenter.SkillList[i].ReceiveCool(NewSkillCD, true, false);
  373. }
  374. }
  375. if (!NewSkillCdBuff.Equal(0))
  376. {
  377. for (int i = 0; i < ManaCenter.SkillList.Count; i++)
  378. {
  379. ManaCenter.SkillList[i].ReceiveCool(NewSkillCdBuff, true, true);
  380. }
  381. }
  382. }
  383. protected override void OnClick()
  384. {
  385. ManaAudio.PlayClip(Clip.BtnClip);
  386. ManaReso.Get("Fe_Info").TweenForCG();
  387. ManaReso.SetText("Fe_Tit", Name);
  388. ManaReso.SetSprite("Fe_Icon", Icon);
  389. if (ItemStatus == SkillStatus.Lock)
  390. {
  391. ManaReso.SetText("Fe_Lab0", "");
  392. ManaReso.SetText("Fe_Lab1", GetDescription(0));
  393. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab0"), ImageParse(UnlockAheadCur), UnlockAheadAmt));
  394. ManaReso.SetButtonEvent
  395. (
  396. "Fe_Btn",
  397. () =>
  398. {
  399. UnlockAhead();
  400. ManaReso.Get("Fe_Info").TweenBacCG();
  401. }
  402. );
  403. }
  404. else if (ItemStatus == SkillStatus.UnLock)
  405. {
  406. ManaReso.SetText("Fe_Lab0", "");
  407. ManaReso.SetText("Fe_Lab1", GetDescription(0));
  408. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab1"), ImageParse(UnlockCur), UnlockAmt));
  409. ManaReso.SetButtonEvent
  410. (
  411. "Fe_Btn",
  412. () =>
  413. {
  414. Unlock();
  415. ManaReso.Get("Fe_Info").TweenBacCG();
  416. }
  417. );
  418. }
  419. else if (ItemStatus == SkillStatus.Upgrade)
  420. {
  421. ManaReso.SetText("Fe_Lab0", GetDescription(0));
  422. ManaReso.SetText("Fe_Lab1", GetDescription(1));
  423. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt)));
  424. ManaReso.SetButtonEvent
  425. (
  426. "Fe_Btn",
  427. () =>
  428. {
  429. Upgrade();
  430. ItemLab.text = GetDescription(0);
  431. ItemBtnLab.text = Language.GetStr("UI", "Fe_BtnLab2") + "\n" + ImageParse(UpgradeCur) + Auxiliary.ShrinkNumberStr(NewUpgradeAmt);
  432. ManaReso.SetText("Fe_Tit", Name);
  433. ManaReso.SetText("Fe_Lab0", GetDescription(0));
  434. ManaReso.SetText("Fe_Lab1", GetDescription(1));
  435. ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt)));
  436. }
  437. );
  438. }
  439. }
  440. protected override void UnlockAhead()
  441. {
  442. ManaCenter.Pay
  443. (
  444. ID,
  445. UnlockAheadAmt,
  446. UnlockAheadCur,
  447. () =>
  448. {
  449. if (UnlockCur == Current.Free)
  450. {
  451. Unlock();
  452. }
  453. else
  454. {
  455. ManaAudio.PlayClip(Clip.SkillClip);
  456. ItemStatus = SkillStatus.UnLock;
  457. }
  458. }
  459. );
  460. }
  461. }