123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 |
- using UnityEngine;
- using UnityEngine.UI;
- using System;
- using System.Xml;
- using System.Collections;
- using System.Collections.Generic;
- public enum Current
- {
- AD,
- Free,
- Coin,
- Cash,
- Other,
- Diamond,
- }
- public enum SkillTab
- {
- Elf,
- Null,
- Store,
- Magic,
- Garden,
- }
- public enum SkillType
- {
- Skill,
- Pack,
- Ability,
- BigSkill,
- }
- public enum SkillStatus
- {
- Buy,
- Use,
- Lock,
- Cool,
- UnLock,
- Upgrade,
- }
- public abstract class SkillRoot
- {
- #region 变量
- #region 配置
- public Sprite Icon
- {
- get
- {
- return ManaReso.LoadSprite(Icon_, Folder.UI);
- }
- }
- public string Desc
- {
- get
- {
- return Language.GetStr("SkillDesc", ID);
- }
- }
- public virtual string ID
- {
- get { throw new Exception(); }
- }
- public virtual string Name
- {
- get
- {
- if (Level == 0)
- {
- return Language.GetStr("SkillName", ID);
- }
- else
- {
- return Language.GetStr("SkillName", ID) + Level;
- }
- }
- }
- public int ID_;
- public string Icon_;
- public int ItemIndex;
- #endregion
- public virtual int Level
- {
- get { return Level_; }
- set
- {
- Level_ = value;
- if (SkillTab == SkillTab.Null)
- {
- return;
- }
- if (Level == 0)
- {
- ManaLan.Add(ItemTit, new LanStr("SkillName", ID));
- }
- else
- {
- ManaLan.Add(ItemTit, new LanStr("SkillName", ID), Level);
- }
- }
- }
- public int Level_;
- public Text ItemTit;
- public Text ItemLab;
- public Text ItemBtnLab;
- public Image ItemIcon;
- public Button ItemBtn;
- public SkillTab SkillTab;
- public SkillType SkillType;
- public Transform SkillItem;
- public virtual SkillStatus ItemStatus
- {
- get { return ItemStatus_; }
- set
- {
- ItemStatus_ = value;
- }
- }
- public SkillStatus ItemStatus_;
- #endregion
- public static int Sort(SkillRoot skillRootA, SkillRoot skillRootB)
- {
- if (skillRootA.ItemIndex == skillRootB.ItemIndex)
- {
- return 0;
- }
- else if (skillRootA.ItemIndex > skillRootB.ItemIndex)
- {
- return 1;
- }
- else if (skillRootA.ItemIndex < skillRootB.ItemIndex)
- {
- return -1;
- }
- else
- {
- throw new Exception();
- }
- }
- public virtual void Reactive()
- {
- }
- public virtual void RegistValue(bool firstRegist, float elapse, List<List<Skill>> useList, XmlAttributeCollection attribute)
- {
- }
- public virtual void RegistReference()
- {
- if (SkillTab == SkillTab.Null)
- {
- return;
- }
- Dictionary<string, Transform> childDic = new Dictionary<string, Transform>();
- Auxiliary.CompileDic(SkillItem, childDic);
- ItemTit = childDic["Tit"].GetComponent<Text>();
- ItemBtn = childDic["Btn"].GetComponent<Button>();
- ItemLab = childDic["Lab"].GetComponent<Text>();
- ItemIcon = childDic["Icon"].GetComponent<Image>();
- ItemBtnLab = childDic["BtnLab"].GetComponent<Text>();
- ItemIcon.sprite = Icon;
- }
- public virtual void SwitchLanguage()
- {
- if (SkillTab != SkillTab.Null)
- {
- ItemLab.text = GetDescription(0);
- }
- }
-
- public virtual void AnnulA()
- {
- }
- public virtual bool DoUse()
- {
- throw new Exception();
- }
- public virtual void ReceiveCool(float amt, bool current, bool buff)
- {
-
- }
- public virtual void UpdateStatus()
- {
- }
- #region 解读器
- protected string ImageParse(Current current)
- {
- if (current == Current.Coin)
- {
- return "<(金币)>";
- }
- else if (current == Current.Diamond)
- {
- return "<(钻石)>";
- }
- else if (current == Current.Cash)
- {
- return Language.GetStr("Common", "Cash");
- }
- else
- {
- throw new Exception(current.ToString());
- }
- }
- protected Current CurrentParse(string str)
- {
- if (string.IsNullOrEmpty(str))
- {
- return Current.Free;
- }
- else
- {
- int number = int.Parse(str);
- if (number == 1)
- {
- return Current.Coin;
- }
- else if (number == 2)
- {
- return Current.Diamond;
- }
- else if (number == 3)
- {
- return Current.Cash;
- }
- else if (number == 4)
- {
- return Current.Other;
- }
- else if (number == 5)
- {
- return Current.AD;
- }
- else
- {
- throw new Exception(number.ToString());
- }
- }
- }
- protected SkillTab SkillClassParse(string str)
- {
- if (string.IsNullOrEmpty(str))
- {
- return SkillTab.Null;
- }
- else
- {
- int number = int.Parse(str);
- if (number == 1)
- {
- return SkillTab.Garden;
- }
- else if (number == 2)
- {
- return SkillTab.Elf;
- }
- else if (number == 3)
- {
- return SkillTab.Magic;
- }
- else if (number == 4)
- {
- return SkillTab.Store;
- }
- else
- {
- throw new Exception();
- }
- }
- }
- protected void UpgradeUnit(ref float target, string fml)
- {
- if (fml.Contains("*"))
- {
- target *= float.Parse(fml.Split('*')[1]);
- }
- else if (fml.Contains("/"))
- {
- target /= float.Parse(fml.Split('/')[1]);
- }
- }
- protected void UpgradeValue(ref float target, string fml, int offset)
- {
- if (fml.Contains("%"))
- {
- target += (float.Parse(fml.Replace("%", ""))/100)*offset;
- }
- }
- protected void UpgradeValue(ref float target, float baseValue, string fml, int offset)
- {
- if (target.Equal(0))
- {
- return;
- }
- if (string.IsNullOrEmpty(fml))
- {
- return;
- }
- if (fml.Contains("%"))
- {
- float step = float.Parse(fml.Replace("%", "")) / 100;
- target += baseValue * step * offset;
- }
- else
- {
- target += float.Parse(fml) * offset;
- }
- }
- protected void UpgradeSkillCdBuff(ref float target, string fml, int offset)
- {
- if (fml.Contains("%"))
- {
- float unit = (float.Parse(fml.Replace("%", "")))/100;
- for (int i = 0; i < offset; i++)
- {
- target += (1 - target) * unit;
- }
- }
- }
- protected void ValueBuffParse(out float value, out float buff, string str)
- {
- if (str.Contains("%"))
- {
- float step = float.Parse(str.Replace("%", "")) / 100;
- buff = step;
- value = 0;
- }
- else
- {
- buff = 0;
- value = Auxiliary.FloatParse(str, 0);
- }
- }
- protected virtual string GetDescription(int offset)
- {
- throw new Exception();
- }
- #endregion
- }
- #region DebugList
- //语言切换
- #endregion
|