BigSkill.cs 15 KB

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