BigSkill.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  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 Config
  11. public int BigSkillIndex;
  12. public Text Text;
  13. public Image BK0;
  14. public Image Bk1;
  15. public Button Button;
  16. public SkillStatus BarStatus
  17. {
  18. get { return barStatus; }
  19. set
  20. {
  21. barStatus = value;
  22. if (barStatus == SkillStatus.Cool)
  23. {
  24. BK0.SetActive(true);
  25. Bk1.SetActive(false);
  26. }
  27. else if (barStatus == SkillStatus.UnLock)
  28. {
  29. BK0.SetActive(false);
  30. Bk1.SetActive(true);
  31. }
  32. else if (barStatus == SkillStatus.Buy)
  33. {
  34. BK0.SetActive(false);
  35. Bk1.SetActive(true);
  36. Button.interactable = true;
  37. }
  38. }
  39. }
  40. public SkillStatus barStatus;
  41. public override SkillStatus ItemStatus
  42. {
  43. get { return itemStatus; }
  44. set
  45. {
  46. itemStatus = value;
  47. if (SkillTab == SkillTab.Null)
  48. {
  49. return;
  50. }
  51. if (itemStatus == SkillStatus.Lock)
  52. {
  53. LanguageManager.Add(ButtonTitle, new MulLanStr(LanguageLabel.UI__Fe_BtnLab0), "\n", new MulLanStr(LanguageLabel.UI__Fe_BtnLab4), UnlockLv);
  54. }
  55. else if (itemStatus == SkillStatus.UnLock)
  56. {
  57. LanguageManager.Add(ButtonTitle, new MulLanStr(LanguageLabel.UI__Fe_BtnLab1), "\n", Auxiliary.ImageParse(UnlockCur), UnlockAmt.ToString("0"));
  58. }
  59. else if (itemStatus == SkillStatus.Upgrade)
  60. {
  61. LanguageManager.Add(ButtonTitle, new MulLanStr(LanguageLabel.UI__Fe_BtnLab2), "\n", Auxiliary.ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt));
  62. }
  63. }
  64. }
  65. public static int WatchADSkillID = 7;
  66. public static List<Text> BigSkillTexts = new List<Text>();
  67. public static List<Image> BigSkillBk0s = new List<Image>();
  68. public static List<Image> BigSkillBk1s = new List<Image>();
  69. #endregion
  70. public BigSkill(XmlAttributeCollection attribute) : base(attribute)
  71. {
  72. BigSkillIndex = Auxiliary.StringToInt(attribute[4].Value,0);
  73. SkillType = SkillType.BigSkill;
  74. }
  75. public override void AnnulEffect()
  76. {
  77. CoolTimer = CD * CdBuff - 1;
  78. BarStatus = SkillStatus.Cool;
  79. Manager.CoolSkillList.Add(this);
  80. AnnulBuff();
  81. }
  82. public override void AnnulBuff()
  83. {
  84. Manager.SkillPlus -= NewPlus;
  85. Manager.SkillPerson -= NewPerson;
  86. Manager.SkillPersonBuff -= NewPersonBuff;
  87. Manager.SkillCoinPerson -= NewCoinPerson;
  88. }
  89. public override bool DoUpdate()
  90. {
  91. UseTimer -= Time.deltaTime;
  92. TimeSpan timeSpan = new TimeSpan(0, 0, 0, Mathf.CeilToInt(UseTimer));
  93. if (timeSpan.Hours >= 1)
  94. {
  95. Text.text = string.Format("{0} : {1}", timeSpan.Hours.ToString("00"), timeSpan.Minutes.ToString("00"));
  96. }
  97. else
  98. {
  99. Text.text = string.Format("{0} : {1}", timeSpan.Minutes.ToString("00"), timeSpan.Seconds.ToString("00"));
  100. }
  101. if (UseTimer <= 0)
  102. {
  103. AnnulEffect();
  104. return true;
  105. }
  106. else
  107. {
  108. return false;
  109. }
  110. }
  111. public override bool DoCD()
  112. {
  113. CoolTimer -= Time.deltaTime;
  114. TimeSpan timeSpan = new TimeSpan(0, 0, 0, Mathf.CeilToInt(CoolTimer));
  115. if (timeSpan.Hours >= 1)
  116. {
  117. Text.text = string.Format("{0} : {1}", timeSpan.Hours.ToString("00"), timeSpan.Minutes.ToString("00"));
  118. }
  119. else
  120. {
  121. Text.text = string.Format("{0} : {1}", timeSpan.Minutes.ToString("00"), timeSpan.Seconds.ToString("00"));
  122. }
  123. BK0.fillAmount = CoolTimer / CD;
  124. if (CoolTimer <= 0)
  125. {
  126. Text.text = "";
  127. BarStatus = SkillStatus.Buy;
  128. return true;
  129. }
  130. else
  131. {
  132. return false;
  133. }
  134. }
  135. public override void Reactive()
  136. {
  137. if (BarStatus == SkillStatus.Use)
  138. {
  139. AnnulBuff();
  140. Manager.UsingSkillList.Remove(this);
  141. }
  142. else if (BarStatus == SkillStatus.Cool)
  143. {
  144. Manager.CoolSkillList.Remove(this);
  145. }
  146. }
  147. public override void Init(bool firstInit, float elapse, List<List<Skill>> useList, XmlAttributeCollection attribute)
  148. {
  149. Level = int.Parse(attribute[4].Value);
  150. UseTimer = float.Parse(attribute[6].Value);
  151. CoolTimer = float.Parse(attribute[5].Value);
  152. Bk1.material = Lib.GrayMat;
  153. barStatus = (SkillStatus)Enum.Parse(typeof(SkillStatus), attribute[3].Value);
  154. itemStatus = (SkillStatus)Enum.Parse(typeof(SkillStatus), attribute[2].Value);
  155. NewPlus = Plus;
  156. NewPerson = Person;
  157. NewSkillCD = SkillCD;
  158. NewDuration = Duration;
  159. NewCoinOnce = CoinOnce;
  160. NewSkillCdBuff = SkillCdBuff;
  161. NewPersonBuff = PersonBuff;
  162. NewCoinPerson = CoinPerson;
  163. NewUpgradeAmt = UpgradeAmt;
  164. NewCoinOnceBuff = CoinOnceBuff;
  165. Bk1.sprite = Icon;
  166. Button.onClick.RemoveAllListeners();
  167. Button.onClick.AddListener(Buy);
  168. if (SkillTab != SkillTab.Null)
  169. {
  170. for (int i = 0; i < Level - 1; i++)
  171. {
  172. NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString());
  173. }
  174. if (barStatus != SkillStatus.Lock && barStatus != SkillStatus.UnLock)
  175. {
  176. SkillIcon.material = null;
  177. UpgradeValue(ref NewPlus, UpgradePlus, Level - 1);
  178. UpgradeValue(ref NewPersonBuff, UpgradePerson, Level - 1);
  179. UpgradeValue(ref NewCoinOnceBuff, UpgradeCoinOnce, Level - 1);
  180. UpgradeSkillCdBuff(ref NewSkillCdBuff, UpgradeCD, Level - 1);
  181. UpgradeValue(ref NewPerson, Person, UpgradePerson, Level - 1);
  182. UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, Level - 1);
  183. UpgradeValue(ref NewDuration, Duration, UpgradeDuration, Level - 1);
  184. UpgradeValue(ref NewCoinOnce, CoinOnce, UpgradeCoinOnce, Level - 1);
  185. UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, Level - 1);
  186. }
  187. else
  188. {
  189. SkillIcon.material = Lib.GrayMat;
  190. }
  191. button.onClick.RemoveAllListeners();
  192. button.onClick.AddListener(OnClick);
  193. DescriptionText.text = GetDescription(0);
  194. }
  195. if (barStatus == SkillStatus.Use)
  196. {
  197. GetBuff();
  198. if (UseTimer < elapse)
  199. {
  200. Manager.UsingSkillList.Remove(this);
  201. if (useList.Count > 0)
  202. {
  203. if (UseTimer < Manager.IncomeCircleTimer)
  204. {
  205. useList[0].UniqueAdd(this);
  206. }
  207. else
  208. {
  209. int circle = 1 + Mathf.FloorToInt((UseTimer - Manager.IncomeCircleTimer) / Manager.IncomeCircleTime);
  210. useList[circle].UniqueAdd(this);
  211. }
  212. }
  213. }
  214. else
  215. {
  216. UseTimer -= elapse;
  217. Bk1.SetActive(true);
  218. }
  219. }
  220. else if (barStatus == SkillStatus.Cool)
  221. {
  222. CoolTimer -= elapse;
  223. Manager.CoolSkillList.Add(this);
  224. }
  225. if (barStatus != SkillStatus.UnLock)
  226. {
  227. Bk1.material = null;
  228. }
  229. if (itemStatus == SkillStatus.UnLock)
  230. {
  231. UIManager.UpdateManagePanelHint();
  232. }
  233. BarStatus = BarStatus;
  234. ItemStatus = ItemStatus;
  235. }
  236. public override void Cool(float amt, bool current, bool buff)
  237. {
  238. if (!CoolLock)
  239. {
  240. return;
  241. }
  242. if (current)
  243. {
  244. if (BarStatus != SkillStatus.Cool)
  245. {
  246. return;
  247. }
  248. if (buff)
  249. {
  250. CoolTimer -= CD * amt;
  251. }
  252. else
  253. {
  254. CoolTimer -= amt;
  255. }
  256. }
  257. else
  258. {
  259. if (buff)
  260. {
  261. CdBuff = 1 - amt;
  262. }
  263. else
  264. {
  265. CD -= amt;
  266. }
  267. }
  268. }
  269. public override void UpdateStatus()
  270. {
  271. if (!Manager.Inited)
  272. {
  273. return;
  274. }
  275. if (Manager.GardenLevel >= UnlockLv)
  276. {
  277. if (SkillTab == SkillTab.Null)
  278. {
  279. if (BarStatus == SkillStatus.UnLock)
  280. {
  281. Unlock();
  282. }
  283. }
  284. else
  285. {
  286. if (ItemStatus == SkillStatus.Lock)
  287. {
  288. if (UnlockCur == Current.Free)
  289. {
  290. Unlock();
  291. }
  292. else
  293. {
  294. ItemStatus = SkillStatus.UnLock;
  295. UIManager.UpdateManagePanelHint();
  296. }
  297. }
  298. }
  299. }
  300. }
  301. public override void RegistReference()
  302. {
  303. base.RegistReference();
  304. if (BigSkillBk0s.Count == 0)
  305. {
  306. BigSkillTexts.Add(ResourceManager.Get<Text>(CanvasLabel.F_SkillLab1));
  307. BigSkillTexts.Add(ResourceManager.Get<Text>(CanvasLabel.F_SkillLab2));
  308. BigSkillTexts.Add(ResourceManager.Get<Text>(CanvasLabel.F_SkillLab3));
  309. BigSkillTexts.Add(ResourceManager.Get<Text>(CanvasLabel.F_SkillLab4));
  310. BigSkillBk0s.Add(ResourceManager.Get<Image>(CanvasLabel.F_SkillBk10));
  311. BigSkillBk0s.Add(ResourceManager.Get<Image>(CanvasLabel.F_SkillBk20));
  312. BigSkillBk0s.Add(ResourceManager.Get<Image>(CanvasLabel.F_SkillBk30));
  313. BigSkillBk0s.Add(ResourceManager.Get<Image>(CanvasLabel.F_SkillBk40));
  314. BigSkillBk1s.Add(ResourceManager.Get<Image>(CanvasLabel.F_SkillBk11));
  315. BigSkillBk1s.Add(ResourceManager.Get<Image>(CanvasLabel.F_SkillBk21));
  316. BigSkillBk1s.Add(ResourceManager.Get<Image>(CanvasLabel.F_SkillBk31));
  317. BigSkillBk1s.Add(ResourceManager.Get<Image>(CanvasLabel.F_SkillBk41));
  318. }
  319. Text = BigSkillTexts[BigSkillIndex-1];
  320. BK0 = BigSkillBk0s[BigSkillIndex-1];
  321. Bk1 = BigSkillBk1s[BigSkillIndex-1];
  322. Button = Bk1.GetComponent<Button>();
  323. }
  324. protected void Unlock()
  325. {
  326. Manager.Pay
  327. (
  328. FullID,
  329. UnlockAmt,
  330. UnlockCur,
  331. () =>
  332. {
  333. AudioManager.PlayClip(AudioLabel.UseSkill);
  334. BarStatus = SkillStatus.Buy;
  335. ItemStatus = SkillStatus.Upgrade;
  336. if (SkillTab != SkillTab.Null)
  337. {
  338. SkillIcon.material = null;
  339. }
  340. if (UnlockCur != Current.Free)
  341. {
  342. UIManager.UpdateManagePanelHint();
  343. }
  344. Level = 1;
  345. Bk1.material = null;
  346. },
  347. StaticsManager.ItemID.解锁技能,
  348. StaticsManager.ConsumeModule.Shop
  349. );
  350. }
  351. protected void Upgrade()
  352. {
  353. Manager.Pay
  354. (
  355. FullID,
  356. NewUpgradeAmt,
  357. UpgradeCur,
  358. () =>
  359. {
  360. AudioManager.PlayClip(AudioLabel.UseSkill);
  361. Level++;
  362. if (BarStatus == SkillStatus.Use)
  363. {
  364. AnnulBuff();
  365. Manager.UsingSkillList.Remove(this);
  366. }
  367. NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString("0.00"));
  368. UpgradeValue(ref NewPlus, UpgradePlus, 1);
  369. UpgradeValue(ref NewPersonBuff, UpgradePerson, 1);
  370. UpgradeValue(ref NewCoinOnceBuff, UpgradeCoinOnce, 1);
  371. UpgradeSkillCdBuff(ref NewSkillCdBuff, UpgradeCD, 1);
  372. UpgradeValue(ref NewPerson, Person, UpgradePerson, 1);
  373. UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, 1);
  374. UpgradeValue(ref NewDuration, Duration, UpgradeDuration, 1);
  375. UpgradeValue(ref NewCoinOnce, CoinOnce, UpgradeCoinOnce, 1);
  376. UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, 1);
  377. if (BarStatus == SkillStatus.Use)
  378. {
  379. GetBuff();
  380. }
  381. },
  382. StaticsManager.ItemID.升级技能,
  383. StaticsManager.ConsumeModule.Shop
  384. );
  385. }
  386. protected override void Buy()
  387. {
  388. if (ID == WatchADSkillID)
  389. {
  390. StaticsManager.GetInstance().AdClicked(0);
  391. }
  392. if (!HttpManager.IsConnect)
  393. {
  394. ResourceManager.Get(CanvasLabel.Fg_Reconnect).TweenForCG();
  395. return;
  396. }
  397. Manager.Pay
  398. (
  399. FullID,
  400. UseAmt,
  401. BuyCur,
  402. () =>
  403. {
  404. AudioManager.PlayClip(AudioLabel.UseSkill);
  405. ResourceManager.GetLightwall();
  406. Manager.UseSkillAmt++;
  407. UseTimer = NewDuration - 1;
  408. GetBuff();
  409. GetAward();
  410. InfoBoxManager.GardenInfoBox.Display(string.Format("{0}{1}", Language.GetStr(LanguageLabel.UI__J_Info1), Language.GetStr(LanguageLabel.CombineLanguageLabel(LanguageLabel.SkillName, FullID))), 10f, Color.white, ResourceManager.LoadSprite(ResourceLabel.Atlas, Folder.Atlas));
  411. },
  412. StaticsManager.ItemID.使用技能,
  413. StaticsManager.ConsumeModule.Shop
  414. );
  415. }
  416. protected override void GetBuff()
  417. {
  418. Button.interactable = false;
  419. if (UseTimer.Equal(-1))
  420. {
  421. AnnulEffect();
  422. }
  423. else
  424. {
  425. BarStatus = SkillStatus.Use;
  426. Manager.UsingSkillList.Add(this);
  427. }
  428. Manager.SkillPlus += NewPlus;
  429. Manager.SkillPerson += NewPerson;
  430. Manager.SkillPersonBuff += NewPersonBuff;
  431. Manager.SkillCoinPerson += NewCoinPerson;
  432. if (!NewSkillCD.Equal(0))
  433. {
  434. for (int i = 0; i < Manager.SkillList.Count; i++)
  435. {
  436. Manager.SkillList[i].Cool(NewSkillCD, true, false);
  437. }
  438. }
  439. if (!NewSkillCdBuff.Equal(0))
  440. {
  441. for (int i = 0; i < Manager.SkillList.Count; i++)
  442. {
  443. Manager.SkillList[i].Cool(NewSkillCdBuff, true, true);
  444. }
  445. }
  446. }
  447. protected override void OnClick()
  448. {
  449. AudioManager.PlayClip(AudioLabel.ClickButton);
  450. ResourceManager.Get(CanvasLabel.Fe_Info).TweenForCG();
  451. ResourceManager.SetText(CanvasLabel.Fe_Tit, Name);
  452. ResourceManager.SetSprite(CanvasLabel.Fe_Icon, Icon);
  453. if (ItemStatus == SkillStatus.Lock)
  454. {
  455. ResourceManager.SetText(CanvasLabel.Fe_Lab0, "");
  456. ResourceManager.SetText(CanvasLabel.Fe_Lab1, GetDescription(0));
  457. ResourceManager.SetText(CanvasLabel.Fe_BtnLab, string.Format("{0}({1}{2:0})", Language.GetStr(LanguageLabel.UI__Fe_BtnLab0), Auxiliary.ImageParse(UnlockAheadCur), UnlockAheadAmt.ToString("0")));
  458. ResourceManager.SetButtonEvent
  459. (
  460. CanvasLabel.Fe_Btn,
  461. () =>
  462. {
  463. UnlockAhead();
  464. ResourceManager.Get(CanvasLabel.Fe_Info).TweenBacCG();
  465. }
  466. );
  467. }
  468. else if (ItemStatus == SkillStatus.UnLock)
  469. {
  470. ResourceManager.SetText(CanvasLabel.Fe_Lab0, "");
  471. ResourceManager.SetText(CanvasLabel.Fe_Lab1, GetDescription(0));
  472. ResourceManager.SetText(CanvasLabel.Fe_BtnLab, string.Format("{0}({1}{2:0})", Language.GetStr(LanguageLabel.UI__Fe_BtnLab1), Auxiliary.ImageParse(UnlockCur), UnlockAmt));
  473. ResourceManager.SetButtonEvent
  474. (
  475. CanvasLabel.Fe_Btn,
  476. () =>
  477. {
  478. Unlock();
  479. ResourceManager.Get(CanvasLabel.Fe_Info).TweenBacCG();
  480. }
  481. );
  482. }
  483. else if (ItemStatus == SkillStatus.Upgrade)
  484. {
  485. ResourceManager.SetText(CanvasLabel.Fe_Lab0, GetDescription(0));
  486. ResourceManager.SetText(CanvasLabel.Fe_Lab1, GetDescription(1));
  487. ResourceManager.SetText(CanvasLabel.Fe_BtnLab, string.Format("{0}({1}{2:0})", Language.GetStr(LanguageLabel.UI__Fe_BtnLab2), Auxiliary.ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt)));
  488. ResourceManager.SetButtonEvent
  489. (
  490. CanvasLabel.Fe_Btn,
  491. () =>
  492. {
  493. Upgrade();
  494. DescriptionText.text = GetDescription(0);
  495. ButtonTitle.text = Language.GetStr(LanguageLabel.UI__Fe_BtnLab2) + "\n" + Auxiliary.ImageParse(UpgradeCur) + Auxiliary.ShrinkNumberStr(NewUpgradeAmt);
  496. ResourceManager.SetText(CanvasLabel.Fe_Tit, Name);
  497. ResourceManager.SetText(CanvasLabel.Fe_Lab0, GetDescription(0));
  498. ResourceManager.SetText(CanvasLabel.Fe_Lab1, GetDescription(1));
  499. ResourceManager.SetText(CanvasLabel.Fe_BtnLab, string.Format("{0}({1}{2:0})", Language.GetStr(LanguageLabel.UI__Fe_BtnLab2), Auxiliary.ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt)));
  500. }
  501. );
  502. }
  503. }
  504. protected override void UnlockAhead()
  505. {
  506. Manager.Pay
  507. (
  508. FullID,
  509. UnlockAheadAmt,
  510. UnlockAheadCur,
  511. () =>
  512. {
  513. if (UnlockCur == Current.Free)
  514. {
  515. Unlock();
  516. }
  517. else
  518. {
  519. AudioManager.PlayClip(AudioLabel.UseSkill);
  520. ItemStatus = SkillStatus.UnLock;
  521. }
  522. },
  523. StaticsManager.ItemID.提前解锁技能,
  524. StaticsManager.ConsumeModule.Shop
  525. );
  526. }
  527. }