123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783 |
- using UnityEngine;
- using UnityEngine.UI;
- using System;
- using System.Xml;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- using Random = UnityEngine.Random;
- public class Ability : SkillRoot
- {
- #region Config
- #region 配置
- public float UnlockAheadAmt
- {
- get { return UnlockAheadBaseAmt + (UnlockLv - Manager.Level - 1)*UnlockAheadDeltaAmt; }
- }
- public override string FullIDPrefix
- {
- get { return "Ability"; }
- }
- public static string ElfAnim = "Elf";
- public static string ItemAnim = "Item";
- public float Person;
- public float SkillCD;
- public float CoinPerson;
- public double UpgradeAmt;
- public float Plus;
- public float PersonBuff;
- public float SkillCdBuff;
- public int UnlockLv;
- public float UnlockAmt;
- public float UnlockAheadBaseAmt;
- public float UnlockAheadDeltaAmt;
- public string UnlockPos;
- public Current UnlockCur;
- public Current UpgradeCur;
- public Current UnlockAheadCur;
- public string Label;
- public string Anim;
- public string UpgradeCD;
- public string UpgradeFml;
- public string UpgradePlus;
- public string UpgradePerson;
- #endregion
- public bool ElfLock = true;
- public string Elf;
- public string Item;
- public float NewPlus;
- public float NewPerson;
- public float NewSkillCD;
- public float NewSkillCdBuff;
- public float NewPersonBuff;
- public float NewCoinPerson;
- public double NewUpgradeAmt;
- public override SkillStatus ItemStatus
- {
- get { return ItemStatus_; }
- set
- {
- ItemStatus_ = value;
- if (ItemStatus_ == SkillStatus.Lock)
- {
- if (UnlockAheadCur == Current.Free)
- {
- ItemBtn.interactable = false;
- LanguageManager.Add(ItemBtnLab, new MulLanStr(LanguageLabel.UI__Fe_BtnLab1), "\n", new MulLanStr(LanguageLabel.UI__Fe_BtnLab4), UnlockLv.ToString());
- }
- else
- {
- ItemBtn.interactable = true;
- LanguageManager.Add(ItemBtnLab, new MulLanStr(LanguageLabel.UI__Fe_BtnLab0), "\n", new MulLanStr(LanguageLabel.UI__Fe_BtnLab4), UnlockLv.ToString());
- }
- }
- else if (ItemStatus_ == SkillStatus.UnLock)
- {
- ItemBtn.interactable = true;
- ItemBtnLab.text = Language.GetStr(LanguageLabel.UI__Fe_BtnLab1) + "\n" + Auxiliary.ImageParse(UnlockCur) + Auxiliary.ShrinkNumberStr(UnlockAmt);
- }
- else if (ItemStatus_ == SkillStatus.Upgrade)
- {
- ItemBtn.interactable = true;
- ItemBtnLab.text = Language.GetStr(LanguageLabel.UI__Fe_BtnLab2) + "\n" + Auxiliary.ImageParse(UpgradeCur) + Auxiliary.ShrinkNumberStr(NewUpgradeAmt);
- }
- }
- }
- #endregion
- public Ability(XmlAttributeCollection attribute)
- {
- #region 配置
- ID_ = int.Parse(attribute[0].Value);
- Icon_ = attribute[21].Value;
- Anim = attribute[22].Value;
- Label = attribute[23].Value;
- UnlockPos = attribute[13].Value;
- UpgradeCD = attribute[19].Value;
- UpgradeFml = attribute[16].Value;
- UpgradePlus = attribute[17].Value;
- UpgradePerson = attribute[18].Value;
- UnlockLv = Auxiliary.StringToInt(attribute[7].Value,0);
- ItemIndex = Auxiliary.StringToInt(attribute[3].Value,0);
- UnlockAmt = Auxiliary.StringToFloat(attribute[12].Value,0);
- UnlockAheadBaseAmt = Auxiliary.StringToFloat(attribute[10].Value,0);
- UnlockAheadDeltaAmt = Auxiliary.StringToFloat(attribute[9].Value, 0);
- SkillTab = SkillClassParse(attribute[2].Value);
- UpgradeAmt = UpgradeAmtParse(attribute[15].Value);
-
- UnlockCur = Auxiliary.CurrentParse(attribute[11].Value);
- UpgradeCur = Auxiliary.CurrentParse(attribute[14].Value);
- UnlockAheadCur = Auxiliary.CurrentParse(attribute[8].Value);
- ValueBuffParse(out Person, out PersonBuff, attribute[5].Value);
- ValueBuffParse(out SkillCD, out SkillCdBuff, attribute[6].Value);
- ValueBuffParse(out CoinPerson, out Plus, attribute[4].Value);
-
- #endregion
- SkillType = SkillType.Ability;
- }
- public void UnlockTab()
- {
- ResourceManager.Get<Graphic>(ObjectLabel.F_Elf).material = null;
- ResourceManager.Get<Graphic>(ObjectLabel.F_Store).material = null;
- ResourceManager.Get<Graphic>(ObjectLabel.F_Magic).material = null;
- ResourceManager.Get<Graphic>(ObjectLabel.F_ElfLab).material = null;
- ResourceManager.Get<Graphic>(ObjectLabel.F_StoreLab).material = null;
- ResourceManager.Get<Graphic>(ObjectLabel.F_MagicLab).material = null;
- ResourceManager.Get<Button>(ObjectLabel.F_Elf).interactable = true;
- ResourceManager.Get<Button>(ObjectLabel.F_Store).interactable = true;
- ResourceManager.Get<Button>(ObjectLabel.F_Magic).interactable = true;
- }
- public override void Reactive()
- {
- //if (Level > 0)
- //{
- // AnnulA();
- // AnnulB();
- //}
- }
- public override void Init(bool firstInit, float elapse, List<List<Skill>> useList, XmlAttributeCollection attribute)
- {
- if (!firstInit)
- {
- return;
- }
- Level = int.Parse(attribute[3].Value);
- ItemStatus_ = (SkillStatus)Enum.Parse(typeof(SkillStatus), attribute[2].Value);
- NewPlus = Plus;
- NewPerson = Person;
- NewSkillCD = SkillCD;
- NewSkillCdBuff = SkillCdBuff;
- NewPersonBuff = PersonBuff;
- NewCoinPerson = CoinPerson;
- NewUpgradeAmt = UpgradeAmt;
- if (FullID == "Ability1")
- {
- Manager.Level = Level;
- if (Level > 0)
- {
- UnlockTab();
- }
- }
- if (ItemStatus_ == SkillStatus.Lock || ItemStatus_ == SkillStatus.UnLock)
- {
- ItemIcon.material = Lib.GrayMat;
- }
- else
- {
- ItemIcon.material = null;
- }
- if (ItemStatus_ == SkillStatus.Upgrade)
- {
- for (int i = 0; i < Level - 1; i++)
- {
- NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString("0.00"));
- }
- UpgradeValue(ref NewPlus, UpgradePlus, Level - 1);
- UpgradeValue(ref NewPersonBuff, UpgradePerson, Level - 1);
- UpgradeSkillCdBuff(ref NewSkillCdBuff, UpgradeCD, Level - 1);
- UpgradeValue(ref NewPerson, Person, UpgradePerson, Level - 1);
- UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, Level - 1);
- UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, Level - 1);
- GetAward();
- GetSlot();
- }
- else if (ItemStatus_ == SkillStatus.UnLock)
- {
- UIManager.UpdateHint();
- }
- ItemStatus = ItemStatus;
- ItemBtn.onClick.RemoveAllListeners();
- ItemBtn.onClick.AddListener(OnClick);
- ItemLab.text = GetDescription(0);
- }
- public override void SwitchLanguage()
- {
- base.SwitchLanguage();
- ItemStatus = ItemStatus;
- }
- protected void GetAward()
- {
- if (ElfLock)
- {
- ElfLock = false;
- if (!string.IsNullOrEmpty(Anim))
- {
- if (Anim.Contains(ElfAnim))
- {
- string[] strings = Anim.Split(',');
- for (int i = 1; i < strings.Length; i++)
- {
- GardenManager.ElfList.Add(strings[i].ToEnum<ElfType>());
- }
- Elf = strings[1];
- }
- else if (Anim.Contains(ItemAnim))
- {
- string[] strings = Anim.Split(',');
- for (int i = 1; i < strings.Length; i++)
- {
- ResourceManager.Get(strings[i]).TweenForSr();
- }
- Item = strings[1];
- }
- }
- }
- Manager.Person += NewPerson;
- Manager.CoinPerson += NewCoinPerson;
- Manager.SkillPlus += NewPlus;
- Manager.SkillPersonBuff += NewPersonBuff;
-
- if (!NewSkillCD.Equal(0))
- {
- for (int i = 0; i < Manager.SkillList.Count; i++)
- {
- Manager.SkillList[i].ReceiveCool(NewSkillCD, false, false);
- }
- }
- if (!NewSkillCdBuff.Equal(0))
- {
- for (int i = 0; i < Manager.SkillList.Count; i++)
- {
- Manager.SkillList[i].ReceiveCool(NewSkillCdBuff, false, true);
- }
- }
- }
- protected void AddAchieve()
- {
- if (!string.IsNullOrEmpty(Elf))
- {
- Manager.ElfLevel++;
- }
- }
- protected void GetSlot()
- {
- for (int i = 0; i < Auxiliary.StringToInt(UnlockPos, 0); i++)
- {
- GardenManager.UnlockSlot();
- }
- }
- private int BannedSlotIndex = 4;
- protected void Zoom()
- {
- if (!string.IsNullOrEmpty(Elf))
- {
- if (GardenManager.PlantList.Count <= Garden.CurPage * GardenManager.TotalSlotAmtInOnePage)
- {
- return;
- }
-
- GardenManager.ElfTimer = Random.Range(GardenManager.MinElfTime, GardenManager.MaxElfTime);
- Slot zoomSlot = GardenManager.PlantList.Random(1, false, false, slot => { return slot.Index >= Garden.CurPage* GardenManager.TotalSlotAmtInOnePage; })[0];
- if (zoomSlot.Index% GardenManager.TotalSlotAmtInOnePage == BannedSlotIndex)
- {
- return;
- }
- Flower flower = zoomSlot.Flower;
- flower.GetElf(GardenManager.ElfList.Back(0), 0, 0, 0, 0);
- ResourceManager.Get(ObjectLabel.Fe_Info).TweenBacCG();
- ResourceManager.Get(ObjectLabel.F_Manage).TweenBacGra();
- TweenRoot tween = ResourceManager.Get(ObjectLabel.F_Manage0).GetTweenVec();
- tween.AddEventOnetime
- (
- EventType.BackwardFinish,
- () =>
- {
- ResourceManager.Get("MainCamera").Zoom2D(1.5f, 3f, 1, flower.ElfList.Back(0), Curve.EaseOutQuad);
- }
- );
- }
- else if (!string.IsNullOrEmpty(Item))
- {
- TweenRoot tween = ResourceManager.Get(Item).GetTweenSr();
- Vector3 pos = ResourceManager.Get(Item).position;
- pos.z = -2;
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ResourceManager.GetFirework(pos);
- }
- );
- ResourceManager.Get(ObjectLabel.Fe_Info).TweenBacCG();
- ResourceManager.Get(ObjectLabel.F_Manage).TweenBacGra();
- tween = ResourceManager.Get(ObjectLabel.F_Manage0).GetTweenVec();
- tween.AddEventOnetime
- (
- EventType.BackwardFinish,
- () =>
- {
- ResourceManager.Get("MainCamera").Zoom2D(3.5f, 3f, 1, ResourceManager.Get(Item), Curve.EaseOutQuad);
- }
- );
- }
- }
- protected void Unlock()
- {
- Manager.Pay
- (
- FullID,
- UnlockAmt,
- UnlockCur,
- () =>
- {
- UnlockSucceed();
- Zoom();
- if (FullID == "Ability1")
- {
- Manager.Level = 1;
- UnlockTab();
- }
- },
- StaticsManager.ItemID.解锁技能,
- StaticsManager.ConsumeModule.Shop
- );
- }
- public void UnlockSucceed()
- {
- AudioManager.PlayClip(Clip.SkillClip);
- ItemIcon.material = null;
- ItemStatus = SkillStatus.Upgrade;
- if (UnlockCur != Current.Free)
- {
- UIManager.UpdateHint();
- }
- Level = 1;
- GetAward();
- AddAchieve();
- GetSlot();
- }
- protected void OnClick()
- {
- AudioManager.PlayClip(Clip.BtnClip);
- ResourceManager.Get(ObjectLabel.Fe_Info).TweenForCG();
- ResourceManager.SetText(ObjectLabel.Fe_Tit, Name);
- ResourceManager.SetSprite(ObjectLabel.Fe_Icon, Icon);
- if (ItemStatus == SkillStatus.Lock)
- {
- ResourceManager.SetText(ObjectLabel.Fe_Lab0, "");
- ResourceManager.SetText(ObjectLabel.Fe_Lab1, GetDescription(0));
- ResourceManager.SetText(ObjectLabel.Fe_BtnLab, string.Format("{0}({1}{2:0})", Language.GetStr(LanguageLabel.UI__Fe_BtnLab0), Auxiliary.ImageParse(UnlockAheadCur), UnlockAheadAmt.ToString("0")));
- ResourceManager.SetButtonEvent
- (
- ObjectLabel.Fe_Btn,
- () =>
- {
- UnlockAhead();
- ResourceManager.Get(ObjectLabel.Fe_Info).TweenBacCG();
- }
- );
- }
- else if (ItemStatus == SkillStatus.UnLock)
- {
- ResourceManager.SetText(ObjectLabel.Fe_Lab0, "");
- ResourceManager.SetText(ObjectLabel.Fe_Lab1, GetDescription(0));
- ResourceManager.SetText(ObjectLabel.Fe_BtnLab, string.Format("{0}({1}{2:0})", Language.GetStr(LanguageLabel.UI__Fe_BtnLab1), Auxiliary.ImageParse(UnlockCur), UnlockAmt.ToString("0")));
-
- ResourceManager.SetButtonEvent
- (
- ObjectLabel.Fe_Btn,
- () =>
- {
- Unlock();
- ResourceManager.Get(ObjectLabel.Fe_Info).TweenBacCG();
- }
- );
- }
- else if (ItemStatus == SkillStatus.Upgrade)
- {
- ResourceManager.SetText(ObjectLabel.Fe_Lab0, GetDescription(0));
- ResourceManager.SetText(ObjectLabel.Fe_Lab1, GetDescription(1));
- ResourceManager.SetText(ObjectLabel.Fe_BtnLab, string.Format("{0}({1}{2:0})", Language.GetStr(LanguageLabel.UI__Fe_BtnLab2), Auxiliary.ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt)));
- ResourceManager.SetButtonEvent
- (
- ObjectLabel.Fe_Btn,
- () =>
- {
- Upgrade();
- ItemLab.text = GetDescription(0);
- ItemBtnLab.text = Language.GetStr(LanguageLabel.UI__Fe_BtnLab2) + "\n" + Auxiliary.ImageParse(UpgradeCur) + Auxiliary.ShrinkNumberStr(NewUpgradeAmt);
- ResourceManager.SetText(ObjectLabel.Fe_Tit, Name);
- ResourceManager.SetText(ObjectLabel.Fe_Lab0, GetDescription(0));
- ResourceManager.SetText(ObjectLabel.Fe_Lab1, GetDescription(1));
- ResourceManager.SetText(ObjectLabel.Fe_BtnLab, string.Format("{0}({1}{2:0})", Language.GetStr(LanguageLabel.UI__Fe_BtnLab2), Auxiliary.ImageParse(UpgradeCur), Auxiliary.ShrinkNumberStr(NewUpgradeAmt)));
- }
- );
- }
- }
- protected void Upgrade()
- {
- Manager.Pay
- (
- FullID,
- NewUpgradeAmt,
- UpgradeCur,
- () =>
- {
- UpgradeSucceed();
- },
- StaticsManager.ItemID.升级技能,
- StaticsManager.ConsumeModule.Shop
- );
- }
- public void UpgradeSucceed()
- {
- AudioManager.PlayClip(Clip.SkillClip);
- Level++;
- AnnulEffect();
- NewUpgradeAmt = Auxiliary.FmlParse(UpgradeFml, "a", NewUpgradeAmt.ToString("0.00"));
- UpgradeValue(ref NewPlus, UpgradePlus, 1);
- UpgradeValue(ref NewPersonBuff, UpgradePerson, 1);
- UpgradeSkillCdBuff(ref NewSkillCdBuff, UpgradeCD, 1);
- UpgradeValue(ref NewPerson, Person, UpgradePerson, 1);
- UpgradeValue(ref NewSkillCD, SkillCD, UpgradeCD, 1);
- UpgradeValue(ref NewCoinPerson, CoinPerson, UpgradePlus, 1);
- GetAward();
- AddAchieve();
- if (FullID == "Ability1")
- {
- Manager.Level++;
- }
- }
- protected void UnlockAhead()
- {
- Manager.Pay
- (
- FullID,
- UnlockAheadAmt,
- UnlockAheadCur,
- () =>
- {
- UnlockAheadSucceed();
- },
- StaticsManager.ItemID.提前解锁技能,
- StaticsManager.ConsumeModule.Shop
- );
- }
- public void UnlockAheadSucceed()
- {
- AudioManager.PlayClip(Clip.SkillClip);
- if (UnlockCur == Current.Free)
- {
- Unlock();
- }
- else
- {
- ItemStatus = SkillStatus.UnLock;
- UIManager.UpdateHint();
- }
- }
- public override void AnnulEffect()
- {
- Manager.Person -= NewPerson;
- Manager.CoinPerson -= NewCoinPerson;
- Manager.SkillPlus -= NewPlus;
- Manager.SkillPersonBuff -= NewPersonBuff;
- if (Math.Abs(NewSkillCD) > 0.0005f)
- {
- for (int i = 0; i < Manager.SkillList.Count; i++)
- {
- Manager.SkillList[i].ReceiveCool(-NewSkillCD, false, false);
- }
- }
- if (Math.Abs(NewSkillCdBuff) > 0.0005f)
- {
- for (int i = 0; i < Manager.SkillList.Count; i++)
- {
- Manager.SkillList[i].ReceiveCool(-NewSkillCdBuff, false, true);
- }
- }
- }
- public override void UpdateStatus()
- {
- if (!Manager.Complete)
- {
- return;
- }
- if (Manager.Level >= UnlockLv)
- {
- if (ItemStatus == SkillStatus.Lock)
- {
- if (UnlockCur == Current.Free)
- {
- Unlock();
- }
- else
- {
- ItemStatus = SkillStatus.UnLock;
- UIManager.UpdateHint();
- }
- }
- }
- }
- public ExchangeInfo GetUnlockAheadExchangeValue(float rate, StaticsManager.ConsumeModule consumeModule)
- {
- ExchangeInfo info = ExchangeInfo.GetExchangeInfo(UnlockAheadCur, UnlockAheadAmt, rate);
- ExchangeInfo.GetExchangeValue(info, consumeModule);
- return info;
- }
- #region 解读器
- protected double UpgradeAmtParse(string str)
- {
- if (string.IsNullOrEmpty(str))
- {
- return UnlockAmt;
- }
- else
- {
- return double.Parse(str);
- }
- }
- protected override string GetDescription(int offset)
- {
- float temp;
- string[] strings = Desc.Split(TransferLabel.OpenChar, TransferLabel.CloseChar);
- StringBuilder stringBuilder = new StringBuilder();
- for (int i = 0; i < strings.Length; i++)
- {
- if (strings[i].Contains(TransferLabel.Level))
- {
- }
- else if (strings[i].Contains(TransferLabel.Person))
- {
- #region MyRegion
- if (!Person.Equal(0))
- {
- temp = NewPerson;
- UpgradeValue(ref temp, Person, UpgradePerson, offset);
- UpgradeUnit(ref temp, strings[i]);
- float remainder = temp % 1;
- if (remainder > 0)
- {
- stringBuilder.Append(temp.ToString("0") + "+");
- }
- else
- {
- stringBuilder.Append(temp.ToString("0"));
- }
- }
- else if (!PersonBuff.Equal(0))
- {
- temp = NewPersonBuff;
- UpgradeValue(ref temp, UpgradePerson, offset);
- stringBuilder.Append(string.Format("{0:0}%", temp * 100));
- }
- #endregion
- }
- else if (strings[i].Contains(TransferLabel.SkillCD))
- {
- #region MyRegion
- if (!SkillCD.Equal(0))
- {
- temp = NewSkillCD;
- UpgradeValue(ref temp, SkillCD, UpgradeCD, offset);
- UpgradeUnit(ref temp, strings[i]);
- stringBuilder.Append(temp.ToString("0"));
- }
- else if (!SkillCdBuff.Equal(0))
- {
- temp = NewSkillCdBuff;
- UpgradeSkillCdBuff(ref temp, UpgradeCD, offset);
-
- stringBuilder.Append(string.Format("{0:0}%", temp * 100));
- }
- #endregion
- }
- else if (strings[i].Contains(TransferLabel.CoinPerson))
- {
- #region MyRegion
- if (!CoinPerson.Equal(0))
- {
- temp = NewCoinPerson;
- UpgradeValue(ref temp, CoinPerson, UpgradePlus, offset);
- UpgradeUnit(ref temp, strings[i]);
- float remainder = temp % 1;
- if (remainder > 0)
- {
- stringBuilder.Append(temp.ToString("0") + "+");
- }
- else
- {
- stringBuilder.Append(temp.ToString("0"));
- }
- }
- else if (!Plus.Equal(0))
- {
- temp = NewPlus;
- UpgradeValue(ref temp, UpgradePlus, offset);
- stringBuilder.Append(string.Format("{0:0}%", temp * 100));
- }
- #endregion
- }
- else
- {
- stringBuilder.Append(strings[i]);
- }
- }
- return stringBuilder.ToString();
- }
- #endregion
- }
|