You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

60 lines
1.8 KiB

using System;
using System.Collections.Generic;
[Serializable]
public class SkillProperty
{
public uint id;
public float defaultCoolTime;
public EditableKeyValue<string, float>[] extraValues = new EditableKeyValue<string, float>[0];
}
public class SkillData
{
SkillProperty property;
Dictionary<int, byte> 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<int, byte>();
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);
}
}