BigSkill.cs 18 KB

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