using System; using System.Collections.Generic; [Serializable] public class SkillProperty { public uint id; public float defaultCoolTime; public EditableKeyValue[] extraValues = new EditableKeyValue[0]; } public class SkillData { SkillProperty property; Dictionary extraValueIndexMap; float[] extraValues; public uint ID => property.id; public float DefaultCoolTime => property.defaultCoolTime; public string NameKey => FormatString.StringFormat("skill_name_{0}", ID); public string DescriptionKey => FormatString.StringFormat("skill_desc_{0}", ID); public string IconImgAtlasName => GameProperty.Instance.SkillIconAtlasName; public string IconImgNameInAtlas => (2000 + ID).ToString(); public SkillData(SkillProperty property) { this.property = property; extraValueIndexMap = new Dictionary(); extraValues = new float[property.extraValues.Length]; for (int i = 0; i < property.extraValues.Length; i++) { int hash = property.extraValues[i].key.GetHashCode(); extraValueIndexMap.SafeInsert(hash, (byte)i); extraValues[i] = property.extraValues[i].value; } } public void SetExtraValue(string key, float value) { if(extraValueIndexMap.TryGetValue(key.GetHashCode(), out byte idx)) extraValues[idx] = value; } public float TryGetExtraValue(string key) { if(extraValueIndexMap.TryGetValue(key.GetHashCode(), out byte idx)) return extraValues[idx]; return 0; } public string GetSkillDesc() { string descFormat = LocalizationInjector.InjectLocalization(LocalizationInjector.MakeToLocalizationKey(DescriptionKey)); return FormatString.StringFormat(descFormat, extraValues); } }