修复Player进入场景时不会加入Role_InstanceList的问题
1 parent 8cd0f5b commit 5a338271d8003f73027a12e3a2f72b14a0d0d4d4
@小李xl 小李xl authored on 5 Apr 2024
Showing 3 changed files
View
14
DungeonShooting_Godot/src/game/activity/role/Role.cs
/// </summary>
protected virtual void OnRemoveBuffProp(BuffProp buffProp)
{
}
public override void EnterTree()
{
if (!World.Role_InstanceList.Contains(this))
{
World.Role_InstanceList.Add(this);
}
}
 
public override void ExitTree()
{
World.Role_InstanceList.Remove(this);
}
 
public override void OnInit()
{
RoleState = OnCreateRoleState();
View
29
DungeonShooting_Godot/src/game/activity/role/ai/AiRole.cs
/// <summary>
/// 是否有移动欲望, 仅在 AiNormal 状态下有效, 其他状态都可以移动
/// </summary>
public bool HasMoveDesire { get; private set; } = true;
 
/// <summary>
/// 临时存储攻击目标, 获取该值请调用 GetAttackTarget() 函数
/// </summary>
protected Role AttackTarget { get; set; } = null;
 
public override void OnInit()
{
base.OnInit();
/// 获取攻击的目标对象, 当 HasAttackDesire 为 true 时才会调用
/// </summary>
public virtual Role GetAttackTarget()
{
return World.Player;
if (AttackTarget == null || AttackTarget.IsDestroyed || !IsEnemy(AttackTarget))
{
foreach (var role in World.Role_InstanceList)
{
if (role.AffiliationArea == AffiliationArea && IsEnemy(role))
{
AttackTarget = role;
break;
}
}
}
return AttackTarget;
}
/// <summary>
/// 返回地上的武器是否有可以拾取的, 也包含没有被其他敌人标记的武器
View
DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs