diff --git a/DungeonShooting_Godot/prefab/role/Enemy0001.tscn b/DungeonShooting_Godot/prefab/role/Enemy0001.tscn
index 923ba15..6f76541 100644
--- a/DungeonShooting_Godot/prefab/role/Enemy0001.tscn
+++ b/DungeonShooting_Godot/prefab/role/Enemy0001.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=12 format=3 uid="uid://b8s1dgu63fddf"]
+[gd_scene load_steps=13 format=3 uid="uid://b8s1dgu63fddf"]
[ext_resource type="PackedScene" uid="uid://dbrig6dq441wo" path="res://prefab/role/template/EnemyTemplate.tscn" id="1_2vqwe"]
[ext_resource type="Script" path="res://src/game/activity/role/enemy/Enemy.cs" id="2_0pcq3"]
@@ -27,6 +27,9 @@
shader_parameter/outline_rainbow = false
shader_parameter/outline_use_blend = true
+[sub_resource type="RectangleShape2D" id="RectangleShape2D_rkrey"]
+size = Vector2(12, 18)
+
[sub_resource type="Animation" id="Animation_0l5k0"]
length = 0.001
tracks/0/type = "value"
@@ -296,6 +299,9 @@
material = SubResource("ShaderMaterial_2kup1")
sprite_frames = ExtResource("4_qv8w5")
+[node name="HurtCollision" parent="HurtArea" index="0"]
+shape = SubResource("RectangleShape2D_rkrey")
+
[node name="AnimationPlayer" parent="." index="10"]
libraries = {
"": SubResource("AnimationLibrary_ur1ug")
diff --git a/DungeonShooting_Godot/prefab/role/Enemy0002.tscn b/DungeonShooting_Godot/prefab/role/Enemy0002.tscn
new file mode 100644
index 0000000..1e08932
--- /dev/null
+++ b/DungeonShooting_Godot/prefab/role/Enemy0002.tscn
@@ -0,0 +1,80 @@
+[gd_scene load_steps=7 format=3 uid="uid://qqktspyolb34"]
+
+[ext_resource type="PackedScene" uid="uid://cyrcv2jdgr8cf" path="res://prefab/role/template/RoleTemplate.tscn" id="1_coayb"]
+[ext_resource type="Script" path="res://src/game/activity/role/enemy/NoWeaponEnemy.cs" id="2_3an4s"]
+[ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="2_yunbp"]
+[ext_resource type="SpriteFrames" uid="uid://ctpkpxgcwb583" path="res://resource/spriteFrames/role/Enemy0002.tres" id="3_hbsqi"]
+
+[sub_resource type="ShaderMaterial" id="ShaderMaterial_8vxx6"]
+resource_local_to_scene = true
+shader = ExtResource("2_yunbp")
+shader_parameter/blend = Color(0, 0, 0, 0.470588)
+shader_parameter/schedule = 1.0
+shader_parameter/modulate = Color(1, 1, 1, 1)
+shader_parameter/show_outline = true
+shader_parameter/outline_color = Color(0, 0, 0, 1)
+shader_parameter/outline_rainbow = false
+shader_parameter/outline_use_blend = true
+
+[sub_resource type="ShaderMaterial" id="ShaderMaterial_k8mt5"]
+resource_local_to_scene = true
+shader = ExtResource("2_yunbp")
+shader_parameter/blend = Color(1, 1, 1, 1)
+shader_parameter/schedule = 0.0
+shader_parameter/modulate = Color(1, 1, 1, 1)
+shader_parameter/show_outline = true
+shader_parameter/outline_color = Color(0, 0, 0, 1)
+shader_parameter/outline_rainbow = false
+shader_parameter/outline_use_blend = true
+
+[node name="Enemy0002" node_paths=PackedStringArray("ViewRay", "NavigationAgent2D", "NavigationPoint", "HurtArea", "HurtCollision", "InteractiveArea", "InteractiveCollision", "TipRoot", "TipSprite", "AnimationPlayer", "MountPoint", "BackMountPoint", "MeleeAttackArea", "MeleeAttackCollision", "ShadowSprite", "AnimatedSprite", "Collision") instance=ExtResource("1_coayb")]
+collision_layer = 16
+collision_mask = 25
+script = ExtResource("2_3an4s")
+CanPickUpWeapon = false
+ViewRay = NodePath("ViewRay")
+NavigationAgent2D = NodePath("NavigationPoint/NavigationAgent2D")
+NavigationPoint = NodePath("NavigationPoint")
+HurtArea = NodePath("HurtArea")
+HurtCollision = NodePath("HurtArea/HurtCollision")
+InteractiveArea = NodePath("InteractiveArea")
+InteractiveCollision = NodePath("InteractiveArea/InteractiveCollision")
+TipRoot = NodePath("TipRoot")
+TipSprite = NodePath("TipRoot/TipSprite")
+AnimationPlayer = NodePath("AnimationPlayer")
+MountPoint = NodePath("MountPoint")
+BackMountPoint = NodePath("BackMountPoint")
+MeleeAttackArea = NodePath("MountPoint/MeleeAttackArea")
+MeleeAttackCollision = NodePath("MountPoint/MeleeAttackArea/MeleeAttackCollision")
+ShadowSprite = NodePath("ShadowSprite")
+AnimatedSprite = NodePath("AnimatedSprite")
+Collision = NodePath("Collision")
+
+[node name="ShadowSprite" parent="." index="0"]
+material = SubResource("ShaderMaterial_8vxx6")
+
+[node name="BackMountPoint" parent="." index="1"]
+position = Vector2(-2, -7)
+
+[node name="AnimatedSprite" parent="." index="2"]
+material = SubResource("ShaderMaterial_k8mt5")
+sprite_frames = ExtResource("3_hbsqi")
+offset = Vector2(0, -10)
+
+[node name="HurtCollision" parent="HurtArea" index="0"]
+position = Vector2(-0.5, -7)
+
+[node name="ViewRay" type="RayCast2D" parent="." index="6"]
+position = Vector2(0, -8)
+enabled = false
+
+[node name="MountPoint" parent="." index="7"]
+position = Vector2(6, -8)
+
+[node name="NavigationPoint" type="Marker2D" parent="." index="8"]
+position = Vector2(0, -5)
+
+[node name="NavigationAgent2D" type="NavigationAgent2D" parent="NavigationPoint" index="0"]
+path_desired_distance = 3.0
+target_desired_distance = 3.0
+radius = 20.0
diff --git a/DungeonShooting_Godot/prefab/role/Role0001.tscn b/DungeonShooting_Godot/prefab/role/Role0001.tscn
index 43ea2ef..65015c6 100644
--- a/DungeonShooting_Godot/prefab/role/Role0001.tscn
+++ b/DungeonShooting_Godot/prefab/role/Role0001.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=7 format=3 uid="uid://cxhrcytrx0kcf"]
+[gd_scene load_steps=8 format=3 uid="uid://cxhrcytrx0kcf"]
[ext_resource type="PackedScene" uid="uid://cyrcv2jdgr8cf" path="res://prefab/role/template/RoleTemplate.tscn" id="1_10c2n"]
[ext_resource type="Script" path="res://src/game/activity/role/player/Player.cs" id="2_6xwnt"]
@@ -27,6 +27,9 @@
shader_parameter/outline_rainbow = false
shader_parameter/outline_use_blend = true
+[sub_resource type="RectangleShape2D" id="RectangleShape2D_ve262"]
+size = Vector2(12, 18)
+
[node name="Role0001" node_paths=PackedStringArray("HurtArea", "HurtCollision", "InteractiveArea", "InteractiveCollision", "TipRoot", "TipSprite", "AnimationPlayer", "MountPoint", "BackMountPoint", "MeleeAttackArea", "MeleeAttackCollision", "ShadowSprite", "AnimatedSprite", "Collision") instance=ExtResource("1_10c2n")]
collision_layer = 8
script = ExtResource("2_6xwnt")
@@ -52,3 +55,6 @@
material = SubResource("ShaderMaterial_8hgu2")
sprite_frames = ExtResource("4_galcc")
frame_progress = 0.658799
+
+[node name="HurtCollision" parent="HurtArea" index="0"]
+shape = SubResource("RectangleShape2D_ve262")
diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start2/Preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start2/Preinstall.json
index ae80ce0..571aa13 100644
--- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start2/Preinstall.json
+++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start2/Preinstall.json
@@ -1 +1 @@
-[{"Name":"test1","Weight":100,"Remark":"","WaveList":[[{"Position":{"X":0,"Y":0},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]},{"Position":{"X":16,"Y":26},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0003","Weight":100,"Attr":{"CurrAmmon":"12","ResidueAmmo":"90"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-16,"Y":25},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":37,"Y":-13},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"30","ResidueAmmo":"210"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-11,"Y":-12},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0009","Weight":100,"Attr":{"CurrAmmon":"1","ResidueAmmo":"25"},"Altitude":8,"VerticalSpeed":0}]}],[{"Position":{"X":10,"Y":-39},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":2,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-48,"Y":0},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":"weapon0002","CurrAmmon":"7","ResidueAmmo":"7"},"Altitude":0,"VerticalSpeed":0}]}]]}]
\ No newline at end of file
+[{"Name":"test1","Weight":100,"Remark":"","WaveList":[[{"Position":{"X":0,"Y":0},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]},{"Position":{"X":16,"Y":26},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0003","Weight":100,"Attr":{"CurrAmmon":"12","ResidueAmmo":"90"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-16,"Y":25},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":37,"Y":-13},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"30","ResidueAmmo":"210"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-11,"Y":-12},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0009","Weight":100,"Attr":{"CurrAmmon":"1","ResidueAmmo":"25"},"Altitude":8,"VerticalSpeed":0}]}],[{"Position":{"X":10,"Y":-39},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":2,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-114,"Y":-5},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0002","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]}]]}]
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/activity/package/Package.cs b/DungeonShooting_Godot/src/game/activity/package/Package.cs
index 301cd98..476b7e5 100644
--- a/DungeonShooting_Godot/src/game/activity/package/Package.cs
+++ b/DungeonShooting_Godot/src/game/activity/package/Package.cs
@@ -76,9 +76,8 @@
{
newArray[i] = packageItem;
}
- else
+ else if (packageItem != null) //溢出的item
{
- //溢出的item
packageItem.OnOverflowItem();
packageItem.Master = null;
packageItem.PackageIndex = -1;
diff --git a/DungeonShooting_Godot/src/game/activity/role/Role.cs b/DungeonShooting_Godot/src/game/activity/role/Role.cs
index 0a22232..3a4e483 100644
--- a/DungeonShooting_Godot/src/game/activity/role/Role.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/Role.cs
@@ -137,12 +137,14 @@
public bool MountLookTarget { get; set; } = true;
///
- /// 是否处于近战攻击中
+ /// 是否处于攻击中, 近战攻击远程攻击都算
///
- public bool IsMeleeAttack { get; private set; }
-
- //近战计时器
- private float _meleeAttackTimer = 0;
+ public bool IsAttack => AttackTimer > 0;
+
+ ///
+ /// 攻击计时器
+ ///
+ public float AttackTimer { get; set; }
///
/// 是否死亡
@@ -440,7 +442,7 @@
//------------------------
WeaponPack = AddComponent>();
- WeaponPack.SetCapacity(4);
+ WeaponPack.SetCapacity(2);
MountPoint.Master = this;
@@ -458,9 +460,9 @@
return;
}
- if (_meleeAttackTimer > 0)
+ if (AttackTimer > 0)
{
- _meleeAttackTimer -= delta;
+ AttackTimer -= delta;
}
//检查可互动的物体
@@ -1020,7 +1022,7 @@
///
/// 返回所有武器是否弹药都打光了
///
- public bool IsAllWeaponTotalAmmoEmpty()
+ public virtual bool IsAllWeaponTotalAmmoEmpty()
{
foreach (var weapon in WeaponPack.ItemSlot)
{
@@ -1155,7 +1157,7 @@
///
public virtual void Attack()
{
- if (!IsMeleeAttack && WeaponPack.ActiveItem != null)
+ if (!IsAttack && WeaponPack.ActiveItem != null)
{
WeaponPack.ActiveItem.Trigger(this);
}
@@ -1166,23 +1168,20 @@
///
public virtual void MeleeAttack()
{
- if (IsMeleeAttack || _meleeAttackTimer > 0)
+ if (IsAttack || AttackTimer > 0)
{
return;
}
if (WeaponPack.ActiveItem != null && WeaponPack.ActiveItem.Attribute.CanMeleeAttack)
{
- IsMeleeAttack = true;
- _meleeAttackTimer = RoleState.MeleeAttackTime;
+ AttackTimer = RoleState.MeleeAttackTime;
MountLookTarget = false;
- //WeaponPack.ActiveItem.TriggerMeleeAttack(this);
//播放近战动画
PlayAnimation_MeleeAttack(() =>
{
MountLookTarget = true;
- IsMeleeAttack = false;
});
}
}
diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs
index 3bb3691..4876e62 100644
--- a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs
@@ -36,7 +36,7 @@
public float ViewRange { get; set; } = 250;
///
- /// 发现玩家后的视野半径
+ /// 发现玩家后跟随玩家的视野半径
///
public float TailAfterViewRange { get; set; } = 400;
@@ -46,27 +46,38 @@
public float BackViewRange { get; set; } = 50;
///
+ /// 是否可以拾起武器
+ ///
+ [Export]
+ public bool CanPickUpWeapon { get; set; } = true;
+
+ ///
/// 视野检测射线, 朝玩家打射线, 检测是否碰到墙
///
[Export, ExportFillNode]
- public RayCast2D ViewRay { get; private set; }
+ public RayCast2D ViewRay { get; set; }
///
/// 导航代理
///
[Export, ExportFillNode]
- public NavigationAgent2D NavigationAgent2D { get; private set; }
+ public NavigationAgent2D NavigationAgent2D { get; set; }
///
/// 导航代理中点
///
[Export, ExportFillNode]
- public Marker2D NavigationPoint { get; private set; }
+ public Marker2D NavigationPoint { get; set; }
///
/// 当前敌人所看向的对象, 也就是枪口指向的对象
///
public ActivityObject LookTarget { get; set; }
+
+ ///
+ /// 攻击锁定目标时间
+ ///
+ public float LockingTime { get; set; } = 1f;
///
/// 锁定目标已经走过的时间
@@ -77,6 +88,12 @@
{
base.OnInit();
IsAi = true;
+
+ if (!CanPickUpWeapon)
+ {
+ WeaponPack.SetCapacity(0);
+ }
+
StateController = AddComponent>();
AttackLayer = PhysicsLayer.Wall | PhysicsLayer.Player;
@@ -88,11 +105,8 @@
MaxHp = 20;
Hp = 20;
- //PathSign = new PathSign(this, PathSignLength, GameApplication.Instance.Node3D.Player);
-
//注册Ai状态机
StateController.Register(new AiNormalState());
- //StateController.Register(new AiProbeState());
StateController.Register(new AiTailAfterState());
StateController.Register(new AiFollowUpState());
StateController.Register(new AiLeaveForState());
@@ -180,6 +194,15 @@
EnemyPickUpWeapon();
}
+ public override bool IsAllWeaponTotalAmmoEmpty()
+ {
+ if (!CanPickUpWeapon)
+ {
+ return false;
+ }
+ return base.IsAllWeaponTotalAmmoEmpty();
+ }
+
protected override void OnHit(ActivityObject target, int damage, float angle, bool realHarm)
{
//受到伤害
@@ -357,7 +380,7 @@
{
//这几个状态不需要主动拾起武器操作
var state = StateController.CurrState;
- if (state == AIStateEnum.AiNormal)
+ if (state == AIStateEnum.AiNormal || state == AIStateEnum.AiNotify || state == AIStateEnum.AiAstonished || state == AIStateEnum.AiAttack)
{
return;
}
@@ -414,19 +437,11 @@
var weapon = WeaponPack.ActiveItem;
if (weapon == null)
{
- return 0;
+ return LockingTime - LockTargetTime;
}
return weapon.Attribute.AiAttackAttr.LockingTime - LockTargetTime;
}
- ///
- /// 强制设置锁定目标时间
- ///
- public void SetLockTargetTime(float time)
- {
- LockTargetTime = time;
- }
-
public override void LookTargetPosition(Vector2 pos)
{
LookTarget = null;
diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs
index b2da111..b66c3ab 100644
--- a/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs
@@ -7,5 +7,8 @@
[Tool]
public partial class NoWeaponEnemy : Enemy
{
-
+ public override void Attack()
+ {
+ Debug.Log("attack...");
+ }
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiAttackState.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiAttackState.cs
index 2f0b18e..128ec1a 100644
--- a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiAttackState.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiAttackState.cs
@@ -32,6 +32,8 @@
private Vector2 _prevPos;
//卡在一个位置的时间
private float _lockTimer;
+ //进入状态的时候是否有武器
+ private bool _hasWeapon = true;
public AiAttackState() : base(AIStateEnum.AiAttack)
{
@@ -45,15 +47,22 @@
}
var weapon = Master.WeaponPack.ActiveItem;
- if (weapon == null)
- {
- throw new Exception("进入 AIAdvancedStateEnum.AiAttack 状态时角色没有武器!");
+ if (weapon != null)
+ {
+ _hasWeapon = true;
+ if (!weapon.TriggerIsReady())
+ {
+ throw new Exception("进入 AIAdvancedStateEnum.AiAttack 状态时角色武器还无法触动扳机!");
+ }
}
-
- if (!weapon.TriggerIsReady())
+ else
{
- throw new Exception("进入 AIAdvancedStateEnum.AiAttack 状态时角色武器还玩法触动扳机!");
+ _hasWeapon = false;
+ if (Master.IsAttack)
+ {
+ throw new Exception("进入 AIAdvancedStateEnum.AiAttack 状态时角色攻击状态还没准备好");
+ }
}
Master.BasisVelocity = Vector2.Zero;
@@ -76,7 +85,20 @@
{
//更新标记位置
Master.UpdateMarkTargetPosition();
-
+
+ if (_hasWeapon)
+ {
+ WeaponRoleProcess(delta);
+ }
+ else
+ {
+ NoWeaponRoleProcess(delta);
+ }
+ }
+
+ //有武器的敌人更新逻辑
+ private void WeaponRoleProcess(float delta)
+ {
var weapon = Master.WeaponPack.ActiveItem;
if (weapon == null)
{
@@ -114,8 +136,8 @@
else //攻击状态
{
//触发扳机
- AttackState = Master.WeaponPack.ActiveItem.AiTriggerAttackState();
-
+ AttackState = weapon.AiTriggerAttackState();
+
if (AttackState == AiAttackEnum.LockingTime) //锁定玩家状态
{
Master.LockTargetTime += delta;
@@ -188,6 +210,25 @@
}
}
+ //没有武器的敌人攻击逻辑
+ private void NoWeaponRoleProcess(float delta)
+ {
+ var weapon = Master.WeaponPack.ActiveItem;
+ if (weapon != null)
+ {
+ //找到武器了, 攻击结束
+ ChangeState(PrevState);
+ }
+ else if (AttackState == AiAttackEnum.AttackInterval) //攻击结束
+ {
+
+ }
+ else //攻击状态
+ {
+ Master.Attack();
+ }
+ }
+
private void MoveHandler(float delta)
{
diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiFollowUpState.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiFollowUpState.cs
index e107a5e..bb0c5f3 100644
--- a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiFollowUpState.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiFollowUpState.cs
@@ -70,6 +70,10 @@
{
inAttackRange = distanceSquared <= Mathf.Pow(Master.GetWeaponRange(0.7f), 2);
}
+ else
+ {
+ inAttackRange = distanceSquared <= Mathf.Pow(Master.ViewRange * 0.7f, 2);
+ }
if (!Master.NavigationAgent2D.IsNavigationFinished())
{
@@ -101,15 +105,31 @@
Master.UpdateMarkTargetPosition();
if (inAttackRange) //在攻击范围内
{
- //距离够近, 可以切换到环绕模式
- if (distanceSquared <= Mathf.Pow(Utils.GetConfigRangeStart(weapon.Attribute.Bullet.DistanceRange), 2) * 0.7f)
+ if (weapon != null)
{
- ChangeState(AIStateEnum.AiSurround);
+ //距离够近, 可以切换到环绕模式
+ if (distanceSquared <= Mathf.Pow(Utils.GetConfigRangeStart(weapon.Attribute.Bullet.DistanceRange) * 0.7f, 2))
+ {
+ ChangeState(AIStateEnum.AiSurround);
+ }
+ else if (weapon.TriggerIsReady()) //可以攻击
+ {
+ //攻击状态
+ ChangeState(AIStateEnum.AiAttack);
+ }
}
- else if (weapon.TriggerIsReady()) //可以攻击
+ else
{
- //攻击状态
- ChangeState(AIStateEnum.AiAttack);
+ //距离够近, 可以切换到环绕模式
+ if (distanceSquared <= Mathf.Pow(Master.ViewRange * 0.7f, 2))
+ {
+ ChangeState(AIStateEnum.AiSurround);
+ }
+ else if (!Master.IsAttack) //可以攻击
+ {
+ //攻击状态
+ ChangeState(AIStateEnum.AiAttack);
+ }
}
}
}
diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiSurroundState.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiSurroundState.cs
index c9a8f6e..88aae7d 100644
--- a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiSurroundState.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiSurroundState.cs
@@ -56,7 +56,6 @@
}
var playerPos = Master.LookTarget.GetCenterPosition();
- var weapon = Master.WeaponPack.ActiveItem;
//检测玩家是否在视野内
if (Master.IsInTailAfterViewRange(playerPos))
@@ -137,6 +136,7 @@
}
}
+ var weapon = Master.WeaponPack.ActiveItem;
if (weapon != null)
{
if (masterPosition.DistanceSquaredTo(playerPos) > Mathf.Pow(Master.GetWeaponRange(0.7f), 2)) //玩家离开正常射击范围
@@ -149,6 +149,18 @@
ChangeState(AIStateEnum.AiAttack);
}
}
+ else
+ {
+ if (masterPosition.DistanceSquaredTo(playerPos) > Mathf.Pow(Master.ViewRange * 0.7f, 2)) //玩家离开正常射击范围
+ {
+ ChangeState(AIStateEnum.AiFollowUp);
+ }
+ else if (!Master.IsAttack) //可以攻击
+ {
+ //攻击状态
+ ChangeState(AIStateEnum.AiAttack);
+ }
+ }
}
}
else //目标离开视野
diff --git a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs
index 87cf9c4..c29158d 100644
--- a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs
@@ -52,6 +52,8 @@
MaxShield = 0;
Shield = 0;
+ WeaponPack.SetCapacity(4);
+
// debug用
// RoleState.Acceleration = 3000;
// RoleState.Friction = 3000;
diff --git a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs
index 5c9ffe8..b54c0b3 100644
--- a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs
+++ b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs
@@ -1977,7 +1977,7 @@
enemy.Attack();
if (_attackFlag)
{
- enemy.SetLockTargetTime(0);
+ enemy.LockingTime = 0;
}
}
else
@@ -1988,7 +1988,7 @@
enemy.Attack();
if (_attackFlag)
{
- enemy.SetLockTargetTime(0);
+ enemy.LockingTime = 0;
}
}
else //单发
@@ -1997,7 +1997,7 @@
enemy.Attack();
if (_attackFlag)
{
- enemy.SetLockTargetTime(0);
+ enemy.LockingTime = 0;
}
}
}