123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695 |
- 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 变量
- #region 配置
- public int SkillIndex;
- #endregion
- 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);
-
- ManaData.CoolList.Add(this);
- }
- else if (_BarStatus == SkillStatus.Buy)
- {
- if (SkillTab != SkillTab.Null && ItemStatus != SkillStatus.Upgrade)
- {
- BarBk0.SetActive(false);
- BarBk1.SetActive(true);
- BarBtn.interactable = false;
- BarLab.text = "";
- }
- else
- {
- BarBk0.SetActive(false);
- BarBk1.SetActive(true);
- BarBtn.interactable = true;
- BarLab.text = "";
- }
- }
- else if (_BarStatus == SkillStatus.Use)
- {
-
- }
- else
- {
- throw new Exception();
- }
- }
- }
- public new SkillStatus ItemStatus
- {
- get { return _ItemStatus; }
- set
- {
- _ItemStatus = value;
- if (SkillTab == SkillTab.Null)
- {
- return;
- }
- if (_ItemStatus == SkillStatus.Lock)
- {
- ManaText.Add(ItemBtnLab, new LanStr("UI", "Fe_BtnLab0"), "\n", new LanStr("UI", "Fe_BtnLab4"), UnlockLv);
- }
- else if (_ItemStatus == SkillStatus.UnLock)
- {
- ManaText.Add(ItemBtnLab, new LanStr("UI", "Fe_BtnLab1"));
- }
- else if (_ItemStatus == SkillStatus.Upgrade)
- {
- ManaText.Add(ItemTit, new LanStr("SkillName", _Name), " ", Level.ToString());
- ManaText.Add(ItemBtnLab, new LanStr("UI", "Fe_BtnLab2"));
- }
- else
- {
- throw new Exception(_ItemStatus.ToString());
- }
- }
- }
- public SkillStatus _BarStatus;
- #endregion
- public BigSkill(XmlAttributeCollection attribute) : base(attribute)
- {
- SkillIndex = IntParse(attribute[4].Value);
- SkillType = SkillType.BigSkill;
- }
- public override void Annul()
- {
- CoolTimer = CD * (1 + CdBuff);
-
- BarLab.color = Color.white;
- BarStatus = SkillStatus.Cool;
- AnnulConti();
- ManaDebug.Log(string.Format("技能结束 <color=red>{0}</color>", Name));
- }
- public override void AnnulConti()
- {
- ManaData.SkillPlus -= NewPlus;
- ManaData.SkillPerson -= NewPerson;
- ManaData.SkillPersonBuff -= NewPersonBuff;
- ManaData.SkillCoinPerson -= NewCoinPerson;
- if (Math.Abs(NewSkillCD) > 0.0005f)
- {
- for (int i = 0; i < ManaData.SkillList.Count; i++)
- {
- ManaData.SkillList[i].ReceiveCool(-NewSkillCD, true, false);
- }
- }
- if (Math.Abs(NewSkillCdBuff) > 0.0005f)
- {
- for (int i = 0; i < ManaData.SkillList.Count; i++)
- {
- ManaData.SkillList[i].ReceiveCool(-NewSkillCdBuff, true, true);
- }
- }
- }
- public override bool DoUse()
- {
- UseTimer -= Time.deltaTime;
-
- BarLab.text = UseTimer.ToString("0.0");
- if (UseTimer <= 0)
- {
- Annul();
- ManaData.UseList.Remove(this);
- return true;
- }
- else
- {
- return false;
- }
- }
- public override bool DoCool()
- {
- CoolTimer -= Time.deltaTime;
- TimeSpan timeSpan = new TimeSpan(0, 0, 0, (int)CoolTimer);
- BarLab.text = string.Format("{0} : {1}", timeSpan.Minutes, timeSpan.Seconds);
- BarBk0.fillAmount = CoolTimer / CD;
- if (CoolTimer <= 0)
- {
- BarStatus = SkillStatus.Buy;
- ManaDebug.Log(string.Format("技能<color=red>{0}</color>已冷却", Name));
- ManaData.CoolList.Remove(this);
- return true;
- }
- else
- {
- return false;
- }
- }
- public override void RegistValue(float elapse, List<List<Skill>> ffList, XmlAttributeCollection attribute)
- {
- Level = int.Parse(attribute[4].Value);
- UseTimer = float.Parse(attribute[6].Value);
- CoolTimer = float.Parse(attribute[5].Value);
-
- _ItemStatus = (SkillStatus)Enum.Parse(typeof(SkillStatus), attribute[2].Value);
- _BarStatus = (SkillStatus)Enum.Parse(typeof(SkillStatus), attribute[3].Value);
-
- BarBtn.onClick.AddListener(Buy);
- BarBk1.sprite = ManaReso.Load<Sprite>(Icon + "副", Folder.Skill);
-
- NewPlus = Plus;
- NewPerson = Person;
- NewSkillCD = SkillCD;
- NewDuration = Duration;
- NewCoinOnce = CoinOnce;
- NewSkillCdBuff = SkillCdBuff;
- NewPersonBuff = PersonBuff;
- NewCoinPerson = CoinPerson;
- NewUpgradeAmt = UpgradeAmt;
- NewCoinOnceBuff = CoinOnceBuff;
-
- if (SkillTab == SkillTab.Null)
- {
- BarBk1.material = null;
- }
- else
- {
- ManaText.Add(ItemTit, new LanStr("SkillName", _Name));
- ItemLab.text = Description(0);
- ItemBtn.onClick.AddListener(OnClick);
- for (int i = 0; i < Level; i++)
- {
- NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString());
- }
- UpgradeValue(ref NewPlus, Plus, UpgradePlus, Level);
- UpgradeValue(ref NewSkillCdBuff, UpgradeCD, Level);
- UpgradeValue(ref NewPersonBuff, PersonBuff, UpgradePerson, Level);
- UpgradeValue(ref NewCoinOnceBuff, UpgradeCoinOnce, Level);
- UpgradeValue(ref NewPerson, Person, UpgradePerson, Level);
- UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, Level);
- UpgradeValue(ref NewDuration, Duration, UpgradeDuration, Level);
- UpgradeValue(ref NewCoinOnce, CoinOnce, UpgradeCoinOnce, Level);
- UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, Level);
- if (_ItemStatus == SkillStatus.Upgrade)
- {
- ShowSkillBar();
- ManaDebug.Log(string.Format("技能<color=red>{0}</color>已解锁 等级 : {1}", Name, Level));
- }
- if (_BarStatus == SkillStatus.Use)
- {
- UseConti();
- if (UseTimer < elapse)
- {
- if (ffList.Count > 0)
- {
- if (UseTimer < ManaData.CircleTimer)
- {
- ffList[0].UniqueAdd(this);
- }
- else
- {
- int ffCircle = 1 + Mathf.FloorToInt(((UseTimer - ManaData.CircleTimer) / ManaData.CircleTime));
- ffList[ffCircle].UniqueAdd(this);
- }
- }
- }
- else
- {
- UseTimer -= elapse;
- ManaData.UseList.Add(this);
- BarBk1.SetActive(true);
- BarLab.color = Color.blue;
- }
- }
- else if (_BarStatus == SkillStatus.Cool)
- {
- CoolTimer -= elapse;
- }
- }
-
- ItemStatus = ItemStatus;
- BarStatus = BarStatus;
- }
- public override void ReceiveCool(float amt, bool current, bool buff)
- {
- if (!ReduceCD)
- {
- return;
- }
-
- if (current)
- {
- if (BarStatus != SkillStatus.Cool)
- {
- return;
- }
- if (buff)
- {
- CoolTimer -= CD * amt;
- }
- else
- {
- CoolTimer -= amt;
- }
- }
- else
- {
- if (buff)
- {
- CdBuff -= amt;
- }
- else
- {
- CD -= amt;
- }
- }
- }
- public override void RegistReference()
- {
- base.RegistReference();
- BarLab = ManaReso.Get<Text>(string.Format("F_SkillLab{0}", SkillIndex - 1));
- BarBk0 = ManaReso.Get<Image>(string.Format("F_SkillBk{0}0", SkillIndex - 1));
- BarBk1 = ManaReso.Get<Image>(string.Format("F_SkillBk{0}1", SkillIndex - 1));
- BarBtn = BarBk1.GetComponent<Button>();
- }
- private void ShowSkillBar()
- {
- if (!ManaData.SkillBar)
- {
- ManaData.SkillBar = true;
- ManaReso.Get("Fa_Scrr").TweenForRect();
- if (ManaReso.Get("Fa_Garden").gameObject.activeSelf)
- {
- ManaReso.SetActive("Ff_SkillBar", true);
- }
- }
- }
- protected override void Buy()
- {
- if (ManaTutorial.TutorialA)
- {
- TutorialBuy();
- }
- else
- {
- RegularBuy();
- }
- }
- protected override void Unlock()
- {
- if (ManaData.Pay(UnlockAmt, UnlockCur))
- {
- ShowSkillBar();
-
- ItemStatus = SkillStatus.Upgrade;
- if (SkillTab != SkillTab.Null)
- {
- ItemStatus = SkillStatus.Upgrade;
- }
-
- ManaDebug.Log(string.Format("技能<color=red>{0}</color>已解锁", Name));
- }
- }
- protected override void Upgrade()
- {
- if (ManaTutorial.TutorialA || ManaTutorial.TutorialB && ManaData.Level >= 200)
- {
- TutorialUpgrade();
- }
- else
- {
- RegularUpgrade();
- }
- }
- protected override void UnlockAhead()
- {
- if (ItemStatus != SkillStatus.Lock)
- {
- ManaDebug.Log("您并不需要提前解锁");
- return;
- }
- if (ManaData.Pay(UnlockAheadAmt, UnlockAheadCur))
- {
- ShowSkillBar();
- ItemStatus = SkillStatus.Upgrade;
- ManaReso.Get("Fe_Info").TweenBacCG();
- ManaDebug.Log(string.Format("技能<color=red>{0}</color>已解锁", Name));
- }
- }
- private void TutorialBuy()
- {
- ManaTutorial.EndStep9();
- ManaData.Skill++;
- UseTimer = NewDuration;
- ManaData.UseList.Add(this);
- if (Math.Abs(Duration) < 0.0005f)
- {
- BarStatus = SkillStatus.Cool;
- }
- else
- {
- BarStatus = SkillStatus.Use;
- BarLab.color = Color.blue;
- }
- UseConti();
- UseImmed();
- #region 调试输出
- StringBuilder strb = new StringBuilder();
- strb.AppendFormat("使用技能 : <color=red>{0}</color>", Name);
- if (Math.Abs(NewPlus) > 0.0005f)
- {
- strb.AppendFormat(" 收入加成<color=red>+{0}%</color>", NewPlus*100);
- }
- if (Math.Abs(NewPerson) > 0.0005f)
- {
- strb.AppendFormat(" 参观人次<color=red>+{0}</color>", NewPerson);
- }
- if (Math.Abs(NewPersonBuff) > 0.0005f)
- {
- strb.AppendFormat(" 参观人次<color=red>+{0}%</color>", NewPersonBuff*100);
- }
- if (Math.Abs(NewCoinPerson) > 0.0005f)
- {
- strb.AppendFormat(" 每次金币<color=red>+{0}</color>", NewCoinPerson);
- }
- if (Math.Abs(NewSkillCD) > 0.0005f)
- {
- strb.AppendFormat(" 减少冷却<color=red>{0}</color>", NewSkillCD);
- }
- if (Math.Abs(NewSkillCdBuff) > 0.0005f)
- {
- strb.AppendFormat(" 减少冷却<color=red>{0}%</color>", NewSkillCdBuff*100);
- }
- if (Math.Abs(NewCoinOnce) > 0.0005f)
- {
- strb.AppendFormat(" 获得金币<color=red>{0}</color>", NewCoinOnce);
- }
- if (Math.Abs(NewCoinOnceBuff) > 0.0005f)
- {
- strb.AppendFormat(" 获得金币<color=red>{0}</color>", ManaData.Person*ManaData.CoinPerson*ManaData.CircleTime*NewCoinOnceBuff);
- }
- if (Math.Abs(DiamondOnce) > 0.0005f)
- {
- strb.AppendFormat(" 获得钻石<color=red>{0}</color>", DiamondOnce);
- }
- if (Math.Abs(NewDuration) > 0.0005f)
- {
- strb.AppendFormat(" 持续时间<color=red>{0}</color>秒", NewDuration);
- }
- else
- {
- strb.Append(" <color=red>永久有效</color>");
- }
- ManaDebug.Log(strb.ToString());
- #endregion
- }
- private void RegularBuy()
- {
- if (ManaData.Connect == false)
- {
- ManaReso.Get("Fg_Reconnect").TweenForCG();
- return;
- }
- if (ManaData.Pay(UseAmt, BuyCur))
- {
- ManaData.Skill++;
- UseTimer = NewDuration;
- ManaData.UseList.Add(this);
- if (Math.Abs(Duration) < 0.0005f)
- {
- BarStatus = SkillStatus.Cool;
- }
- else
- {
- BarStatus = SkillStatus.Use;
- BarLab.color = Color.blue;
- }
- UseConti();
- UseImmed();
- #region 调试输出
- StringBuilder strb = new StringBuilder();
- strb.AppendFormat("使用技能 : <color=red>{0}</color>", Name);
- if (Math.Abs(NewPlus) > 0.0005f)
- {
- strb.AppendFormat(" 收入加成<color=red>+{0}%</color>", NewPlus * 100);
- }
- if (Math.Abs(NewPerson) > 0.0005f)
- {
- strb.AppendFormat(" 参观人次<color=red>+{0}</color>", NewPerson);
- }
- if (Math.Abs(NewPersonBuff) > 0.0005f)
- {
- strb.AppendFormat(" 参观人次<color=red>+{0}%</color>", NewPersonBuff * 100);
- }
- if (Math.Abs(NewCoinPerson) > 0.0005f)
- {
- strb.AppendFormat(" 每次金币<color=red>+{0}</color>", NewCoinPerson);
- }
- if (Math.Abs(NewSkillCD) > 0.0005f)
- {
- strb.AppendFormat(" 减少冷却<color=red>{0}</color>", NewSkillCD);
- }
- if (Math.Abs(NewSkillCdBuff) > 0.0005f)
- {
- strb.AppendFormat(" 减少冷却<color=red>{0}%</color>", NewSkillCdBuff * 100);
- }
- if (Math.Abs(NewCoinOnce) > 0.0005f)
- {
- strb.AppendFormat(" 获得金币<color=red>{0}</color>", NewCoinOnce);
- }
- if (Math.Abs(NewCoinOnceBuff) > 0.0005f)
- {
- strb.AppendFormat(" 获得金币<color=red>{0}</color>", ManaData.Person * ManaData.CoinPerson * ManaData.CircleTime * NewCoinOnceBuff);
- }
- if (Math.Abs(DiamondOnce) > 0.0005f)
- {
- strb.AppendFormat(" 获得钻石<color=red>{0}</color>", DiamondOnce);
- }
- if (Math.Abs(NewDuration) > 0.0005f)
- {
- strb.AppendFormat(" 持续时间<color=red>{0}</color>秒", NewDuration);
- }
- else
- {
- strb.Append(" <color=red>永久有效</color>");
- }
- ManaDebug.Log(strb.ToString());
- #endregion
- }
- }
- private void TutorialUpgrade()
- {
- if (Level == 0)
- {
- BarStatus = SkillStatus.Buy;
- BarBk1.material = null;
- return;
- }
- Level++;
- if (BarStatus == SkillStatus.Use)
- {
- AnnulConti();
- }
- NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString());
- UpgradeValue(ref NewPlus, Plus, UpgradePlus, 1);
- UpgradeValue(ref NewSkillCdBuff, UpgradeCD, 1);
- UpgradeValue(ref NewPersonBuff, PersonBuff, UpgradePerson, 1);
- UpgradeValue(ref NewCoinOnceBuff, UpgradeCoinOnce, 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);
- ManaText.Add(ItemTit, new LanStr("SkillName", _Name), " ", Level.ToString());
- ItemLab.text = Description(0);
- ManaReso.SetText("Fe_Lab0", Description(0));
- ManaReso.SetText("Fe_Lab1", Description(1));
- ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), ImageParse(UpgradeCur), NewUpgradeAmt));
- ManaDebug.Log(string.Format("<color=red>{0}</color> 升级 : {1}", Name, Level));
- if (BarStatus == SkillStatus.Use)
- {
- UseConti();
- }
- }
- private void RegularUpgrade()
- {
- if (ManaData.Pay(NewUpgradeAmt, UpgradeCur))
- {
- if (Level == 0)
- {
- BarStatus = SkillStatus.Buy;
- BarBk1.material = null;
- return;
- }
- Level++;
- if (BarStatus == SkillStatus.Use)
- {
- AnnulConti();
- }
- NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString());
- UpgradeValue(ref NewPlus, Plus, UpgradePlus, 1);
- UpgradeValue(ref NewSkillCdBuff, UpgradeCD, 1);
- UpgradeValue(ref NewPersonBuff, PersonBuff, UpgradePerson, 1);
- UpgradeValue(ref NewCoinOnceBuff, UpgradeCoinOnce, 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);
- ManaText.Add(ItemTit, new LanStr("SkillName", _Name), " ", Level.ToString());
- ItemLab.text = Description(0);
- ManaReso.SetText("Fe_Lab0", Description(0));
- ManaReso.SetText("Fe_Lab1", Description(1));
- ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab2"), ImageParse(UpgradeCur), NewUpgradeAmt));
- ManaDebug.Log(string.Format("<color=red>{0}</color> 升级 : {1}", Name, Level));
- if (BarStatus == SkillStatus.Use)
- {
- UseConti();
- }
- }
- }
- }
|