2024-09-23 15:05:34 +08:00
|
|
|
using AOT.PostProcess.BlackArea;
|
2024-07-12 17:06:39 +08:00
|
|
|
using Gameplay.Area;
|
2024-05-31 19:44:10 +08:00
|
|
|
using Gameplay.Character;
|
2024-07-10 19:51:24 +08:00
|
|
|
using Gameplay.PostProcess.BlackArea;
|
2023-12-13 16:20:41 +08:00
|
|
|
namespace Gameplay.Unit.Data
|
2023-08-22 19:08:45 +08:00
|
|
|
{
|
|
|
|
|
public class UnitStatusData
|
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
public readonly GameUnit owner;
|
2024-11-20 14:23:33 +08:00
|
|
|
|
2023-08-22 19:08:45 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否正在移动
|
|
|
|
|
/// </summary>
|
2024-11-20 14:23:33 +08:00
|
|
|
public bool isMoveing
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 19:08:45 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否已死亡
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isDead = false;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否可以被攻击
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool canBeAttack = true;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否在载具上
|
|
|
|
|
/// </summary>
|
2025-02-11 16:45:45 +08:00
|
|
|
public bool isOnVehicle
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
} = false;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否在建筑内
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isInBuilding
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
} = false;
|
|
|
|
|
|
|
|
|
|
public bool isOnFloor
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return !isOnVehicle && !isInBuilding;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否混乱
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isChaos = false;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否眩晕
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isStun = false;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否锁定位置
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isLockPos = false;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否逃跑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isRetreat = false;
|
2024-09-23 15:33:27 +08:00
|
|
|
|
2025-01-20 19:42:11 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否已经撤离
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isEvacuate
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
} = false;
|
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否需要技能暂停
|
|
|
|
|
/// </summary>
|
2024-09-23 15:33:27 +08:00
|
|
|
public bool needSkillPaused
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-12 17:55:58 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否是战斗状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isInFight
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
} = true;
|
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否在释放技能
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isInSkilling = false;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否不可逃跑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isNoRetreat = false;
|
2023-08-22 19:08:45 +08:00
|
|
|
|
2023-12-25 19:00:08 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否是AI控制
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isAIControll = false;
|
|
|
|
|
|
2024-01-17 14:09:16 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否是伪装状态
|
|
|
|
|
/// </summary>
|
2025-02-12 17:40:38 +08:00
|
|
|
public bool isPretend
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
} = false;
|
2024-01-17 14:09:16 +08:00
|
|
|
|
2024-03-22 14:25:27 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否是死撑状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isDeadRetreat = false;
|
|
|
|
|
|
2024-06-05 14:38:13 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否是扛旗状态
|
|
|
|
|
/// </summary>
|
2025-01-21 19:44:03 +08:00
|
|
|
public bool isHoldFlag
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-12 19:09:10 +08:00
|
|
|
public GameUnit lastAttackUnit = null;
|
2024-06-05 14:38:13 +08:00
|
|
|
|
2024-07-03 19:21:10 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否激活攻击
|
|
|
|
|
/// </summary>
|
2025-02-11 16:45:45 +08:00
|
|
|
public bool isAttackActive
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
} = false;
|
2024-07-03 19:21:10 +08:00
|
|
|
|
2024-07-09 19:26:04 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否允许攻击
|
|
|
|
|
/// </summary>
|
2024-10-12 17:37:51 +08:00
|
|
|
public bool isAllowAttack
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
} = true;
|
2024-07-09 19:26:04 +08:00
|
|
|
|
2024-09-29 13:38:26 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否被选中
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isSelected { get; set; }
|
|
|
|
|
|
2024-10-22 15:48:46 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否正在重新装填
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isReloading
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-22 18:11:17 +08:00
|
|
|
public float reloadProgress
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否在攻击间隔中
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isAttackEnd
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
public float attackEndProgress
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-09 19:26:04 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 自身是否可以发起攻击
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool CheckCanAttack()
|
|
|
|
|
{
|
|
|
|
|
if (isDead) return false;
|
2025-02-11 16:45:45 +08:00
|
|
|
if (!isOnFloor) return false;
|
2024-07-09 19:26:04 +08:00
|
|
|
if (isRetreat) return false;
|
|
|
|
|
if (isInSkilling) return false;
|
2025-01-20 19:42:11 +08:00
|
|
|
if (isEvacuate) return false;
|
2024-07-09 19:26:04 +08:00
|
|
|
if (!isAttackActive) return false;
|
|
|
|
|
if (!isAllowAttack) return false;
|
2025-02-13 12:13:51 +08:00
|
|
|
if (isPretend) return false;
|
2024-07-09 19:26:04 +08:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 19:08:45 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 检查是否可以被当做被攻击目标
|
2025-02-11 17:53:42 +08:00
|
|
|
/// checkDistance -1:不检查距离 0:使用攻击距离
|
2023-08-22 19:08:45 +08:00
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2024-07-12 17:06:39 +08:00
|
|
|
public bool CheckCanBeTarget(GameUnit attacker, int checkDistance = 0)
|
2023-08-22 19:08:45 +08:00
|
|
|
{
|
2025-02-11 17:53:42 +08:00
|
|
|
if (owner.needRemove) return false;
|
2025-01-20 19:42:11 +08:00
|
|
|
if (isEvacuate) return false;
|
2023-08-22 19:08:45 +08:00
|
|
|
if (!canBeAttack) return false;
|
2023-10-19 15:00:19 +08:00
|
|
|
if (!owner.isReady) return false;
|
2023-08-22 19:08:45 +08:00
|
|
|
if (isDead) return false;
|
2025-02-11 16:45:45 +08:00
|
|
|
if (!isOnFloor) return false;
|
2024-01-17 14:09:16 +08:00
|
|
|
if (isPretend) return false;
|
2024-07-10 19:51:24 +08:00
|
|
|
if (owner.commonData.troopId != ETroopsId.Self)
|
|
|
|
|
{
|
|
|
|
|
if (!BlackAreaManager.instance.CheckIsInLightArea(owner.transData.cellIndex))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-15 19:03:51 +08:00
|
|
|
return CheckIsInAttackArea(attacker, checkDistance);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CheckIsInAttackArea(GameUnit attacker, int checkDistance = 0)
|
|
|
|
|
{
|
2024-10-08 12:54:13 +08:00
|
|
|
if (checkDistance == -1) return true;
|
2024-07-12 17:06:39 +08:00
|
|
|
if (attacker != null)
|
|
|
|
|
{
|
|
|
|
|
if (checkDistance == 0)
|
|
|
|
|
{
|
|
|
|
|
checkDistance = attacker.fightData.attackDistance;
|
|
|
|
|
}
|
|
|
|
|
var attackArea = AreaManager.instance.attackAreaManager.GetAttackArea(attacker.transData.cellIndex, checkDistance);
|
2024-07-12 18:46:26 +08:00
|
|
|
if (owner.fightData.isAttackIgnoreBlock)
|
2024-07-12 17:06:39 +08:00
|
|
|
{
|
2024-07-12 18:46:26 +08:00
|
|
|
if (!attackArea.totalCells.Contains(owner.transData.cellIndex))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!attackArea.canAttackCells.Contains(owner.transData.cellIndex))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-07-12 17:06:39 +08:00
|
|
|
}
|
2024-07-12 18:46:26 +08:00
|
|
|
|
2024-07-12 17:06:39 +08:00
|
|
|
}
|
2023-08-22 19:08:45 +08:00
|
|
|
return true;
|
|
|
|
|
}
|
2024-05-31 19:44:10 +08:00
|
|
|
|
|
|
|
|
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;
|
2025-02-11 16:45:45 +08:00
|
|
|
if (!isOnFloor) return false;
|
2024-05-31 19:44:10 +08:00
|
|
|
if (isRetreat) return false;
|
2025-01-22 14:55:40 +08:00
|
|
|
// if (isInSkilling) return false;
|
2024-05-31 19:44:10 +08:00
|
|
|
return true;
|
|
|
|
|
}
|
2023-08-22 19:08:45 +08:00
|
|
|
|
|
|
|
|
public UnitStatusData(GameUnit owner)
|
|
|
|
|
{
|
|
|
|
|
this.owner = owner;
|
|
|
|
|
}
|
2023-12-19 14:26:50 +08:00
|
|
|
|
|
|
|
|
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;
|
2024-03-22 14:25:27 +08:00
|
|
|
isDeadRetreat = false;
|
2023-12-19 14:26:50 +08:00
|
|
|
}
|
2023-08-22 19:08:45 +08:00
|
|
|
}
|
|
|
|
|
}
|