NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Team/CommandSkillManager.cs

68 lines
1.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using cfg.ActorCfg;
using cfg.SkillCfg;
using Framework;
using Gameplay.Net;
using System.Collections.Generic;
public class CommandSkillManager
{
/// <summary>
/// 指挥官可以携带的技能数量
/// </summary>
public static readonly int COMMAND_SKILL_COUNT = 3;
/// <summary>
/// 指挥官技能无效id
/// </summary>
public static readonly int NONE_ID = 0;
private readonly List<int> _commandSkillIDs = new(COMMAND_SKILL_COUNT) { NONE_ID, NONE_ID, NONE_ID };
public List<int> CommandSkillIDs => _commandSkillIDs;
public CommandSkillManager(uint[] ids = null)
{
if (null == ids)
{
for (int i = 0; i <= COMMAND_SKILL_COUNT; ++i)
{
_commandSkillIDs[i] = NONE_ID;
}
return;
}
for (int i = 0; i < ids.Length && i < COMMAND_SKILL_COUNT; ++i)
{
int upgradeId = (int)ids[i];
if (NONE_ID == upgradeId)
{
_commandSkillIDs[i] = NONE_ID;
continue;
}
int skillLevel = Actor.Instance.PlayerSkill.GetLevel(upgradeId);
DataPlayerSkillUpgrade playerSkillUpgrade = TableManager.Instance.Tables.PlayerSkillUpgrade.Get(upgradeId, skillLevel);
if (null == playerSkillUpgrade)
{
DebugUtil.LogError($"取不到指挥官技能养成数据id{upgradeId},等级{skillLevel}");
_commandSkillIDs[i] = NONE_ID;
continue;
}
_commandSkillIDs[i] = playerSkillUpgrade.SkillID;
}
}
public int GetCommandSkillID(int idx)
{
return _commandSkillIDs[idx];
}
/// <summary>
/// 指挥官技能id是否有效
/// </summary>
/// <returns></returns>
public static bool IsIdValid(int skillId)
{
return skillId > NONE_ID;
}
}