123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365 |
- 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 class SkillItemLabel
- {
- public static string Button = "Button";
- public static string ArrowPosition = "ArrowPosition";
- public static string ArrowDestination = "ArrowDestination";
- public static string Title = "Title";
- public static string Description = "Description";
- public static string LabelText = "LabelText";
- public static string SkillIcon = "SkillIcon";
- public static string LabelIcon = "LabelIcon";
- public static string ButtonTitle = "ButtonTitle";
- }
- public abstract class SkillRoot
- {
- #region Config
- public static string SkillFullIDPrefix = "Skill";
- public static string AbilityFullIDPrefix = "Ability";
- public static string PackFullIDPrefix = "Pack";
- #region 配置
- public Sprite Icon
- {
- get
- {
- return ResourceManager.LoadSprite(icon, Folder.UI);
- }
- }
- public string icon;
- public string Desc
- {
- get
- {
- return Language.GetStr(LanguageLabel.CombineLanguageLabel(LanguageLabel.SkillDesc, FullID));
- }
- }
- public virtual string FullID
- {
- get { throw new Exception();}
- }
- public int ID;
- public virtual string Name
- {
- get
- {
- if (Level == 0)
- {
- return Language.GetStr(LanguageLabel.CombineLanguageLabel(LanguageLabel.SkillName, FullID));
- }
- else
- {
- return Language.GetStr(LanguageLabel.CombineLanguageLabel(LanguageLabel.SkillName, FullID)) + Level;
- }
- }
- }
- public int ItemIndex;
- #endregion
- public virtual int Level
- {
- get { return level; }
- set
- {
- level = value;
- if (SkillTab == SkillTab.Null)
- {
- return;
- }
- if (Level == 0)
- {
- LanguageManager.Add(TitleText, new MulLanStr(LanguageLabel.CombineLanguageLabel(LanguageLabel.SkillName, FullID)));
- }
- else
- {
- LanguageManager.Add(TitleText, new MulLanStr(LanguageLabel.CombineLanguageLabel(LanguageLabel.SkillName, FullID)), Level);
- }
- }
- }
- public int level;
- public Text TitleText;
- public Text DescriptionText;
- public Text LabelText;
- public Text ButtonTitle;
- public Image SkillIcon;
- public Image LabelIcon;
- public Button button;
- 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 Init(bool firstInit, 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);
- TitleText = childDic[SkillItemLabel.Title].GetComponent<Text>();
- button = childDic[SkillItemLabel.Button].GetComponent<Button>();
- DescriptionText = childDic[SkillItemLabel.Description].GetComponent<Text>();
- LabelText = childDic[SkillItemLabel.LabelText].GetComponent<Text>();
- SkillIcon = childDic[SkillItemLabel.SkillIcon].GetComponent<Image>();
- LabelIcon = childDic[SkillItemLabel.LabelIcon].GetComponent<Image>();
- ButtonTitle = childDic[SkillItemLabel.ButtonTitle].GetComponent<Text>();
- SkillIcon.sprite = Icon;
- }
- public virtual void SwitchLanguage()
- {
- if (SkillTab != SkillTab.Null)
- {
- DescriptionText.text = GetDescription(0);
- }
- }
-
- public virtual void AnnulEffect()
- {
- }
- public virtual bool DoUpdate()
- {
- throw new Exception();
- }
- public virtual void Cool(float amt, bool current, bool buff)
- {
-
- }
- public virtual void UpdateStatus()
- {
- }
- #region 解读器
- 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 (target.Equal(0))
- {
- return;
- }
- 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.StringToFloat(str, 0);
- }
- }
- protected virtual string GetDescription(int offset)
- {
- throw new Exception();
- }
- #endregion
- }
|