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.
108 lines
3.8 KiB
108 lines
3.8 KiB
using System.Collections.Generic;
|
|
using Skill_V2;
|
|
using UnityEngine;
|
|
|
|
public class SkillData : IHasBuff
|
|
{
|
|
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(string nameKey, out BuffData buff) => buffs.TryFind(x => x.NameKey == nameKey, out buff);
|
|
|
|
/// <summary>
|
|
/// stat.{statID}은 스탯의 이름을 표시합니다.
|
|
/// buff.{buffName}.{property}은 버프의 속성을 표시합니다.
|
|
/// buff.{buffName}.effect.{index}.{property}은 버프의 효과의 속성을 표시합니다.
|
|
/// </summary>
|
|
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 = values[1];
|
|
if (TryGetBuff(key, out BuffData buff))
|
|
{
|
|
if (values[2] == "duration")
|
|
{
|
|
result += buff.Duration.ToString("F2");
|
|
}
|
|
else if (values[2] == "effect")
|
|
{
|
|
Debug.Assert(values.Length > 4, "Invalid skill desc");
|
|
|
|
var index = int.Parse(values[3]);
|
|
if (values[4] == "value")
|
|
{
|
|
result += buff.Effects[index].Value;
|
|
}
|
|
else if (values[4] == "name")
|
|
{
|
|
result += LocalizationText.GetText(buff.Effects[index].NameKey);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result += descFormat[i];
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|