NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/GameUnitEx.cs

60 lines
2.0 KiB
C#

using Gameplay.Character;
using Gameplay.Summon;
using Gameplay.Unit.Data;
namespace Gameplay.Unit
{
public static class GameUnitEx
{
public static EGameUnitType GetFinalUnitType(this GameUnit unit)
{
if (unit.gameunitType == EGameUnitType.Summon)
{
if (unit is BaseSummon summon)
{
return summon.subUnitType;
}
}
return unit.gameunitType;
}
public static string GetUnitDesc(this GameUnit unit)
{
var isSelf = unit.commonData.troopId == ETroopsId.Self;
switch (unit.gameunitType)
{
case EGameUnitType.Character:
if (isSelf)
{
return "我方角色:" + unit.GetID();
}
return "敌方角色:" + unit.GetID();
case EGameUnitType.Summon:
if (isSelf)
{
return "我方召唤物:" + unit.GetID();
}
return "敌方召唤物:" + unit.GetID();
case EGameUnitType.Vehicle:
if (isSelf)
{
return "我方载具:" + unit.GetID();
}
return "敌方载具:" + unit.GetID();
case EGameUnitType.Player:
if (isSelf)
{
return "我方玩家:" + unit.GetID();
}
return "敌方玩家:" + unit.GetID();
default:
DebugUtil.LogError($"未知类型:{unit.gameunitType} Id:{unit.GetID()}");
return "未知类型:" + unit.gameunitType + "Id:" + unit.GetID();
}
DebugUtil.LogError($"错误类型:{unit.gameunitType} Id:{unit.GetID()}");
return "错误类型:" + unit.gameunitType + "Id:" + unit.GetID();
}
}
}