BigSkill.cs 15 KB

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