BigSkill.cs 19 KB

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