diff --git a/DungeonShooting_Godot/DungeonShooting.csproj b/DungeonShooting_Godot/DungeonShooting.csproj index 97e725f..672ba00 100644 --- a/DungeonShooting_Godot/DungeonShooting.csproj +++ b/DungeonShooting_Godot/DungeonShooting.csproj @@ -1,4 +1,4 @@ - + net7.0 true diff --git a/DungeonShooting_Godot/resource/animation/enemy/Enemy_astonished.res b/DungeonShooting_Godot/resource/animation/enemy/Enemy_astonished.res index 17db896..715ff3c 100644 --- a/DungeonShooting_Godot/resource/animation/enemy/Enemy_astonished.res +++ b/DungeonShooting_Godot/resource/animation/enemy/Enemy_astonished.res Binary files differ diff --git a/DungeonShooting_Godot/resource/animation/enemy/Enemy_notify.res b/DungeonShooting_Godot/resource/animation/enemy/Enemy_notify.res index f89e556..d1cc298 100644 --- a/DungeonShooting_Godot/resource/animation/enemy/Enemy_notify.res +++ b/DungeonShooting_Godot/resource/animation/enemy/Enemy_notify.res Binary files differ diff --git a/DungeonShooting_Godot/resource/animation/enemy/Enemy_reset.res b/DungeonShooting_Godot/resource/animation/enemy/Enemy_reset.res index 640992e..ef1a612 100644 --- a/DungeonShooting_Godot/resource/animation/enemy/Enemy_reset.res +++ b/DungeonShooting_Godot/resource/animation/enemy/Enemy_reset.res Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/role/common/Role_notify.png b/DungeonShooting_Godot/resource/sprite/role/common/Role_notify.png index b93ffca..f2bddef 100644 --- a/DungeonShooting_Godot/resource/sprite/role/common/Role_notify.png +++ b/DungeonShooting_Godot/resource/sprite/role/common/Role_notify.png Binary files differ diff --git a/DungeonShooting_Godot/resource/spriteFrames/role/Role_tip.tres b/DungeonShooting_Godot/resource/spriteFrames/role/Role_tip.tres index f47c45e..f1a0e7a 100644 --- a/DungeonShooting_Godot/resource/spriteFrames/role/Role_tip.tres +++ b/DungeonShooting_Godot/resource/spriteFrames/role/Role_tip.tres @@ -1,9 +1,49 @@ -[gd_resource type="SpriteFrames" load_steps=4 format=3 uid="uid://c8h5svp76h3kw"] +[gd_resource type="SpriteFrames" load_steps=14 format=3 uid="uid://c8h5svp76h3kw"] [ext_resource type="Texture2D" uid="uid://b75k7hefqy3tm" path="res://resource/sprite/role/common/Role_astonished.png" id="1_tbb6m"] [ext_resource type="Texture2D" uid="uid://6jka6itu76x7" path="res://resource/sprite/role/common/Role_notify.png" id="2_0e3tg"] [ext_resource type="Texture2D" uid="uid://bda63puujv425" path="res://resource/sprite/role/common/Role_query.png" id="2_70ucj"] +[sub_resource type="AtlasTexture" id="AtlasTexture_fn2rk"] +atlas = ExtResource("2_0e3tg") +region = Rect2(0, 0, 10, 10) + +[sub_resource type="AtlasTexture" id="AtlasTexture_cofxm"] +atlas = ExtResource("2_0e3tg") +region = Rect2(10, 0, 10, 10) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ml0d0"] +atlas = ExtResource("2_0e3tg") +region = Rect2(20, 0, 10, 10) + +[sub_resource type="AtlasTexture" id="AtlasTexture_w7tts"] +atlas = ExtResource("2_0e3tg") +region = Rect2(30, 0, 10, 10) + +[sub_resource type="AtlasTexture" id="AtlasTexture_sfnsa"] +atlas = ExtResource("2_0e3tg") +region = Rect2(40, 0, 10, 10) + +[sub_resource type="AtlasTexture" id="AtlasTexture_i8sk2"] +atlas = ExtResource("2_0e3tg") +region = Rect2(50, 0, 10, 10) + +[sub_resource type="AtlasTexture" id="AtlasTexture_iu1kr"] +atlas = ExtResource("2_0e3tg") +region = Rect2(60, 0, 10, 10) + +[sub_resource type="AtlasTexture" id="AtlasTexture_men28"] +atlas = ExtResource("2_0e3tg") +region = Rect2(70, 0, 10, 10) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mrwdd"] +atlas = ExtResource("2_0e3tg") +region = Rect2(80, 0, 10, 10) + +[sub_resource type="AtlasTexture" id="AtlasTexture_v47to"] +atlas = ExtResource("2_0e3tg") +region = Rect2(90, 0, 10, 10) + [resource] animations = [{ "frames": [{ @@ -21,11 +61,41 @@ }, { "frames": [{ "duration": 1.0, -"texture": ExtResource("2_0e3tg") +"texture": SubResource("AtlasTexture_fn2rk") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_cofxm") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ml0d0") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_w7tts") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_sfnsa") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_i8sk2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_iu1kr") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_men28") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mrwdd") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_v47to") +}, { +"duration": 1.0, +"texture": null }], -"loop": true, +"loop": false, "name": &"notify", -"speed": 5.0 +"speed": 10.0 }, { "frames": [{ "duration": 1.0, diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs index 8b0c9e2..c36937f 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs @@ -210,10 +210,27 @@ { //受到伤害 var state = StateController.CurrState; - if (state == AIStateEnum.AiNormal || state == AIStateEnum.AiLeaveFor) //|| state == AiStateEnum.AiProbe + if (state == AIStateEnum.AiNormal) { LookTarget = target; - StateController.ChangeState(AIStateEnum.AiTailAfter); + //判断是否进入通知状态 + if (World.Enemy_InstanceList.FindIndex(enemy => + enemy != this && !enemy.IsDie && enemy.AffiliationArea == AffiliationArea && + enemy.StateController.CurrState == AIStateEnum.AiNormal) != -1) + { + //进入惊讶状态, 然后再进入通知状态 + StateController.ChangeState(AIStateEnum.AiAstonished, AIStateEnum.AiNotify); + } + else + { + //进入惊讶状态, 然后再进入跟随状态 + StateController.ChangeState(AIStateEnum.AiAstonished, AIStateEnum.AiTailAfter); + } + } + else if (state == AIStateEnum.AiLeaveFor) + { + LookTarget = target; + StateController.ChangeState(AIStateEnum.AiAstonished, AIStateEnum.AiTailAfter); } } diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiAstonishedState.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiAstonishedState.cs index 081f791..50a13be 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiAstonishedState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiAstonishedState.cs @@ -11,8 +11,7 @@ /// 下一个状态 /// public AIStateEnum NextState; - - private object[] _args; + private float _timer; public AiAstonishedState() : base(AIStateEnum.AiAstonished) @@ -29,14 +28,7 @@ } NextState = (AIStateEnum)args[0]; - _args = args; _timer = 0.6f; - - if (NextState == AIStateEnum.AiLeaveFor) - { - var target = (ActivityObject)args[1]; - Master.LookTargetPosition(target.GetCenterPosition()); - } //播放惊讶表情 Master.AnimationPlayer.Play(AnimatorNames.Astonished); @@ -48,18 +40,7 @@ _timer -= delta; if (_timer <= 0) { - if (_args.Length == 1) - { - ChangeState(NextState); - } - else if (_args.Length == 2) - { - ChangeState(NextState, _args[1]); - } - else if (_args.Length == 3) - { - ChangeState(NextState, _args[1], _args[2]); - } + ChangeState(NextState); } } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiLeaveForState.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiLeaveForState.cs index d5bc087..2ec0526 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiLeaveForState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiLeaveForState.cs @@ -55,6 +55,9 @@ { Master.AnimationPlayer.Play(AnimatorNames.Query); } + + //看向目标位置 + Master.LookTargetPosition(_target.GetCenterPosition()); } public override void Exit(AIStateEnum next) diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiNormalState.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiNormalState.cs index be8f86e..c4635c9 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiNormalState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiNormalState.cs @@ -1,4 +1,5 @@ +using System.Linq; using Godot; namespace EnemyState; @@ -56,8 +57,19 @@ Master.TestViewRayCastOver(); //发现玩家 Master.LookTarget = player; - //进入惊讶状态, 然后再进入通知状态 - ChangeState(AIStateEnum.AiAstonished, AIStateEnum.AiNotify); + //判断是否进入通知状态 + if (Master.World.Enemy_InstanceList.FindIndex(enemy => + enemy != Master && !enemy.IsDie && enemy.AffiliationArea == Master.AffiliationArea && + enemy.StateController.CurrState == AIStateEnum.AiNormal) != -1) + { + //进入惊讶状态, 然后再进入通知状态 + ChangeState(AIStateEnum.AiAstonished, AIStateEnum.AiNotify); + } + else + { + //进入惊讶状态, 然后再进入跟随状态 + ChangeState(AIStateEnum.AiAstonished, AIStateEnum.AiTailAfter); + } return; } else if (_pauseTimer >= 0) diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiNotifyState.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiNotifyState.cs index d7c199e..09a6b08 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiNotifyState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiNotifyState.cs @@ -19,7 +19,7 @@ { throw new Exception("进入 AIAdvancedStateEnum.AiNotify 没有攻击目标!"); } - _timer = 0.6f; + _timer = 1.2f; //通知其它角色 Master.World.NotifyEnemyTarget(Master, Master.LookTarget); Master.AnimationPlayer.Play(AnimatorNames.Notify); diff --git a/DungeonShooting_Godot/src/game/room/World.cs b/DungeonShooting_Godot/src/game/room/World.cs index e45156c..35673f9 100644 --- a/DungeonShooting_Godot/src/game/room/World.cs +++ b/DungeonShooting_Godot/src/game/room/World.cs @@ -114,10 +114,14 @@ { //将未发现目标的敌人状态置为惊讶状态 var controller = role.StateController; - if (controller.CurrState == AIStateEnum.AiNormal) + //延时通知效果 + role.CallDelay(Utils.Random.RandomRangeFloat(0.2f, 1f), () => { - controller.ChangeState(AIStateEnum.AiLeaveFor, target); - } + if (controller.CurrState == AIStateEnum.AiNormal) + { + controller.ChangeState(AIStateEnum.AiLeaveFor, target); + } + }); } } }