123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618 |
- using UnityEngine;
- using UnityEngine.UI;
- using System;
- using System.Xml;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- public class BigSkill : Skill
- {
- #region 变量
- public int BarIndex;
- public Text BarLab;
- public Image BarBk0;
- public Image BarBk1;
- public Button BarBtn;
- public SkillStatus BarStatus
- {
- get { return BarStatus_; }
- set
- {
- BarStatus_ = value;
- if (BarStatus_ == SkillStatus.Cool)
- {
- BarBk0.SetActive(true);
- BarBk1.SetActive(false);
- }
- else if (BarStatus_ == SkillStatus.UnLock)
- {
- BarBk0.SetActive(false);
- BarBk1.SetActive(true);
- }
- else if (BarStatus_ == SkillStatus.Buy)
- {
- BarBk0.SetActive(false);
- BarBk1.SetActive(true);
-
- BarBtn.interactable = true;
- }
- }
- }
- public override SkillStatus ItemStatus
- {
- get { return ItemStatus_; }
- set
- {
- ItemStatus_ = value;
- if (SkillTab == SkillTab.Null)
- {
- return;
- }
- if (ItemStatus_ == SkillStatus.Lock)
- {
- ManaLan.Add(ItemBtnLab, new LanStr("UI", "Fe_BtnLab0"), "\n", new LanStr("UI", "Fe_BtnLab4"), UnlockLv);
- }
- else if (ItemStatus_ == SkillStatus.UnLock)
- {
- ManaLan.Add(ItemBtnLab, new LanStr("UI", "Fe_BtnLab1"), "\n", Auxiliary.ImageParse(UnlockCur), UnlockAmt.ToString("0"));
- }
- else if (ItemStatus_ == SkillStatus.Upgrade)
- {
- ManaLan.Add(ItemBtnLab, new LanStr("UI", "Fe_BtnLab2"), "\n", Auxiliary.ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt));
- }
- }
- }
- public SkillStatus BarStatus_;
- #endregion
- public BigSkill(XmlAttributeCollection attribute) : base(attribute)
- {
- BarIndex = Auxiliary.IntParse(attribute[4].Value,0);
- SkillType = SkillType.BigSkill;
- }
- public override void AnnulA()
- {
- CoolTimer = CD * CdBuff - 1;
- BarStatus = SkillStatus.Cool;
- ManaCenter.CoolList.Add(this);
- AnnulB();
- }
- public override void AnnulB()
- {
- ManaCenter.SkillPlus -= NewPlus;
- ManaCenter.SkillPerson -= NewPerson;
- ManaCenter.SkillPersonBuff -= NewPersonBuff;
- ManaCenter.SkillCoinPerson -= NewCoinPerson;
- }
- public override bool DoUse()
- {
- UseTimer -= Time.deltaTime;
- TimeSpan timeSpan = new TimeSpan(0, 0, 0, Mathf.CeilToInt(UseTimer));
- if (timeSpan.Hours >= 1)
- {
- BarLab.text = string.Format("{0} : {1}", timeSpan.Hours.ToString("00"), timeSpan.Minutes.ToString("00"));
- }
- else
- {
- BarLab.text = string.Format("{0} : {1}", timeSpan.Minutes.ToString("00"), timeSpan.Seconds.ToString("00"));
- }
- if (UseTimer <= 0)
- {
- AnnulA();
- return true;
- }
- else
- {
- return false;
- }
- }
- public override bool DoCool()
- {
- CoolTimer -= Time.deltaTime;
-
- TimeSpan timeSpan = new TimeSpan(0, 0, 0, Mathf.CeilToInt(CoolTimer));
-
- if (timeSpan.Hours >= 1)
- {
- BarLab.text = string.Format("{0} : {1}", timeSpan.Hours.ToString("00"), timeSpan.Minutes.ToString("00"));
- }
- else
- {
- BarLab.text = string.Format("{0} : {1}", timeSpan.Minutes.ToString("00"), timeSpan.Seconds.ToString("00"));
- }
- BarBk0.fillAmount = CoolTimer / CD;
- if (CoolTimer <= 0)
- {
- BarLab.text = "";
- BarStatus = SkillStatus.Buy;
- return true;
- }
- else
- {
- return false;
- }
- }
- public override void Reactive()
- {
- if (BarStatus == SkillStatus.Use)
- {
- AnnulB();
- ManaCenter.UseList.Remove(this);
- }
- else if (BarStatus == SkillStatus.Cool)
- {
- ManaCenter.CoolList.Remove(this);
- }
- }
- public override void RegistValue(bool firstRegist, float elapse, List<List<Skill>> useList, XmlAttributeCollection attribute)
- {
- Level = int.Parse(attribute[4].Value);
- UseTimer = float.Parse(attribute[6].Value);
- CoolTimer = float.Parse(attribute[5].Value);
-
- BarBk1.material = Lib.GrayMat;
- BarStatus_ = (SkillStatus)Enum.Parse(typeof(SkillStatus), attribute[3].Value);
- ItemStatus_ = (SkillStatus)Enum.Parse(typeof(SkillStatus), attribute[2].Value);
-
- NewPlus = Plus;
- NewPerson = Person;
- NewSkillCD = SkillCD;
- NewDuration = Duration;
- NewCoinOnce = CoinOnce;
- NewSkillCdBuff = SkillCdBuff;
- NewPersonBuff = PersonBuff;
- NewCoinPerson = CoinPerson;
- NewUpgradeAmt = UpgradeAmt;
- NewCoinOnceBuff = CoinOnceBuff;
- BarBk1.sprite = Icon;
- BarBtn.onClick.RemoveAllListeners();
- BarBtn.onClick.AddListener(Buy);
- if (SkillTab != SkillTab.Null)
- {
- for (int i = 0; i < Level - 1; i++)
- {
- NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString());
- }
-
- if (BarStatus_ != SkillStatus.Lock && BarStatus_ != SkillStatus.UnLock)
- {
- ItemIcon.material = null;
- UpgradeValue(ref NewPlus, UpgradePlus, Level - 1);
- UpgradeValue(ref NewPersonBuff, UpgradePerson, Level - 1);
- UpgradeValue(ref NewCoinOnceBuff, UpgradeCoinOnce, Level - 1);
- UpgradeSkillCdBuff(ref NewSkillCdBuff, UpgradeCD, Level - 1);
- UpgradeValue(ref NewPerson, Person, UpgradePerson, Level - 1);
- UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, Level - 1);
- UpgradeValue(ref NewDuration, Duration, UpgradeDuration, Level - 1);
- UpgradeValue(ref NewCoinOnce, CoinOnce, UpgradeCoinOnce, Level - 1);
- UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, Level - 1);
- }
- else
- {
- ItemIcon.material = Lib.GrayMat;
- }
- ItemBtn.onClick.RemoveAllListeners();
- ItemBtn.onClick.AddListener(OnClick);
- ItemLab.text = GetDescription(0);
- }
- if (BarStatus_ == SkillStatus.Use)
- {
- UseA();
- if (UseTimer < elapse)
- {
- ManaCenter.UseList.Remove(this);
- if (useList.Count > 0)
- {
- if (UseTimer < ManaCenter.CircleTimer)
- {
- useList[0].UniqueAdd(this);
- }
- else
- {
- int circle = 1 + Mathf.FloorToInt((UseTimer - ManaCenter.CircleTimer) / ManaCenter.CircleTime);
- useList[circle].UniqueAdd(this);
- }
- }
- }
- else
- {
- UseTimer -= elapse;
- BarBk1.SetActive(true);
- }
- }
- else if (BarStatus_ == SkillStatus.Cool)
- {
- CoolTimer -= elapse;
- ManaCenter.CoolList.Add(this);
- }
- if (BarStatus_ != SkillStatus.UnLock)
- {
- BarBk1.material = null;
- }
- if (ItemStatus_ == SkillStatus.UnLock)
- {
- ManaUI.UpdateHint();
- }
- BarStatus = BarStatus;
- ItemStatus = ItemStatus;
- }
- public override void ReceiveCool(float amt, bool current, bool buff)
- {
- if (!CoolLock)
- {
- return;
- }
-
- if (current)
- {
- if (BarStatus != SkillStatus.Cool)
- {
- return;
- }
- if (buff)
- {
- CoolTimer -= CD * amt;
- }
- else
- {
- CoolTimer -= amt;
- }
- }
- else
- {
- if (buff)
- {
- CdBuff = 1 - amt;
- }
- else
- {
- CD -= amt;
- }
- }
- }
- public override void UpdateStatus()
- {
- if (!ManaCenter.Complete)
- {
- return;
- }
- if (ManaCenter.Level >= UnlockLv)
- {
- if (SkillTab == SkillTab.Null)
- {
- if (BarStatus == SkillStatus.UnLock)
- {
- Unlock();
- }
- }
- else
- {
- if (ItemStatus == SkillStatus.Lock)
- {
- if (UnlockCur == Current.Free)
- {
- Unlock();
- }
- else
- {
- ItemStatus = SkillStatus.UnLock;
- ManaUI.UpdateHint();
- }
- }
- }
- }
- }
- public override void RegistReference()
- {
- base.RegistReference();
- BarLab = ManaReso.Get<Text>(string.Format("F_SkillLab{0}", BarIndex));
- BarBk0 = ManaReso.Get<Image>(string.Format("F_SkillBk{0}0", BarIndex));
- BarBk1 = ManaReso.Get<Image>(string.Format("F_SkillBk{0}1", BarIndex));
- BarBtn = BarBk1.GetComponent<Button>();
- }
- protected void Unlock()
- {
- ManaCenter.Pay
- (
- ID,
- UnlockAmt,
- UnlockCur,
- () =>
- {
- ManaAudio.PlayClip(Clip.SkillClip);
- BarStatus = SkillStatus.Buy;
- ItemStatus = SkillStatus.Upgrade;
- if (SkillTab != SkillTab.Null)
- {
- ItemIcon.material = null;
- }
- if (UnlockCur != Current.Free)
- {
- ManaUI.UpdateHint();
- }
- Level = 1;
- BarBk1.material = null;
- },
- StaticsManager.ItemID.解锁技能,
- StaticsManager.ConsumeModule.Shop
- );
- }
- protected void Upgrade()
- {
- ManaCenter.Pay
- (
- ID,
- NewUpgradeAmt,
- UpgradeCur,
- () =>
- {
- ManaAudio.PlayClip(Clip.SkillClip);
- Level++;
- if (BarStatus == SkillStatus.Use)
- {
- AnnulB();
- ManaCenter.UseList.Remove(this);
- }
- NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString("0.00"));
- UpgradeValue(ref NewPlus, UpgradePlus, 1);
- UpgradeValue(ref NewPersonBuff, UpgradePerson, 1);
- UpgradeValue(ref NewCoinOnceBuff, UpgradeCoinOnce, 1);
- UpgradeSkillCdBuff(ref NewSkillCdBuff, UpgradeCD, 1);
- UpgradeValue(ref NewPerson, Person, UpgradePerson, 1);
- UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, 1);
- UpgradeValue(ref NewDuration, Duration, UpgradeDuration, 1);
- UpgradeValue(ref NewCoinOnce, CoinOnce, UpgradeCoinOnce, 1);
- UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, 1);
- if (BarStatus == SkillStatus.Use)
- {
- UseA();
- }
- },
- StaticsManager.ItemID.升级技能,
- StaticsManager.ConsumeModule.Shop
- );
- }
- protected override void Buy()
- {
- if (!ManaServer.Connect)
- {
- ManaReso.Get("Fg_Reconnect").TweenForCG();
- return;
- }
- ManaCenter.Pay
- (
- ID,
- UseAmt,
- BuyCur,
- () =>
- {
- ManaAudio.PlayClip(Clip.SkillClip);
- ManaReso.GetLightwall();
- ManaCenter.SkillAmt++;
- UseTimer = NewDuration - 1;
- UseA();
- UseB();
- ManaInfo.Show(string.Format("{0}{1}", Language.GetStr("UI", "J_Info1"), Language.GetStr("SkillName", ID)), 10f);
- },
- StaticsManager.ItemID.使用技能,
- StaticsManager.ConsumeModule.Shop
- );
- }
- protected override void UseA()
- {
- BarBtn.interactable = false;
- if (UseTimer.Equal(-1))
- {
- AnnulA();
- }
- else
- {
- BarStatus = SkillStatus.Use;
- ManaCenter.UseList.Add(this);
- }
- ManaCenter.SkillPlus += NewPlus;
- ManaCenter.SkillPerson += NewPerson;
- ManaCenter.SkillPersonBuff += NewPersonBuff;
- ManaCenter.SkillCoinPerson += NewCoinPerson;
- if (!NewSkillCD.Equal(0))
- {
- for (int i = 0; i < ManaCenter.SkillList.Count; i++)
- {
- ManaCenter.SkillList[i].ReceiveCool(NewSkillCD, true, false);
- }
- }
- if (!NewSkillCdBuff.Equal(0))
- {
- for (int i = 0; i < ManaCenter.SkillList.Count; i++)
- {
- ManaCenter.SkillList[i].ReceiveCool(NewSkillCdBuff, true, true);
- }
- }
- }
- protected override void OnClick()
- {
- ManaAudio.PlayClip(Clip.BtnClip);
- ManaReso.Get("Fe_Info").TweenForCG();
- ManaReso.SetText("Fe_Tit", Name);
- ManaReso.SetSprite("Fe_Icon", Icon);
- if (ItemStatus == SkillStatus.Lock)
- {
- ManaReso.SetText("Fe_Lab0", "");
- ManaReso.SetText("Fe_Lab1", GetDescription(0));
- ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab0"), Auxiliary.ImageParse(UnlockAheadCur), UnlockAheadAmt.ToString("0")));
- ManaReso.SetButtonEvent
- (
- "Fe_Btn",
- () =>
- {
- UnlockAhead();
- ManaReso.Get("Fe_Info").TweenBacCG();
- }
- );
- }
- else if (ItemStatus == SkillStatus.UnLock)
- {
- ManaReso.SetText("Fe_Lab0", "");
- ManaReso.SetText("Fe_Lab1", GetDescription(0));
- ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab1"), Auxiliary.ImageParse(UnlockCur), UnlockAmt));
- ManaReso.SetButtonEvent
- (
- "Fe_Btn",
- () =>
- {
- Unlock();
- ManaReso.Get("Fe_Info").TweenBacCG();
- }
- );
- }
- else if (ItemStatus == SkillStatus.Upgrade)
- {
- ManaReso.SetText("Fe_Lab0", GetDescription(0));
- ManaReso.SetText("Fe_Lab1", GetDescription(1));
- ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), Auxiliary.ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt)));
-
- ManaReso.SetButtonEvent
- (
- "Fe_Btn",
- () =>
- {
- Upgrade();
- ItemLab.text = GetDescription(0);
- ItemBtnLab.text = Language.GetStr("UI", "Fe_BtnLab2") + "\n" + Auxiliary.ImageParse(UpgradeCur) + Auxiliary.ShrinkNumberStr(NewUpgradeAmt);
- ManaReso.SetText("Fe_Tit", Name);
- ManaReso.SetText("Fe_Lab0", GetDescription(0));
- ManaReso.SetText("Fe_Lab1", GetDescription(1));
- ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), Auxiliary.ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt)));
- }
- );
- }
- }
- protected override void UnlockAhead()
- {
- ManaCenter.Pay
- (
- ID,
- UnlockAheadAmt,
- UnlockAheadCur,
- () =>
- {
- if (UnlockCur == Current.Free)
- {
- Unlock();
- }
- else
- {
- ManaAudio.PlayClip(Clip.SkillClip);
- ItemStatus = SkillStatus.UnLock;
- }
- },
- StaticsManager.ItemID.提前解锁技能,
- StaticsManager.ConsumeModule.Shop
- );
- }
- }
|