diff --git a/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs b/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs
index 0b340b8..b084398 100644
--- a/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs
+++ b/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs
@@ -25,7 +25,10 @@
///
/// 武器属性数据
///
- public WeaponAttribute Attribute { get; private set; }
+ public WeaponAttribute Attribute => _weaponAttribute;
+
+ private WeaponAttribute _weaponAttribute;
+ private WeaponAttribute _originWeaponAttribute;
///
/// 武器攻击的目标阵营
@@ -173,7 +176,8 @@
public Weapon(string typeId, WeaponAttribute attribute) : base(attribute.WeaponPrefab)
{
TypeId = typeId;
- Attribute = attribute;
+ _originWeaponAttribute = attribute;
+ _weaponAttribute = attribute;
FirePoint = GetNode("WeaponBody/FirePoint");
OriginPoint = GetNode("WeaponBody/OriginPoint");
@@ -960,6 +964,14 @@
public void PickUpWeapon(Role master)
{
Master = master;
+ if (master.IsAi && _originWeaponAttribute.AiUseAttribute != null)
+ {
+ _weaponAttribute = _originWeaponAttribute.AiUseAttribute;
+ }
+ else
+ {
+ _weaponAttribute = _originWeaponAttribute;
+ }
//握把位置
AnimatedSprite.Position = Attribute.HoldPosition;
//停止动画
@@ -981,6 +993,7 @@
public void RemoveAt()
{
Master = null;
+ _weaponAttribute = _originWeaponAttribute;
AnimatedSprite.Position = Attribute.CenterPosition;
OnRemove();
}
diff --git a/DungeonShooting_Godot/src/game/item/weapon/WeaponAttribute.cs b/DungeonShooting_Godot/src/game/item/weapon/WeaponAttribute.cs
index 33d6c8e..6dcd00a 100644
--- a/DungeonShooting_Godot/src/game/item/weapon/WeaponAttribute.cs
+++ b/DungeonShooting_Godot/src/game/item/weapon/WeaponAttribute.cs
@@ -1,3 +1,4 @@
+using System;
using Godot;
///
@@ -167,7 +168,10 @@
public float UpliftAngleRestore = 1f;
//------------------------------ Ai相关 -----------------------------
+
+ public WeaponAttribute AiUseAttribute;
- //public bool Ai
-
+ public AiFireCallback OnAiFireCallback;
+
+ public delegate void AiFireCallback(Enemy enemy, Weapon weapon);
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/role/Role.cs b/DungeonShooting_Godot/src/game/role/Role.cs
index 3ad8117..4881aa4 100644
--- a/DungeonShooting_Godot/src/game/role/Role.cs
+++ b/DungeonShooting_Godot/src/game/role/Role.cs
@@ -7,6 +7,11 @@
public abstract partial class Role : ActivityObject
{
///
+ /// 是否是 Ai
+ ///
+ public bool IsAi { get; protected set; } = false;
+
+ ///
/// 默认攻击对象层级
///
public const uint DefaultAttackLayer = PhysicsLayer.Player | PhysicsLayer.Enemy | PhysicsLayer.Wall | PhysicsLayer.Props;
diff --git a/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs b/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs
index a3b5c66..2362374 100644
--- a/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs
+++ b/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs
@@ -71,6 +71,7 @@
public Enemy() : base(ResourcePath.prefab_role_Enemy_tscn)
{
+ IsAi = true;
StateController = AddComponent>();
AttackLayer = PhysicsLayer.Wall | PhysicsLayer.Props | PhysicsLayer.Player;