diff --git a/DungeonShooting_Godot/prefab/role/Enemy0001.tscn b/DungeonShooting_Godot/prefab/role/Enemy0001.tscn
index 7326d5a..deb7e34 100644
--- a/DungeonShooting_Godot/prefab/role/Enemy0001.tscn
+++ b/DungeonShooting_Godot/prefab/role/Enemy0001.tscn
@@ -1,9 +1,11 @@
-[gd_scene load_steps=7 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/AdvancedEnemyTemplate.tscn" id="1_2vqwe"]
[ext_resource type="Script" path="res://src/game/activity/role/enemy/AdvancedEnemy.cs" id="2_thbey"]
[ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="3_x8agd"]
[ext_resource type="SpriteFrames" uid="uid://cnctpyrn02rhd" path="res://resource/spriteFrames/role/Enemy0001.tres" id="4_qv8w5"]
+[ext_resource type="Texture2D" uid="uid://b75k7hefqy3tm" path="res://resource/sprite/role/common/Role_astonished.png" id="5_0p4q8"]
+[ext_resource type="Texture2D" uid="uid://6jka6itu76x7" path="res://resource/sprite/role/common/Role_notify.png" id="6_70bey"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_f7y56"]
resource_local_to_scene = true
@@ -27,11 +29,102 @@
shader_parameter/outline_rainbow = false
shader_parameter/outline_use_blend = true
-[node name="Enemy0001" node_paths=PackedStringArray("ViewRay", "NavigationAgent2D", "NavigationPoint", "MountPoint", "BackMountPoint", "MeleeAttackArea", "MeleeAttackCollision", "HurtArea", "HurtCollision", "InteractiveArea", "InteractiveCollision", "ShadowSprite", "AnimatedSprite", "Collision") instance=ExtResource("1_2vqwe")]
+[sub_resource type="Animation" id="Animation_nb4pe"]
+resource_name = "astonished"
+length = 0.6
+tracks/0/type = "value"
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/path = NodePath("TipSprite:visible")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/keys = {
+"times": PackedFloat32Array(0, 0.6),
+"transitions": PackedFloat32Array(1, 1),
+"update": 1,
+"values": [true, false]
+}
+tracks/1/type = "value"
+tracks/1/imported = false
+tracks/1/enabled = true
+tracks/1/path = NodePath("TipSprite:texture")
+tracks/1/interp = 1
+tracks/1/loop_wrap = true
+tracks/1/keys = {
+"times": PackedFloat32Array(0),
+"transitions": PackedFloat32Array(1),
+"update": 1,
+"values": [ExtResource("5_0p4q8")]
+}
+
+[sub_resource type="Animation" id="Animation_0l5k0"]
+length = 0.001
+tracks/0/type = "value"
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/path = NodePath("TipSprite:visible")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/keys = {
+"times": PackedFloat32Array(0),
+"transitions": PackedFloat32Array(1),
+"update": 1,
+"values": [false]
+}
+tracks/1/type = "value"
+tracks/1/imported = false
+tracks/1/enabled = true
+tracks/1/path = NodePath("TipSprite:texture")
+tracks/1/interp = 1
+tracks/1/loop_wrap = true
+tracks/1/keys = {
+"times": PackedFloat32Array(0),
+"transitions": PackedFloat32Array(1),
+"update": 1,
+"values": [ExtResource("5_0p4q8")]
+}
+
+[sub_resource type="Animation" id="Animation_5mflw"]
+resource_name = "notify"
+length = 0.6
+tracks/0/type = "value"
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/path = NodePath("TipSprite:texture")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/keys = {
+"times": PackedFloat32Array(0),
+"transitions": PackedFloat32Array(1),
+"update": 1,
+"values": [ExtResource("6_70bey")]
+}
+tracks/1/type = "value"
+tracks/1/imported = false
+tracks/1/enabled = true
+tracks/1/path = NodePath("TipSprite:visible")
+tracks/1/interp = 1
+tracks/1/loop_wrap = true
+tracks/1/keys = {
+"times": PackedFloat32Array(0, 0.6),
+"transitions": PackedFloat32Array(1, 1),
+"update": 1,
+"values": [true, false]
+}
+
+[sub_resource type="AnimationLibrary" id="AnimationLibrary_ur1ug"]
+_data = {
+"RESET": SubResource("Animation_0l5k0"),
+"astonished": SubResource("Animation_nb4pe"),
+"notify": SubResource("Animation_5mflw")
+}
+
+[node name="Enemy0001" node_paths=PackedStringArray("ViewRay", "NavigationAgent2D", "NavigationPoint", "TipSprite", "MountPoint", "BackMountPoint", "MeleeAttackArea", "MeleeAttackCollision", "HurtArea", "HurtCollision", "InteractiveArea", "InteractiveCollision", "AnimationPlayer", "ShadowSprite", "AnimatedSprite", "Collision") instance=ExtResource("1_2vqwe")]
script = ExtResource("2_thbey")
ViewRay = NodePath("ViewRay")
NavigationAgent2D = NodePath("NavigationPoint/NavigationAgent2D")
NavigationPoint = NodePath("NavigationPoint")
+TipSprite = NodePath("TipSprite")
MountPoint = NodePath("MountPoint")
BackMountPoint = NodePath("BackMountPoint")
MeleeAttackArea = NodePath("MountPoint/MeleeAttackArea")
@@ -40,6 +133,7 @@
HurtCollision = NodePath("HurtArea/HurtCollision")
InteractiveArea = NodePath("InteractiveArea")
InteractiveCollision = NodePath("InteractiveArea/InteractiveCollision")
+AnimationPlayer = NodePath("AnimationPlayer")
ShadowSprite = NodePath("ShadowSprite")
AnimatedSprite = NodePath("AnimatedSprite")
Collision = NodePath("Collision")
@@ -50,3 +144,11 @@
[node name="AnimatedSprite" parent="." index="2"]
material = SubResource("ShaderMaterial_2kup1")
sprite_frames = ExtResource("4_qv8w5")
+
+[node name="TipSprite" parent="." index="9"]
+position = Vector2(0, -28)
+
+[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
index bebc437..25fefed 100644
--- a/DungeonShooting_Godot/prefab/role/Enemy0002.tscn
+++ b/DungeonShooting_Godot/prefab/role/Enemy0002.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=10 format=3 uid="uid://b5r3hd8kv2wmd"]
+[gd_scene load_steps=7 format=3 uid="uid://b5r3hd8kv2wmd"]
[ext_resource type="PackedScene" uid="uid://dxeqcssparqoo" path="res://prefab/role/template/EnemyTemplate.tscn" id="1_rikvp"]
[ext_resource type="Script" path="res://src/game/activity/role/enemy/Enemy.cs" id="2_wjtfl"]
@@ -27,82 +27,7 @@
shader_parameter/outline_rainbow = false
shader_parameter/outline_use_blend = true
-[sub_resource type="Animation" id="Animation_g3he5"]
-resource_name = "attack"
-length = 0.6
-tracks/0/type = "value"
-tracks/0/imported = false
-tracks/0/enabled = true
-tracks/0/path = NodePath("AnimatedSprite:animation")
-tracks/0/interp = 1
-tracks/0/loop_wrap = true
-tracks/0/keys = {
-"times": PackedFloat32Array(0),
-"transitions": PackedFloat32Array(1),
-"update": 1,
-"values": [&"attack"]
-}
-tracks/1/type = "value"
-tracks/1/imported = false
-tracks/1/enabled = true
-tracks/1/path = NodePath("AnimatedSprite:frame")
-tracks/1/interp = 1
-tracks/1/loop_wrap = true
-tracks/1/keys = {
-"times": PackedFloat32Array(0, 0.5),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [0, 7]
-}
-tracks/2/type = "method"
-tracks/2/imported = false
-tracks/2/enabled = true
-tracks/2/path = NodePath(".")
-tracks/2/interp = 1
-tracks/2/loop_wrap = true
-tracks/2/keys = {
-"times": PackedFloat32Array(0.3),
-"transitions": PackedFloat32Array(1),
-"values": [{
-"args": [],
-"method": &"Attack"
-}]
-}
-
-[sub_resource type="Animation" id="Animation_4j2gl"]
-length = 0.001
-tracks/0/type = "value"
-tracks/0/imported = false
-tracks/0/enabled = true
-tracks/0/path = NodePath("AnimatedSprite:animation")
-tracks/0/interp = 1
-tracks/0/loop_wrap = true
-tracks/0/keys = {
-"times": PackedFloat32Array(0),
-"transitions": PackedFloat32Array(1),
-"update": 1,
-"values": [&"attack"]
-}
-tracks/1/type = "value"
-tracks/1/imported = false
-tracks/1/enabled = true
-tracks/1/path = NodePath("AnimatedSprite:frame")
-tracks/1/interp = 1
-tracks/1/loop_wrap = true
-tracks/1/keys = {
-"times": PackedFloat32Array(0),
-"transitions": PackedFloat32Array(1),
-"update": 1,
-"values": [0]
-}
-
-[sub_resource type="AnimationLibrary" id="AnimationLibrary_oris7"]
-_data = {
-"RESET": SubResource("Animation_4j2gl"),
-"attack": SubResource("Animation_g3he5")
-}
-
-[node name="Enemy0002" node_paths=PackedStringArray("ViewRay", "NavigationAgent2D", "NavigationPoint", "FirePoint", "HurtArea", "HurtCollision", "InteractiveArea", "InteractiveCollision", "ShadowSprite", "AnimatedSprite", "Collision", "AnimationPlayer") instance=ExtResource("1_rikvp")]
+[node name="Enemy0002" node_paths=PackedStringArray("ViewRay", "NavigationAgent2D", "NavigationPoint", "FirePoint", "HurtArea", "HurtCollision", "InteractiveArea", "InteractiveCollision", "AnimationPlayer", "ShadowSprite", "AnimatedSprite", "Collision") instance=ExtResource("1_rikvp")]
script = ExtResource("2_wjtfl")
ViewRay = NodePath("ViewRay")
NavigationAgent2D = NodePath("NavigationPoint/NavigationAgent2D")
@@ -112,10 +37,10 @@
HurtCollision = NodePath("HurtArea/HurtCollision")
InteractiveArea = NodePath("InteractiveArea")
InteractiveCollision = NodePath("InteractiveArea/InteractiveCollision")
+AnimationPlayer = NodePath("AnimationPlayer")
ShadowSprite = NodePath("ShadowSprite")
AnimatedSprite = NodePath("AnimatedSprite")
Collision = NodePath("Collision")
-AnimationPlayer = NodePath("AnimationPlayer")
[node name="ShadowSprite" parent="." index="0"]
material = SubResource("ShaderMaterial_7theg")
@@ -128,8 +53,3 @@
[node name="FirePoint" type="Marker2D" parent="AnimatedSprite" index="0"]
position = Vector2(9, 4)
-
-[node name="AnimationPlayer" type="AnimationPlayer" parent="." index="7"]
-libraries = {
-"": SubResource("AnimationLibrary_oris7")
-}
diff --git a/DungeonShooting_Godot/prefab/role/template/AdvancedEnemyTemplate.tscn b/DungeonShooting_Godot/prefab/role/template/AdvancedEnemyTemplate.tscn
index b02e44a..e622500 100644
--- a/DungeonShooting_Godot/prefab/role/template/AdvancedEnemyTemplate.tscn
+++ b/DungeonShooting_Godot/prefab/role/template/AdvancedEnemyTemplate.tscn
@@ -1,6 +1,7 @@
-[gd_scene load_steps=5 format=3 uid="uid://dbrig6dq441wo"]
+[gd_scene load_steps=6 format=3 uid="uid://dbrig6dq441wo"]
[ext_resource type="PackedScene" uid="uid://cyrcv2jdgr8cf" path="res://prefab/role/template/AdvancedRoleTemplate.tscn" id="1_5po38"]
+[ext_resource type="Texture2D" uid="uid://b75k7hefqy3tm" path="res://resource/sprite/role/common/Role_astonished.png" id="3_6re6j"]
[ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="3_x8agd"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_8vxx6"]
@@ -46,3 +47,8 @@
path_desired_distance = 3.0
target_desired_distance = 3.0
radius = 20.0
+
+[node name="TipSprite" type="Sprite2D" parent="." index="9"]
+visible = false
+position = Vector2(0, -26)
+texture = ExtResource("3_6re6j")
diff --git a/DungeonShooting_Godot/prefab/role/template/AdvancedRoleTemplate.tscn b/DungeonShooting_Godot/prefab/role/template/AdvancedRoleTemplate.tscn
index 2394511..9e6bb5f 100644
--- a/DungeonShooting_Godot/prefab/role/template/AdvancedRoleTemplate.tscn
+++ b/DungeonShooting_Godot/prefab/role/template/AdvancedRoleTemplate.tscn
@@ -81,3 +81,5 @@
monitorable = false
[node name="MeleeAttackCollision" type="CollisionPolygon2D" parent="MountPoint/MeleeAttackArea"]
+
+[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
diff --git a/DungeonShooting_Godot/prefab/role/template/RoleTemplate.tscn b/DungeonShooting_Godot/prefab/role/template/RoleTemplate.tscn
index ad986de..454bcbd 100644
--- a/DungeonShooting_Godot/prefab/role/template/RoleTemplate.tscn
+++ b/DungeonShooting_Godot/prefab/role/template/RoleTemplate.tscn
@@ -66,3 +66,5 @@
[node name="InteractiveCollision" type="CollisionShape2D" parent="InteractiveArea"]
position = Vector2(0, -5)
shape = SubResource("RectangleShape2D_n68nu")
+
+[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
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 f1e47bd..ae80ce0 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":"enemy0002","Weight":100,"Attr":{"Face":"0","Weapon":null},"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":-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
diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
index 5080d9b..162153c 100644
--- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
+++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
@@ -59,12 +59,6 @@
///
[Export, ExportFillNode]
public CollisionShape2D Collision { get; set; }
-
- ///
- /// 动画播放器
- ///
- [Export, ExportFillNode]
- public AnimationPlayer AnimationPlayer { get; set; }
///
/// 是否调用过 Destroy() 函数
diff --git a/DungeonShooting_Godot/src/game/AnimatorNames.cs b/DungeonShooting_Godot/src/game/AnimatorNames.cs
index 6714285..c78fd7f 100644
--- a/DungeonShooting_Godot/src/game/AnimatorNames.cs
+++ b/DungeonShooting_Godot/src/game/AnimatorNames.cs
@@ -74,4 +74,12 @@
/// 攻击
///
public const string Attack = "attack";
+ ///
+ /// 惊讶动作
+ ///
+ public const string Astonished = "astonished";
+ ///
+ /// 通知动作
+ ///
+ public const string Notify = "notify";
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/activity/bullet/explode/Explode.cs b/DungeonShooting_Godot/src/game/activity/bullet/explode/Explode.cs
index 50a9e22..60922d4 100644
--- a/DungeonShooting_Godot/src/game/activity/bullet/explode/Explode.cs
+++ b/DungeonShooting_Godot/src/game/activity/bullet/explode/Explode.cs
@@ -144,7 +144,7 @@
{
if (o is Role role) //是角色
{
- role.CallDeferred(nameof(role.Hurt), BulletData.TriggerRole, _harm, angle);
+ role.CallDeferred(nameof(role.Hurt), BulletData.TriggerRole.IsDestroyed ? null : BulletData.TriggerRole, _harm, angle);
}
else if (o is Bullet bullet) //是子弹
{
diff --git a/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs b/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs
index 5722fce..3f9a230 100644
--- a/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs
+++ b/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs
@@ -145,7 +145,7 @@
role.MoveController.AddForce(Vector2.FromAngle(Rotation) * BulletData.Repel);
}
//造成伤害
- role.CallDeferred(nameof(Role.Hurt), BulletData.TriggerRole, BulletData.Harm, Rotation);
+ role.CallDeferred(nameof(Role.Hurt), BulletData.TriggerRole.IsDestroyed ? null : BulletData.TriggerRole, BulletData.Harm, Rotation);
}
}
diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs
index 407c461..5491250 100644
--- a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs
+++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs
@@ -146,7 +146,7 @@
}
//造成伤害
- role.CallDeferred(nameof(AdvancedRole.Hurt), BulletData.TriggerRole, BulletData.Harm, Rotation);
+ role.CallDeferred(nameof(AdvancedRole.Hurt), BulletData.TriggerRole.IsDestroyed ? null : BulletData.TriggerRole, BulletData.Harm, Rotation);
//穿透次数
CurrentPenetration++;
diff --git a/DungeonShooting_Godot/src/game/activity/role/Role.cs b/DungeonShooting_Godot/src/game/activity/role/Role.cs
index ee675a6..79b1d58 100644
--- a/DungeonShooting_Godot/src/game/activity/role/Role.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/Role.cs
@@ -72,7 +72,13 @@
[Export, ExportFillNode]
public CollisionShape2D InteractiveCollision { get; set; }
- ///
+ ///
+ /// 动画播放器
+ ///
+ [Export, ExportFillNode]
+ public AnimationPlayer AnimationPlayer { get; set; }
+
+ ///
/// 脸的朝向
///
public FaceDirection Face { get => _face; set => SetFace(value); }
@@ -275,10 +281,11 @@
///
/// 当受伤时调用
///
- /// 谁触发的伤害
+ /// 触发伤害的对象, 为 null 表示不存在对象或者对象已经被销毁
/// 受到的伤害
+ /// 伤害角度(弧度制)
/// 是否受到真实伤害, 如果为false, 则表示该伤害被互动格挡掉了
- protected virtual void OnHit(ActivityObject target, int damage, bool realHarm)
+ protected virtual void OnHit(ActivityObject target, int damage, float angle, bool realHarm)
{
}
@@ -668,7 +675,7 @@
///
/// 受到伤害, 如果是在碰撞信号处理函数中调用该函数, 请使用 CallDeferred 来延时调用, 否则很有可能导致报错
///
- /// 谁触发的伤害
+ /// 触发伤害的对象, 为 null 表示不存在对象或者对象已经被销毁
/// 伤害的量
/// 伤害角度(弧度制)
public virtual void Hurt(ActivityObject target, int damage, float angle)
@@ -700,7 +707,7 @@
// blood.Rotation = angle;
// GameApplication.Instance.Node3D.GetRoot().AddChild(blood);
}
- OnHit(target, damage, !flag);
+ OnHit(target, damage, angle, !flag);
//受伤特效
PlayHitAnimation();
diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/AdvancedEnemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/AdvancedEnemy.cs
index 5052136..f93a65f 100644
--- a/DungeonShooting_Godot/src/game/activity/role/enemy/AdvancedEnemy.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/enemy/AdvancedEnemy.cs
@@ -65,6 +65,12 @@
public Marker2D NavigationPoint { get; private set; }
///
+ /// 用于提示当前敌人状态
+ ///
+ [Export, ExportFillNode]
+ public Sprite2D TipSprite { get; set; }
+
+ ///
/// 当前敌人所看向的对象, 也就是枪口指向的对象
///
public ActivityObject LookTarget { get; set; }
@@ -181,7 +187,7 @@
EnemyPickUpWeapon();
}
- protected override void OnHit(ActivityObject target, int damage, bool realHarm)
+ protected override void OnHit(ActivityObject target, int damage, float angle, bool realHarm)
{
//受到伤害
var state = StateController.CurrState;
diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs
index d97e5f9..1513d7c 100644
--- a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs
@@ -179,17 +179,20 @@
}
}
- protected override void OnHit(ActivityObject target, int damage, bool realHarm)
+ protected override void OnHit(ActivityObject target, int damage, float angle, bool realHarm)
{
//受到伤害
var state = StateController.CurrState;
- if (state == AINormalStateEnum.AiNormal || state == AINormalStateEnum.AiLeaveFor) //|| state == AiStateEnum.AiProbe
- {
- LookTarget = target;
- StateController.ChangeState(AINormalStateEnum.AiTailAfter, target);
- }
+ // if (state == AINormalStateEnum.AiNormal)
+ // {
+ // StateController.ChangeState(AINormalStateEnum.AiLeaveFor, target);
+ // }
+ // else if (state == AINormalStateEnum.AiLeaveFor)
+ // {
+ //
+ // }
}
-
+
protected override void OnDie()
{
var effPos = Position + new Vector2(0, -Altitude);
diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AiAstonishedState.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AiAstonishedState.cs
index bc07574..dae6a74 100644
--- a/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AiAstonishedState.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AiAstonishedState.cs
@@ -37,13 +37,14 @@
var target = (ActivityObject)args[1];
Master.LookTargetPosition(target.GetCenterPosition());
}
+
+ //播放惊讶表情
+ Master.AnimationPlayer.Play(AnimatorNames.Astonished);
}
public override void Process(float delta)
{
Master.DoIdle();
- //播放惊讶表情
-
_timer -= delta;
if (_timer <= 0)
{
diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AiLeaveForState.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AiLeaveForState.cs
index 3383060..16fc162 100644
--- a/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AiLeaveForState.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AiLeaveForState.cs
@@ -40,6 +40,7 @@
var targetWeapon = Master.FindTargetWeapon();
if (targetWeapon != null)
{
+ Master.LookTarget = _target;
ChangeState(AIAdvancedStateEnum.AiFindAmmo, targetWeapon);
}
}
diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AiNotifyState.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AiNotifyState.cs
index b8fe1fa..f1f0c10 100644
--- a/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AiNotifyState.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AiNotifyState.cs
@@ -22,6 +22,7 @@
_timer = 0.6f;
//通知其它角色
Master.World.NotifyEnemyTarget(Master, Master.LookTarget);
+ Master.AnimationPlayer.Play(AnimatorNames.Notify);
}
public override void Process(float delta)
diff --git a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs
index 40e84e3..8dee618 100644
--- a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs
@@ -224,7 +224,7 @@
return 1;
}
- protected override void OnHit(ActivityObject target, int damage, bool realHarm)
+ protected override void OnHit(ActivityObject target, int damage, float angle, bool realHarm)
{
//进入无敌状态
if (realHarm) //真实伤害
diff --git a/DungeonShooting_Godot/src/game/room/DungeonManager.cs b/DungeonShooting_Godot/src/game/room/DungeonManager.cs
index 74d2215..3cf058f 100644
--- a/DungeonShooting_Godot/src/game/room/DungeonManager.cs
+++ b/DungeonShooting_Godot/src/game/room/DungeonManager.cs
@@ -564,7 +564,7 @@
foreach (var enemy in World.Enemy_InstanceList)
{
//不与玩家处于同一个房间
- if (enemy.AffiliationArea != playerAffiliationArea)
+ if (!enemy.IsDestroyed && enemy.AffiliationArea != playerAffiliationArea)
{
if (enemy is Enemy e)
{
diff --git a/DungeonShooting_Godot/src/game/room/World.cs b/DungeonShooting_Godot/src/game/room/World.cs
index 580c809..7c4c23d 100644
--- a/DungeonShooting_Godot/src/game/room/World.cs
+++ b/DungeonShooting_Godot/src/game/room/World.cs
@@ -111,7 +111,7 @@
{
foreach (var role in Enemy_InstanceList)
{
- if (role != self && role.AffiliationArea == self.AffiliationArea)
+ if (role != self && !role.IsDestroyed && role.AffiliationArea == self.AffiliationArea)
{
if (role is AdvancedEnemy advancedEnemy)
{
diff --git a/DungeonShooting_Godot/src/game/ui/roomUI/RoomUIPanel.cs b/DungeonShooting_Godot/src/game/ui/roomUI/RoomUIPanel.cs
index 85aa871..dbd01d3 100644
--- a/DungeonShooting_Godot/src/game/ui/roomUI/RoomUIPanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/roomUI/RoomUIPanel.cs
@@ -1,4 +1,5 @@
+using Godot;
using UI.BottomTips;
namespace UI.RoomUI;
@@ -54,6 +55,8 @@
_weaponBar.Process(delta);
_activePropBar.Process(delta);
_lifeBar.Process(delta);
+
+ QueueRedraw();
}
//玩家拾起道具, 弹出提示
@@ -63,4 +66,16 @@
var message = $"{prop.ActivityBase.Name}\n{prop.ActivityBase.Intro}";
BottomTipsPanel.ShowTips(prop.GetDefaultTexture(), message);
}
+
+ public override void _Draw()
+ {
+ foreach (var role in World.Current.Enemy_InstanceList)
+ {
+ if (!role.IsDestroyed && role is AdvancedEnemy advancedEnemy)
+ {
+ var position = GameApplication.Instance.ViewToGlobalPosition(advancedEnemy.Position);
+ DrawString(ResourceManager.DefaultFont16Px, position, advancedEnemy.StateController.CurrState.ToString());
+ }
+ }
+ }
}
\ No newline at end of file