2025-10-21 19:10:22 +08:00

96 lines
2.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using UnityEngine;
using RuntimeData;
using Logic.Multilingual;
[Serializable]
[CreateAssetMenu(fileName = "SkillDataAssets", menuName = "TH1 Game Data/Skill Data Asset")]
public class SkillDataAssets : ScriptableObject
{
public List<SkillInfo> SkillInfoList = new List<SkillInfo>();
private Dictionary<SkillType,SkillInfo> _skillDict = new Dictionary<SkillType, SkillInfo>();
[NonSerialized]
private bool _initialized = false;
private void Init()
{
if (_initialized)
return;
foreach(var t in SkillInfoList)
_skillDict[t.SkillType] = t;
_initialized = true;
}
public bool GetSkillInfo(SkillType skill, out SkillInfo skillInfo)
{
Init();
return _skillDict.TryGetValue(skill,out skillInfo);
}
//根据unitTypeKey决定skill显示为什么
public bool GetSkillNameAndDesc(SkillType skill,UnitFullType key,out String skillName, out String skillDesc)
{
Init();
skillDesc = "";
skillName = "";
bool ret = _skillDict.TryGetValue(skill,out var skillInfo);
if (!ret) return false;
//如果没有SkillShowList
if (!skillInfo.HasShowList)
{
skillDesc = skillInfo.SkillDesc;
skillName = skillInfo.SkillName;
return true;
}
//如果有ShowList根据key来判断选谁都选不到则采用基础SkillDesc
foreach (var t in skillInfo.SkillShowList)
{
if (key.UnitType == t.UnitType
&& (t.IgnoreUnitGiantType || key.GiantType == t.GiantType)
&& (t.IgnoreUnitLevel || key.UnitLevel == t.UnitLevel))
{
skillDesc = t.SkillDesc;
skillName = t.SkillName;
return true;
}
}
skillDesc = skillInfo.SkillDesc;
skillName = skillInfo.SkillName;
return true;
}
}
[Serializable]
public class SkillInfo
{
public SkillType SkillType;
[MultilingualField]
public string SkillName;
[MultilingualField]
public string SkillDesc;
//根据不同的unittype对象呈现不同的图标&说明
public bool HasShowList;
public List<SkillInfoShowPack> SkillShowList;
}
[Serializable]
public class SkillInfoShowPack
{
public UnitFullType UnitFullType;
public UnitType UnitType;
public GiantType GiantType;
public uint UnitLevel;
public bool IgnoreUnitGiantType;
public bool IgnoreUnitLevel;
[MultilingualField]
public string SkillDesc;
[MultilingualField]
public string SkillName;
}