using Gameplay.Area;
using Gameplay.Character;
using Gameplay.PostProcess.BlackArea;
namespace Gameplay.Unit.Data
{
public class UnitStatusData
{
public readonly GameUnit owner;
///
/// 是否正在移动
///
public bool isMoveing = false;
///
/// 是否已死亡
///
public bool isDead = false;
///
/// 是否可以被攻击
///
public bool canBeAttack = true;
///
/// 是否在载具上
///
public bool isOnVehicle = false;
///
/// 是否混乱
///
public bool isChaos = false;
///
/// 是否眩晕
///
public bool isStun = false;
///
/// 是否锁定位置
///
public bool isLockPos = false;
///
/// 是否逃跑
///
public bool isRetreat = false;
///
/// 是否需要技能暂停
///
public bool needSkillPaused = false;
///
/// 是否在释放技能
///
public bool isInSkilling = false;
///
/// 是否不可逃跑
///
public bool isNoRetreat = false;
///
/// 是否是AI控制
///
public bool isAIControll = false;
///
/// 是否是伪装状态
///
public bool isPretend = false;
///
/// 是否是死撑状态
///
public bool isDeadRetreat = false;
///
/// 是否是扛旗状态
///
public bool isHoldFlag = false;
public GameUnit lastAttackUnit = null;
///
/// 是否激活攻击
///
public bool isAttackActive = false;
///
/// 是否允许攻击
///
public bool isAllowAttack = true;
///
/// 自身是否可以发起攻击
///
///
public bool CheckCanAttack()
{
if (isDead) return false;
if (isOnVehicle) return false;
if (isRetreat) return false;
if (isInSkilling) return false;
if (!isAttackActive) return false;
if (!isAllowAttack) return false;
return true;
}
///
/// 检查是否可以被当做被攻击目标
///
///
public bool CheckCanBeTarget(GameUnit attacker, int checkDistance = 0)
{
if (!canBeAttack) return false;
if (!owner.isReady) return false;
if (isDead) return false;
if (isOnVehicle) return false;
if (isPretend) return false;
if (owner.commonData.troopId != ETroopsId.Self)
{
if (!BlackAreaManager.instance.CheckIsInLightArea(owner.transData.cellIndex))
{
return false;
}
}
return CheckIsInAttackArea(attacker, checkDistance);
}
public bool CheckIsInAttackArea(GameUnit attacker, int checkDistance = 0)
{
if (attacker != null)
{
if (checkDistance == 0)
{
checkDistance = attacker.fightData.attackDistance;
}
var attackArea = AreaManager.instance.attackAreaManager.GetAttackArea(attacker.transData.cellIndex, checkDistance);
if (owner.fightData.isAttackIgnoreBlock)
{
if (!attackArea.totalCells.Contains(owner.transData.cellIndex))
{
return false;
}
}
else
{
if (!attackArea.canAttackCells.Contains(owner.transData.cellIndex))
{
return false;
}
}
}
return true;
}
public bool CheckCanPickFlag()
{
if (owner.commonData.troopId != ETroopsId.Self) return false;
if (owner.gameunitType != EGameUnitType.Character) return false;
var character = owner as Character.Character;
if (character == null) return false;
if (character.runtimeData.isInSuppressed) return false;
if (isPretend) return false;
if (isDead) return false;
if (isOnVehicle) return false;
if (isRetreat) return false;
if (isInSkilling) return false;
return true;
}
public UnitStatusData(GameUnit owner)
{
this.owner = owner;
}
public void Reset()
{
isMoveing = false;
isDead = false;
canBeAttack = true;
isOnVehicle = false;
isChaos = false;
isStun = false;
isLockPos = false;
isRetreat = false;
needSkillPaused = false;
isInSkilling = false;
isNoRetreat = false;
isDeadRetreat = false;
}
}
}