BigSkill.cs 15 KB

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