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.
95 lines
3.1 KiB
95 lines
3.1 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using IVDataFormat;
|
|
using Skill_V2;
|
|
using UnityEngine;
|
|
|
|
public class SkillData
|
|
{
|
|
SkillProperty property;
|
|
|
|
StatGroup statGroup;
|
|
BuffData[] buffs;
|
|
|
|
public uint ID => property.id;
|
|
public Skill Prefab => property.skillPrefab;
|
|
public IReadOnlyList<SkillSequence> Sequences => property.sequences;
|
|
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 IReadOnlyList<BuffData> Buffs => buffs;
|
|
|
|
public SkillData(SkillProperty property)
|
|
{
|
|
this.property = property;
|
|
|
|
statGroup = new StatGroup(property.stats);
|
|
|
|
buffs = new BuffData[property.buffs.Length];
|
|
for (int i = 0; i < property.buffs.Length; i++)
|
|
{
|
|
buffs[i] = new BuffData(property.buffs[i], this);
|
|
}
|
|
}
|
|
|
|
public bool TryGetStat(uint id, out StatData stat) => statGroup.TryGetStat(id, out stat);
|
|
public bool TryGetStat(StatID id, out StatData stat) => TryGetStat((uint)id, out stat);
|
|
public bool TryGetBuff(eEffectType key, out BuffData buff) => buffs.TryFind(x => x.Key == key, out buff);
|
|
|
|
public string GetSkillDesc()
|
|
{
|
|
string descFormat = LocalizationInjector.InjectLocalization(LocalizationInjector.MakeToLocalizationKey(DescriptionKey));
|
|
|
|
string result = string.Empty;
|
|
for(int i = 0; i < descFormat.Length; i++)
|
|
{
|
|
char c = descFormat[i];
|
|
|
|
if (c == '{')
|
|
{
|
|
string keyword = string.Empty;
|
|
while(++i < descFormat.Length && descFormat[i] != '}')
|
|
{
|
|
keyword += descFormat[i];
|
|
}
|
|
|
|
var values = keyword.Split('_');
|
|
Debug.Assert(values.Length > 0, "Invalid skill desc");
|
|
|
|
if (values[0] == "stat")
|
|
{
|
|
Debug.Assert(values.Length > 1, "Invalid skill desc");
|
|
if (statGroup.TryGetStatByName(values[1], out StatData stat))
|
|
{
|
|
result += stat.ToString();
|
|
}
|
|
}
|
|
else if (values[0] == "buff")
|
|
{
|
|
Debug.Assert(values.Length > 2, "Invalid skill desc");
|
|
|
|
var key = Enum.Parse<eEffectType>(values[1]);
|
|
if (TryGetBuff(key, out BuffData buff))
|
|
{
|
|
if (values[2] == "duration")
|
|
{
|
|
result += buff.Duration.ToString("F2");
|
|
}
|
|
else if (values[2] == "value")
|
|
{
|
|
result += buff.Value.ToString();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result += descFormat[i];
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|