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 (Tab != SkillTab.Null) //有技能条 { #region MyRegion if (ItemStatus == SkillStatus.Upgrade) //可以使用 { BarBk0.SetActive(false); BarBk1.SetActive(true); BarBtn.interactable = true; BarLab.text = ""; } else if (ItemStatus == SkillStatus.Buy) //需要购买 { BarBk0.SetActive(false); BarBk1.SetActive(true); BarBtn.interactable = true; BarLab.text = ""; } else //未解锁 { BarBk0.SetActive(false); BarBk1.SetActive(true); BarBtn.interactable = false; BarLab.text = ""; BarBk1.material = ManaReso.Load("Gray", Folder.Shader); } #endregion } else //没有技能条 { #region MyRegion BarBk0.SetActive(false); BarBk1.SetActive(true); BarBtn.interactable = true; BarLab.text = ""; #endregion } } else if (_BarStatus == SkillStatus.Use) { ManaData.UsingList.Add(this); } else { throw new Exception(); } } } public new SkillStatus ItemStatus { get { return _ItemStatus; } set { _ItemStatus = value; if (Tab == SkillTab.Null) //该技能不生成技能条 { return; } if (_ItemStatus == SkillStatus.Lock) { ItemBtnLab.text = string.Format("提前解锁\n等级{0}", UnlockLv); } else if (_ItemStatus == SkillStatus.UnLock) { ItemBtnLab.text = string.Format("解锁"); } else if (_ItemStatus == SkillStatus.Upgrade) { ItemBtnLab.text = string.Format("升级"); BarStatus = SkillStatus.Buy; } else { throw new Exception(_ItemStatus.ToString()); } } } public SkillStatus _BarStatus; #endregion public BigSkill(XmlAttributeCollection attributes) : base(attributes) { SkillIndex = IntParse(attributes[4].Value); SkillType = SkillType.BigSkill; } 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 = (float)CoolTimer / CD; if (CoolTimer <= 0) { BarStatus = SkillStatus.Buy; ManaData.CoolList.Remove(this); return true; } else { return false; } } public override void RegistValue(double elapse, List> ffList) { BarBtn.onClick.AddListener(Use); BarBk1.sprite = ManaReso.Load(Icon + "副", Folder.Skill); NewPlus = Plus; NewPerson = Person; NewSkillCD = SkillCD; NewDuration = Duration; NewCoinOnce = CoinOnce; NewSkillCdBuff = SkillCdBuff; NewPersonBuff = PersonBuff; NewCoinPerson = CoinPerson; NewUpgradeAmt = UpgradeAmt; NewCoinOnceBuff = CoinOnceBuff; if (!string.IsNullOrEmpty(UpgradeFml)) { for (int i = 0; i < Level; i++) { NewUpgradeAmt = FmlParse(UpgradeFml, NewUpgradeAmt); } } 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 (Tab != SkillTab.Null) { ItemTit.text = Name; ItemLab.text = GetDescription(0); ItemBtn.onClick.AddListener(OnClick); } if (_ItemStatus == SkillStatus.Lock || _ItemStatus == SkillStatus.UnLock) { BarBk1.material = ManaReso.Load("Gray", Folder.Shader); } else { BarBk1.material = null; } if (_ItemStatus == SkillStatus.Upgrade) { ManaLog.Log(string.Format("初始化{0} 等级 : {1}", Name, Level)); ShowSkillBar(); } if (_BarStatus == SkillStatus.Use) { Effect(); if (UsingTimer < elapse) { if (ffList.Count > 0) { if (UsingTimer < ManaData.CircleTimer) { ffList[0].UniqueAdd(this); } else { int ffCircle = 1 + Mathf.FloorToInt((float)((UsingTimer - ManaData.CircleTimer) / ManaData.CircleTime)); ffList[ffCircle].UniqueAdd(this); } } } else { ManaLog.Log(string.Format("初始化{0} 等级 : {1}", Name, Level)); UsingTimer -= elapse; BarLab.color = new Color(38 / 255f, 155 / 255f, 1, 1); } } else if (_BarStatus == SkillStatus.Cool) { CoolTimer -= elapse; } ItemStatus = ItemStatus; BarStatus = BarStatus; } public override void ReceiveCool(float amt, bool isCurrent, bool isBuff) { if (!ReduceCD) { return; } if (isCurrent) //减少当前值 { if (isBuff) //按比例减少 { CoolTimer -= CD * amt; } else //按数值减少 { CoolTimer -= amt; } } else //减少最大值 { if (isBuff) //按比例减少 { CdBuff -= amt; } else //按数值减少 { CD -= amt; } } } private void ShowSkillBar() { if (!ManaData.SkillBar) { ManaReso.Get("Fa_Scrr").TweenForRect(); ManaData.SkillBar = true; if (ManaReso.Get("Fa_Garden").gameObject.activeSelf) { ManaReso.SetActive("Ff_SkillBar", true); } } } public override void RegistReference() { BarLab = ManaReso.Get(string.Format("F_SkillLab{0}", SkillIndex - 1)); BarBk0 = ManaReso.Get(string.Format("F_SkillBk{0}0", SkillIndex - 1)); BarBk1 = ManaReso.Get(string.Format("F_SkillBk{0}1", SkillIndex - 1)); BarBtn = BarBk1.GetComponent