76 lines
2.3 KiB
C#
76 lines
2.3 KiB
C#
using System.Collections.Generic;
|
|
using SLSUtilities.General;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Characters
|
|
{
|
|
public enum StatusType
|
|
{
|
|
//负面状态
|
|
Incapacitation = 0, //失能,丧失一切行动能力
|
|
Inhibition = 1, //抑制,无法使用支援装备/技能
|
|
Disarm = 2, //缴械,无法攻击(使用主武器)
|
|
Restraint = 3, //束缚,无法移动
|
|
Disability = 4, //残废,不能使用反应类技能(闪避/格挡等)
|
|
|
|
Stun = 100, //眩晕
|
|
|
|
//正面状态
|
|
Invincible = 1000, //无敌
|
|
Invisible = 1001, //隐身
|
|
|
|
//中性状态
|
|
Recovering = 2000, //恢复中
|
|
}
|
|
|
|
public partial class StatusSubmodule : SubmoduleBase<CharacterBase>
|
|
{
|
|
public Dictionary<StatusType, int> currentStatus;
|
|
public bool isDead;
|
|
|
|
public StatusSubmodule(CharacterBase character) : base(character)
|
|
{
|
|
currentStatus = new Dictionary<StatusType, int>();
|
|
foreach (StatusType statusType in System.Enum.GetValues(typeof(StatusType)))
|
|
{
|
|
currentStatus.Add(statusType, 0);
|
|
}
|
|
|
|
isDead = false;
|
|
}
|
|
}
|
|
|
|
public partial class StatusSubmodule
|
|
{
|
|
public void AddStatus(StatusType statusType, float duration)
|
|
{
|
|
AddStatus(statusType);
|
|
owner.selfTimeSm.AddLocalTimer(duration, () => RemoveStatus(statusType));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加一层某种状态
|
|
/// </summary>
|
|
public void AddStatus(StatusType statusType)
|
|
{
|
|
currentStatus[statusType]++;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 移除某个来源对应的一层状态,注意:如果有其他来源的状态,不会彻底结束状态效果。
|
|
/// </summary>
|
|
public void RemoveStatus(StatusType statusType)
|
|
{
|
|
currentStatus[statusType]--;
|
|
currentStatus[statusType] = Mathf.Max(currentStatus[statusType], 0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 检查是否有某种状态
|
|
/// </summary>
|
|
public bool HasStatus(StatusType statusType)
|
|
{
|
|
return currentStatus[statusType] > 0;
|
|
}
|
|
}
|
|
} |