diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectHit.tres b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectHit.tres
new file mode 100644
index 0000000..1c028b7
--- /dev/null
+++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectHit.tres
@@ -0,0 +1,18 @@
+[gd_resource type="Animation" format=2]
+
+[resource]
+resource_name = "hit"
+length = 0.15
+step = 0.05
+tracks/0/type = "value"
+tracks/0/path = NodePath("AnimatedSprite:material:shader_param/schedule")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/keys = {
+"times": PoolRealArray( 0, 0.05, 0.15 ),
+"transitions": PoolRealArray( 1, 1, 1 ),
+"update": 0,
+"values": [ 1.0, 1.0, 0.0 ]
+}
diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectReset.tres b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectReset.tres
new file mode 100644
index 0000000..80d77f7
--- /dev/null
+++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectReset.tres
@@ -0,0 +1,16 @@
+[gd_resource type="Animation" format=2]
+
+[resource]
+length = 0.001
+tracks/0/type = "value"
+tracks/0/path = NodePath("AnimatedSprite:material:shader_param/schedule")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/keys = {
+"times": PoolRealArray( 0 ),
+"transitions": PoolRealArray( 1 ),
+"update": 0,
+"values": [ 0.0 ]
+}
diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectTemplate.cs b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectTemplate.cs
index 5c2948c..d85d71e 100644
--- a/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectTemplate.cs
+++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectTemplate.cs
@@ -11,26 +11,22 @@
///
/// 是否放入 ySort 节点下
///
- [Export]
- public bool UseYSort;
-
+ [Export] public bool UseYSort;
+
///
/// 当前物体所属物理层
///
- [Export(PropertyHint.Layers2dPhysics)]
- public uint CollisionLayer;
-
+ [Export(PropertyHint.Layers2dPhysics)] public uint CollisionLayer;
+
///
/// 当前物体扫描的物理层
///
- [Export(PropertyHint.Layers2dPhysics)]
- public uint CollisionMask;
-
+ [Export(PropertyHint.Layers2dPhysics)] public uint CollisionMask;
+
///
/// 当前物体渲染层级
///
- [Export]
- public int ZIndex;
+ [Export] public int ZIndex;
public override void _Ready()
{
@@ -54,24 +50,51 @@
{
owner = parent;
}
-
+
+ var sprite = GetNodeOrNull("ShadowSprite");
//创建Shadow
- if (GetNodeOrNull("ShadowSprite") == null)
+ if (sprite == null)
{
- var sd = new Sprite();
- sd.Name = "ShadowSprite";
- sd.Material = ResourceManager.BlendMaterial;
- AddChild(sd);
- sd.Owner = owner;
+ sprite = new Sprite();
+ sprite.Name = "ShadowSprite";
+ var material =
+ ResourceManager.Load(ResourcePath.resource_materlal_Blend_tres, false);
+ material.SetShaderParam("blend", new Color(0, 0, 0, 0.47058824F));
+ material.SetShaderParam("schedule", 1);
+ sprite.Material = material;
+ AddChild(sprite);
+ sprite.Owner = owner;
}
-
- //创建 Sprite
- if (GetNodeOrNull("AnimatedSprite") == null)
+ else if (sprite.Material == null)
{
- var sp = new AnimatedSprite();
- sp.Name = "AnimatedSprite";
- AddChild(sp);
- sp.Owner = owner;
+ var material =
+ ResourceManager.Load(ResourcePath.resource_materlal_Blend_tres, false);
+ material.SetShaderParam("blend", new Color(0, 0, 0, 0.47058824F));
+ material.SetShaderParam("schedule", 1);
+ sprite.Material = material;
+ }
+
+ var animatedSprite = GetNodeOrNull("AnimatedSprite");
+ //创建 Sprite
+ if (animatedSprite == null)
+ {
+ animatedSprite = new AnimatedSprite();
+ animatedSprite.Name = "AnimatedSprite";
+ var material =
+ ResourceManager.Load(ResourcePath.resource_materlal_Blend_tres, false);
+ material.SetShaderParam("blend", new Color(1, 1, 1, 1));
+ material.SetShaderParam("schedule", 0);
+ animatedSprite.Material = material;
+ AddChild(animatedSprite);
+ animatedSprite.Owner = owner;
+ }
+ else if (animatedSprite.Material == null)
+ {
+ var material =
+ ResourceManager.Load(ResourcePath.resource_materlal_Blend_tres, false);
+ material.SetShaderParam("blend", new Color(1, 1, 1, 1));
+ material.SetShaderParam("schedule", 0);
+ animatedSprite.Material = material;
}
//创建Collision
@@ -82,6 +105,21 @@
AddChild(co);
co.Owner = owner;
}
+
+ //创建AnimationPlayer
+ if (GetNodeOrNull("AnimationPlayer") == null)
+ {
+ var ap = new AnimationPlayer();
+ ap.Name = "AnimationPlayer";
+ ap.AddAnimation("RESET",
+ ResourceManager.Load(
+ "res://addons/dungeonShooting_plugin/ActivityObjectReset.tres", false));
+ ap.AddAnimation("hit",
+ ResourceManager.Load(
+ "res://addons/dungeonShooting_plugin/ActivityObjectHit.tres", false));
+ AddChild(ap);
+ ap.Owner = owner;
+ }
}
}
}
diff --git a/DungeonShooting_Godot/prefab/effect/Hit.tscn b/DungeonShooting_Godot/prefab/effect/Hit.tscn
deleted file mode 100644
index 26e0459..0000000
--- a/DungeonShooting_Godot/prefab/effect/Hit.tscn
+++ /dev/null
@@ -1,13 +0,0 @@
-[gd_scene load_steps=3 format=2]
-
-[ext_resource path="res://resource/effects/Hit.tres" type="SpriteFrames" id=1]
-[ext_resource path="res://src/game/effect/Hit.cs" type="Script" id=6]
-
-[node name="Hit" type="AnimatedSprite"]
-z_index = 5
-frames = ExtResource( 1 )
-animation = "Hit"
-offset = Vector2( 1, 11 )
-script = ExtResource( 6 )
-
-[connection signal="animation_finished" from="." to="." method="_on_Hit_animation_finished"]
diff --git a/DungeonShooting_Godot/prefab/role/Enemy.tscn b/DungeonShooting_Godot/prefab/role/Enemy.tscn
index b24c830..335ac3f 100644
--- a/DungeonShooting_Godot/prefab/role/Enemy.tscn
+++ b/DungeonShooting_Godot/prefab/role/Enemy.tscn
@@ -6,13 +6,13 @@
[sub_resource type="ShaderMaterial" id=1]
resource_local_to_scene = true
shader = ExtResource( 2 )
-shader_param/shadowColor = Color( 0, 0, 0, 0.470588 )
+shader_param/blend = Color( 1, 1, 1, 1 )
shader_param/schedule = 1.0
[sub_resource type="ShaderMaterial" id=2]
resource_local_to_scene = true
shader = ExtResource( 2 )
-shader_param/shadowColor = Color( 1, 1, 1, 1 )
+shader_param/blend = Color( 1, 1, 1, 1 )
shader_param/schedule = 0.0
[node name="Enemy" instance=ExtResource( 1 )]
@@ -23,7 +23,7 @@
[node name="AnimatedSprite" parent="." index="2"]
material = SubResource( 2 )
-frame = 2
+frame = 1
-[node name="ViewRay" type="RayCast2D" parent="." index="7"]
+[node name="ViewRay" type="RayCast2D" parent="." index="6"]
position = Vector2( 0, -8 )
diff --git a/DungeonShooting_Godot/prefab/role/Player.tscn b/DungeonShooting_Godot/prefab/role/Player.tscn
index 9bf6662..4d5c98f 100644
--- a/DungeonShooting_Godot/prefab/role/Player.tscn
+++ b/DungeonShooting_Godot/prefab/role/Player.tscn
@@ -6,13 +6,13 @@
[sub_resource type="ShaderMaterial" id=1]
resource_local_to_scene = true
shader = ExtResource( 2 )
-shader_param/shadowColor = Color( 0, 0, 0, 0.8 )
+shader_param/blend = Color( 1, 1, 1, 1 )
shader_param/schedule = 1.0
[sub_resource type="ShaderMaterial" id=2]
resource_local_to_scene = true
shader = ExtResource( 2 )
-shader_param/shadowColor = Color( 1, 1, 1, 1 )
+shader_param/blend = Color( 1, 1, 1, 1 )
shader_param/schedule = 0.0
[node name="Player" instance=ExtResource( 1 )]
@@ -23,4 +23,4 @@
[node name="AnimatedSprite" parent="." index="2"]
material = SubResource( 2 )
-frame = 0
+frame = 2
diff --git a/DungeonShooting_Godot/prefab/role/Role.tscn b/DungeonShooting_Godot/prefab/role/Role.tscn
index 4fd8304..98f98e6 100644
--- a/DungeonShooting_Godot/prefab/role/Role.tscn
+++ b/DungeonShooting_Godot/prefab/role/Role.tscn
@@ -5,11 +5,13 @@
[ext_resource path="res://resource/sprite/role/role1.png" type="Texture" id=3]
[ext_resource path="res://src/game/role/MountRotation.cs" type="Script" id=4]
[ext_resource path="res://resource/materlal/Blend.gdshader" type="Shader" id=5]
+[ext_resource path="res://addons/dungeonShooting_plugin/ActivityObjectReset.tres" type="Animation" id=6]
+[ext_resource path="res://addons/dungeonShooting_plugin/ActivityObjectHit.tres" type="Animation" id=7]
-[sub_resource type="ShaderMaterial" id=31]
+[sub_resource type="ShaderMaterial" id=33]
resource_local_to_scene = true
shader = ExtResource( 5 )
-shader_param/shadowColor = Color( 1, 1, 1, 1 )
+shader_param/blend = Color( 1, 1, 1, 1 )
shader_param/schedule = 0.0
[sub_resource type="AtlasTexture" id=17]
@@ -81,38 +83,6 @@
[sub_resource type="RectangleShape2D" id=16]
extents = Vector2( 5, 8.25 )
-[sub_resource type="Animation" id=32]
-length = 0.001
-tracks/0/type = "value"
-tracks/0/path = NodePath("AnimatedSprite:material:shader_param/schedule")
-tracks/0/interp = 1
-tracks/0/loop_wrap = true
-tracks/0/imported = false
-tracks/0/enabled = true
-tracks/0/keys = {
-"times": PoolRealArray( 0 ),
-"transitions": PoolRealArray( 1 ),
-"update": 0,
-"values": [ 0.0 ]
-}
-
-[sub_resource type="Animation" id=30]
-resource_name = "hit"
-length = 0.1
-step = 0.05
-tracks/0/type = "value"
-tracks/0/path = NodePath("AnimatedSprite:material:shader_param/schedule")
-tracks/0/interp = 1
-tracks/0/loop_wrap = true
-tracks/0/imported = false
-tracks/0/enabled = true
-tracks/0/keys = {
-"times": PoolRealArray( 0, 0.02, 0.1 ),
-"transitions": PoolRealArray( 1, 1, 1 ),
-"update": 0,
-"values": [ 1.0, 1.0, 0.0 ]
-}
-
[node name="Role" type="Node"]
script = ExtResource( 2 )
UseYSort = true
@@ -125,11 +95,11 @@
position = Vector2( 0, -10 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
-material = SubResource( 31 )
+material = SubResource( 33 )
position = Vector2( 0, -12 )
frames = SubResource( 6 )
animation = "idle"
-frame = 3
+frame = 1
playing = true
[node name="Collision" type="CollisionShape2D" parent="."]
@@ -151,5 +121,5 @@
script = ExtResource( 4 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
-anims/RESET = SubResource( 32 )
-anims/hit = SubResource( 30 )
+anims/RESET = ExtResource( 6 )
+anims/hit = ExtResource( 7 )
diff --git a/DungeonShooting_Godot/prefab/weapon/Knife.tscn b/DungeonShooting_Godot/prefab/weapon/Knife.tscn
index d5628c3..9f4a6ec 100644
--- a/DungeonShooting_Godot/prefab/weapon/Knife.tscn
+++ b/DungeonShooting_Godot/prefab/weapon/Knife.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=8 format=2]
+[gd_scene load_steps=10 format=2]
[ext_resource path="res://prefab/weapon/Weapon.tscn" type="PackedScene" id=1]
[ext_resource path="res://resource/sprite/gun/knife1.png" type="Texture" id=2]
@@ -8,13 +8,13 @@
[sub_resource type="ShaderMaterial" id=2]
resource_local_to_scene = true
shader = ExtResource( 3 )
-shader_param/shadowColor = Color( 0, 0, 0, 0.470588 )
+shader_param/blend = Color( 1, 1, 1, 1 )
shader_param/schedule = 1.0
[sub_resource type="ShaderMaterial" id=3]
resource_local_to_scene = true
shader = ExtResource( 3 )
-shader_param/shadowColor = Color( 1, 1, 1, 1 )
+shader_param/blend = Color( 1, 1, 1, 1 )
shader_param/schedule = 0.0
[sub_resource type="SpriteFrames" id=4]
@@ -25,6 +25,38 @@
"speed": 5.0
} ]
+[sub_resource type="Animation" id=5]
+length = 0.001
+tracks/0/type = "value"
+tracks/0/path = NodePath("AnimatedSprite:material:shader_param/schedule")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/keys = {
+"times": PoolRealArray( 0 ),
+"transitions": PoolRealArray( 1 ),
+"update": 0,
+"values": [ 0.0 ]
+}
+
+[sub_resource type="Animation" id=6]
+resource_name = "hit"
+length = 0.15
+step = 0.05
+tracks/0/type = "value"
+tracks/0/path = NodePath("AnimatedSprite:material:shader_param/schedule")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/keys = {
+"times": PoolRealArray( 0, 0.05, 0.15 ),
+"transitions": PoolRealArray( 1, 1, 1 ),
+"update": 0,
+"values": [ 1.0, 1.0, 0.0 ]
+}
+
[node name="Knife" instance=ExtResource( 1 )]
[node name="ShadowSprite" parent="." index="0"]
@@ -44,3 +76,8 @@
[node name="FanCollisionShape" parent="HitArea" index="0" instance=ExtResource( 4 )]
rotation = -1.5708
scale = Vector2( 3, 3 )
+
+[node name="AnimationPlayer" type="AnimationPlayer" parent="HitArea" index="1"]
+root_node = NodePath("../..")
+anims/RESET = SubResource( 5 )
+anims/hit = SubResource( 6 )
diff --git a/DungeonShooting_Godot/prefab/weapon/Weapon.tscn b/DungeonShooting_Godot/prefab/weapon/Weapon.tscn
index ffdb65c..cfec691 100644
--- a/DungeonShooting_Godot/prefab/weapon/Weapon.tscn
+++ b/DungeonShooting_Godot/prefab/weapon/Weapon.tscn
@@ -1,36 +1,27 @@
-[gd_scene load_steps=8 format=2]
+[gd_scene load_steps=9 format=2]
-[ext_resource path="res://resource/materlal/Blend.tres" type="Material" id=1]
-[ext_resource path="res://resource/materlal/Blend.gdshader" type="Shader" id=2]
+[ext_resource path="res://resource/materlal/Blend.gdshader" type="Shader" id=1]
[ext_resource path="res://addons/dungeonShooting_plugin/ActivityObjectTemplate.cs" type="Script" id=3]
-[sub_resource type="ShaderMaterial" id=5]
+[sub_resource type="ShaderMaterial" id=7]
resource_local_to_scene = true
-shader = ExtResource( 2 )
-shader_param/shadowColor = Color( 1, 1, 1, 1 )
+shader = ExtResource( 1 )
+shader_param/blend = Color( 0, 0, 0, 0.470588 )
+shader_param/schedule = 1
+
+[sub_resource type="ShaderMaterial" id=8]
+resource_local_to_scene = true
+shader = ExtResource( 1 )
+shader_param/blend = Color( 1, 1, 1, 1 )
shader_param/schedule = 0.0
-[sub_resource type="Animation" id=3]
-resource_name = "Floodlight"
-length = 3.0
-loop = true
-tracks/0/type = "value"
-tracks/0/path = NodePath("../AnimatedSprite:material:shader_param/schedule")
-tracks/0/interp = 1
-tracks/0/loop_wrap = true
-tracks/0/imported = false
-tracks/0/enabled = true
-tracks/0/keys = {
-"times": PoolRealArray( 0, 2.3, 2.6, 2.7, 3 ),
-"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
-"update": 0,
-"values": [ 0.0, 0.0, 0.5, 0.4, 0.0 ]
-}
+[sub_resource type="RectangleShape2D" id=1]
+extents = Vector2( 7.8, 3.5 )
-[sub_resource type="Animation" id=4]
+[sub_resource type="Animation" id=9]
length = 0.001
tracks/0/type = "value"
-tracks/0/path = NodePath("../AnimatedSprite:material:shader_param/schedule")
+tracks/0/path = NodePath("AnimatedSprite:material:shader_param/schedule")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
@@ -41,18 +32,61 @@
"update": 0,
"values": [ 0.0 ]
}
+tracks/1/type = "value"
+tracks/1/path = NodePath("AnimatedSprite:material:shader_param/blend")
+tracks/1/interp = 1
+tracks/1/loop_wrap = true
+tracks/1/imported = false
+tracks/1/enabled = true
+tracks/1/keys = {
+"times": PoolRealArray( 0 ),
+"transitions": PoolRealArray( 1 ),
+"update": 0,
+"values": [ Color( 1, 1, 1, 1 ) ]
+}
-[sub_resource type="RectangleShape2D" id=1]
-extents = Vector2( 7.8, 3.5 )
+[sub_resource type="Animation" id=11]
+resource_name = "floodlight"
+length = 3.0
+loop = true
+tracks/0/type = "value"
+tracks/0/path = NodePath("AnimatedSprite:material:shader_param/schedule")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/keys = {
+"times": PoolRealArray( 0, 2.3, 2.6, 2.7, 3 ),
+"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
+"update": 0,
+"values": [ 0.0, 0.0, 0.5, 0.5, 0.0 ]
+}
+
+[sub_resource type="Animation" id=10]
+resource_name = "hit"
+length = 0.15
+step = 0.05
+tracks/0/type = "value"
+tracks/0/path = NodePath("AnimatedSprite:material:shader_param/schedule")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/keys = {
+"times": PoolRealArray( 0, 0.05, 0.15 ),
+"transitions": PoolRealArray( 1, 1, 1 ),
+"update": 0,
+"values": [ 1.0, 1.0, 0.0 ]
+}
[node name="Weapon" type="Node"]
script = ExtResource( 3 )
[node name="ShadowSprite" type="Sprite" parent="."]
-material = ExtResource( 1 )
+material = SubResource( 7 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
-material = SubResource( 5 )
+material = SubResource( 8 )
position = Vector2( 0.4, -2.6 )
scale = Vector2( 0.8, 0.8 )
@@ -60,10 +94,6 @@
collision_layer = 4
collision_mask = 0
-[node name="AnimationPlayer" type="AnimationPlayer" parent="WeaponBody"]
-anims/Floodlight = SubResource( 3 )
-anims/RESET = SubResource( 4 )
-
[node name="OriginPoint" type="Position2D" parent="WeaponBody"]
position = Vector2( -3.60001, -1.1 )
@@ -78,3 +108,8 @@
shape = SubResource( 1 )
[node name="Collision" type="CollisionShape2D" parent="."]
+
+[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
+anims/RESET = SubResource( 9 )
+anims/floodlight = SubResource( 11 )
+anims/hit = SubResource( 10 )
diff --git a/DungeonShooting_Godot/prefab/weapon/bullet/Bullet.tscn b/DungeonShooting_Godot/prefab/weapon/bullet/Bullet.tscn
index 5b9b099..21ea163 100644
--- a/DungeonShooting_Godot/prefab/weapon/bullet/Bullet.tscn
+++ b/DungeonShooting_Godot/prefab/weapon/bullet/Bullet.tscn
@@ -1,9 +1,21 @@
-[gd_scene load_steps=6 format=2]
+[gd_scene load_steps=10 format=2]
[ext_resource path="res://addons/dungeonShooting_plugin/ActivityObjectTemplate.cs" type="Script" id=1]
-[ext_resource path="res://resource/materlal/Blend.tres" type="Material" id=2]
+[ext_resource path="res://resource/materlal/Blend.gdshader" type="Shader" id=2]
[ext_resource path="res://resource/sprite/bullet/bullet.png" type="Texture" id=3]
+[sub_resource type="ShaderMaterial" id=3]
+resource_local_to_scene = true
+shader = ExtResource( 2 )
+shader_param/blend = Color( 0, 0, 0, 0.470588 )
+shader_param/schedule = 1
+
+[sub_resource type="ShaderMaterial" id=4]
+resource_local_to_scene = true
+shader = ExtResource( 2 )
+shader_param/blend = Color( 1, 1, 1, 1 )
+shader_param/schedule = 0.0
+
[sub_resource type="SpriteFrames" id=1]
animations = [ {
"frames": [ ExtResource( 3 ) ],
@@ -15,14 +27,47 @@
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 6, 2 )
+[sub_resource type="Animation" id=5]
+length = 0.001
+tracks/0/type = "value"
+tracks/0/path = NodePath("AnimatedSprite:material:shader_param/schedule")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/keys = {
+"times": PoolRealArray( 0 ),
+"transitions": PoolRealArray( 1 ),
+"update": 0,
+"values": [ 0.0 ]
+}
+
+[sub_resource type="Animation" id=6]
+resource_name = "hit"
+length = 0.15
+step = 0.05
+tracks/0/type = "value"
+tracks/0/path = NodePath("AnimatedSprite:material:shader_param/schedule")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/keys = {
+"times": PoolRealArray( 0, 0.05, 0.15 ),
+"transitions": PoolRealArray( 1, 1, 1 ),
+"update": 0,
+"values": [ 1.0, 1.0, 0.0 ]
+}
+
[node name="Bullet" type="Node"]
script = ExtResource( 1 )
[node name="ShadowSprite" type="Sprite" parent="."]
-material = ExtResource( 2 )
+material = SubResource( 3 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
modulate = Color( 1.5, 1.5, 1.5, 1 )
+material = SubResource( 4 )
position = Vector2( 2.38419e-07, 0 )
frames = SubResource( 1 )
@@ -36,3 +81,7 @@
[node name="CollisionShape2D" type="CollisionShape2D" parent="CollisionArea"]
position = Vector2( 2, 0 )
shape = SubResource( 2 )
+
+[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
+anims/RESET = SubResource( 5 )
+anims/hit = SubResource( 6 )
diff --git a/DungeonShooting_Godot/prefab/weapon/shell/ShellCase.tscn b/DungeonShooting_Godot/prefab/weapon/shell/ShellCase.tscn
index 712c039..4f9b26f 100644
--- a/DungeonShooting_Godot/prefab/weapon/shell/ShellCase.tscn
+++ b/DungeonShooting_Godot/prefab/weapon/shell/ShellCase.tscn
@@ -1,9 +1,21 @@
-[gd_scene load_steps=5 format=2]
+[gd_scene load_steps=9 format=2]
[ext_resource path="res://resource/sprite/shell/shellCase.png" type="Texture" id=1]
-[ext_resource path="res://resource/materlal/Blend.tres" type="Material" id=2]
+[ext_resource path="res://resource/materlal/Blend.gdshader" type="Shader" id=2]
[ext_resource path="res://addons/dungeonShooting_plugin/ActivityObjectTemplate.cs" type="Script" id=3]
+[sub_resource type="ShaderMaterial" id=2]
+resource_local_to_scene = true
+shader = ExtResource( 2 )
+shader_param/blend = Color( 0, 0, 0, 0.470588 )
+shader_param/schedule = 1.0
+
+[sub_resource type="ShaderMaterial" id=3]
+resource_local_to_scene = true
+shader = ExtResource( 2 )
+shader_param/blend = Color( 1, 1, 1, 1 )
+shader_param/schedule = 0.0
+
[sub_resource type="SpriteFrames" id=1]
animations = [ {
"frames": [ ExtResource( 1 ) ],
@@ -12,13 +24,50 @@
"speed": 5.0
} ]
+[sub_resource type="Animation" id=4]
+length = 0.001
+tracks/0/type = "value"
+tracks/0/path = NodePath("AnimatedSprite:material:shader_param/schedule")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/keys = {
+"times": PoolRealArray( 0 ),
+"transitions": PoolRealArray( 1 ),
+"update": 0,
+"values": [ 0.0 ]
+}
+
+[sub_resource type="Animation" id=5]
+resource_name = "hit"
+length = 0.15
+step = 0.05
+tracks/0/type = "value"
+tracks/0/path = NodePath("AnimatedSprite:material:shader_param/schedule")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/keys = {
+"times": PoolRealArray( 0, 0.05, 0.15 ),
+"transitions": PoolRealArray( 1, 1, 1 ),
+"update": 0,
+"values": [ 1.0, 1.0, 0.0 ]
+}
+
[node name="ShellCase" type="Node"]
script = ExtResource( 3 )
[node name="ShadowSprite" type="Sprite" parent="."]
-material = ExtResource( 2 )
+material = SubResource( 2 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
+material = SubResource( 3 )
frames = SubResource( 1 )
[node name="Collision" type="CollisionShape2D" parent="."]
+
+[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
+anims/RESET = SubResource( 4 )
+anims/hit = SubResource( 5 )
diff --git a/DungeonShooting_Godot/resource/effects/Hit.tres b/DungeonShooting_Godot/resource/effects/Hit.tres
index 542a423..689253f 100644
--- a/DungeonShooting_Godot/resource/effects/Hit.tres
+++ b/DungeonShooting_Godot/resource/effects/Hit.tres
@@ -10,6 +10,6 @@
animations = [ {
"frames": [ ExtResource( 3 ), ExtResource( 5 ), ExtResource( 1 ), ExtResource( 4 ), ExtResource( 2 ) ],
"loop": true,
-"name": "Hit",
+"name": "default",
"speed": 20.0
} ]
diff --git a/DungeonShooting_Godot/resource/materlal/Blend.gdshader b/DungeonShooting_Godot/resource/materlal/Blend.gdshader
index b3ba457..2d0c5d2 100644
--- a/DungeonShooting_Godot/resource/materlal/Blend.gdshader
+++ b/DungeonShooting_Godot/resource/materlal/Blend.gdshader
@@ -1,11 +1,11 @@
shader_type canvas_item;
-uniform vec4 shadowColor : hint_color = vec4(0.0, 0.0, 0.0, 0.8);
+uniform vec4 blend : hint_color = vec4(1.0, 1.0, 1.0, 1.0);
uniform float schedule = 1.0;
//将贴图渲染为阴影
void fragment() {
vec4 textureColor = texture(TEXTURE, UV);
- vec4 col = mix(textureColor, shadowColor, schedule);
+ vec4 col = mix(textureColor, blend, schedule);
COLOR = mix(vec4(0.0, 0.0, 0.0, 0.0), col, textureColor.a);
}
diff --git a/DungeonShooting_Godot/resource/materlal/Blend.tres b/DungeonShooting_Godot/resource/materlal/Blend.tres
index e683188..aa8db2d 100644
--- a/DungeonShooting_Godot/resource/materlal/Blend.tres
+++ b/DungeonShooting_Godot/resource/materlal/Blend.tres
@@ -5,5 +5,5 @@
[resource]
resource_local_to_scene = true
shader = ExtResource( 1 )
-shader_param/shadowColor = Color( 0, 0, 0, 0.470588 )
-shader_param/schedule = 1.0
+shader_param/blend = Color( 0, 0, 0, 0.470588 )
+shader_param/schedule = 1
diff --git a/DungeonShooting_Godot/resource/sprite/effect/KnifeHit1.aseprite b/DungeonShooting_Godot/resource/sprite/effect/KnifeHit1.aseprite
index 8a8a0e3..be780df 100644
--- a/DungeonShooting_Godot/resource/sprite/effect/KnifeHit1.aseprite
+++ b/DungeonShooting_Godot/resource/sprite/effect/KnifeHit1.aseprite
Binary files differ
diff --git a/DungeonShooting_Godot/resource/sprite/effect/KnifeHit1.png b/DungeonShooting_Godot/resource/sprite/effect/KnifeHit1.png
index 0c07004..83465d0 100644
--- a/DungeonShooting_Godot/resource/sprite/effect/KnifeHit1.png
+++ b/DungeonShooting_Godot/resource/sprite/effect/KnifeHit1.png
Binary files differ
diff --git a/DungeonShooting_Godot/src/framework/ActivityObject.cs b/DungeonShooting_Godot/src/framework/ActivityObject.cs
index 71984fa..8bfbfa7 100644
--- a/DungeonShooting_Godot/src/framework/ActivityObject.cs
+++ b/DungeonShooting_Godot/src/framework/ActivityObject.cs
@@ -35,6 +35,12 @@
public CollisionShape2D Collision { get; }
///
+ /// 动画播放器
+ ///
+ ///
+ public AnimationPlayer AnimationPlayer { get; }
+
+ ///
/// 是否调用过 Destroy() 函数
///
public bool IsDestroyed { get; private set; }
@@ -93,6 +99,9 @@
case "Collision":
Collision = (CollisionShape2D)body;
break;
+ case "AnimationPlayer":
+ AnimationPlayer = (AnimationPlayer)body;
+ break;
}
}
}
diff --git a/DungeonShooting_Godot/src/game/effect/Hit.cs b/DungeonShooting_Godot/src/game/effect/Hit.cs
deleted file mode 100644
index 80d3713..0000000
--- a/DungeonShooting_Godot/src/game/effect/Hit.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using Godot;
-
-public class Hit : AnimatedSprite
-{
- public override void _Ready()
- {
- Frame = 0;
- Playing = true;
- }
-
- ///
- /// 动画结束, 销毁
- ///
- private void _on_Hit_animation_finished()
- {
- QueueFree();
- }
-}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs b/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs
index 5ef38fb..f165656 100644
--- a/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs
+++ b/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs
@@ -22,12 +22,6 @@
public WeaponAttribute Attribute { get; private set; }
///
- /// 动画播放器
- ///
- ///
- public AnimationPlayer AnimationPlayer { get; private set; }
-
- ///
/// 武器攻击的目标阵营
///
public CampEnum TargetCamp { get; set; }
@@ -178,7 +172,6 @@
FirePoint = GetNode("WeaponBody/FirePoint");
OriginPoint = GetNode("WeaponBody/OriginPoint");
ShellPoint = GetNode("WeaponBody/ShellPoint");
- AnimationPlayer = GetNode("WeaponBody/AnimationPlayer");
CollisionShape2D = GetNode("WeaponBody/Collision");
//更新图片
@@ -891,13 +884,13 @@
{
//启用碰撞
CollisionShape2D.Disabled = false;
- AnimationPlayer.Play("Floodlight");
+ AnimationPlayer.Play("floodlight");
}
public override void PutDown()
{
base.PutDown();
- AnimationPlayer.Play("Floodlight");
+ AnimationPlayer.Play("floodlight");
}
///
diff --git a/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs b/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs
index 22e46ae..6eb52b6 100644
--- a/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs
+++ b/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs
@@ -64,7 +64,7 @@
// hit.GlobalPosition = GlobalPosition;
// GameApplication.Instance.Room.GetRoot(true).AddChild(hit);
- SpecialEffectManager.Play(ResourcePath.resource_effects_Hit_tres, "Hit", GlobalPosition,
+ SpecialEffectManager.Play(ResourcePath.resource_effects_Hit_tres, "default", GlobalPosition,
Mathf.Deg2Rad(Utils.RandRangeInt(0, 360)), Vector2.One, new Vector2(1, 11), 0);
Destroy();
diff --git a/DungeonShooting_Godot/src/game/item/weapon/knife/Knife.cs b/DungeonShooting_Godot/src/game/item/weapon/knife/Knife.cs
index 72f0e7e..02f5df5 100644
--- a/DungeonShooting_Godot/src/game/item/weapon/knife/Knife.cs
+++ b/DungeonShooting_Godot/src/game/item/weapon/knife/Knife.cs
@@ -83,10 +83,13 @@
if (IsActive) //被使用
{
//播放挥刀特效
- SpecialEffectManager.Play(ResourcePath.resource_effects_KnifeHit1_tres, "default",
- Master.MountPoint.GlobalPosition, GlobalRotation + Mathf.Pi * 0.5f, new Vector2(0.8f * (int)Master.Face, 0.8f), new Vector2(17, 4), 1);
+ SpecialEffectManager.Play(
+ ResourcePath.resource_effects_KnifeHit1_tres, "default",
+ Master.MountPoint.GlobalPosition, GlobalRotation + Mathf.Pi * 0.5f, new Vector2((int)Master.Face, 1),
+ new Vector2(17, 4), 1
+ );
}
-
+
if (Master == GameApplication.Instance.Room.Player)
{
diff --git a/DungeonShooting_Godot/src/game/manager/ResourceManager.cs b/DungeonShooting_Godot/src/game/manager/ResourceManager.cs
index 686c730..0316d79 100644
--- a/DungeonShooting_Godot/src/game/manager/ResourceManager.cs
+++ b/DungeonShooting_Godot/src/game/manager/ResourceManager.cs
@@ -45,8 +45,21 @@
/// 加载资源对象, 并且缓存当前资源对象, 可频繁获取
///
/// 资源路径
- public static T Load(string path) where T : class
+ /// 是否使用缓存中的资源
+ public static T Load(string path, bool useCache = true) where T : class
{
+ if (!useCache)
+ {
+ T res = ResourceLoader.Load(path, null, true);
+ if (res == null)
+ {
+ GD.PrintErr("加载资源失败, 未找到资源: " + path);
+ return default;
+ }
+
+ return res;
+ }
+
if (CachePack.TryGetValue(path, out var pack))
{
return pack as T;
diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs
index 893d355..fc19176 100644
--- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs
+++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs
@@ -12,7 +12,6 @@
public const string editor_prefabs_Editor_tscn = "res://editor/prefabs/Editor.tscn";
public const string prefab_FanCollisionShape_tscn = "res://prefab/FanCollisionShape.tscn";
public const string prefab_effect_FirePart_tscn = "res://prefab/effect/FirePart.tscn";
- public const string prefab_effect_Hit_tscn = "res://prefab/effect/Hit.tscn";
public const string prefab_role_CPlusPlus_tscn = "res://prefab/role/CPlusPlus.tscn";
public const string prefab_role_Enemy_tscn = "res://prefab/role/Enemy.tscn";
public const string prefab_role_Player_tscn = "res://prefab/role/Player.tscn";