diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectHit.tres b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectHit.tres deleted file mode 100644 index 1c028b7..0000000 --- a/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectHit.tres +++ /dev/null @@ -1,18 +0,0 @@ -[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 deleted file mode 100644 index 80d77f7..0000000 --- a/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectReset.tres +++ /dev/null @@ -1,16 +0,0 @@ -[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 4f13314..2ce3a61 100644 --- a/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectTemplate.cs +++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectTemplate.cs @@ -63,6 +63,7 @@ { sprite = new Sprite(); sprite.Name = "ShadowSprite"; + sprite.ZIndex = -5; var material = ResourceManager.Load(ResourcePath.resource_materlal_Blend_tres, false); material.SetShaderParam("blend", new Color(0, 0, 0, 0.47058824F)); @@ -117,12 +118,6 @@ { 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/role/Enemy.tscn b/DungeonShooting_Godot/prefab/role/Enemy.tscn index 3e3b357..d5204e2 100644 --- a/DungeonShooting_Godot/prefab/role/Enemy.tscn +++ b/DungeonShooting_Godot/prefab/role/Enemy.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=19 format=2] [ext_resource path="res://prefab/role/Role.tscn" type="PackedScene" id=1] [ext_resource path="res://resource/materlal/Blend.gdshader" type="Shader" id=2] +[ext_resource path="res://resource/sprite/role/role8.png" type="Texture" id=3] [sub_resource type="ShaderMaterial" id=1] resource_local_to_scene = true @@ -15,6 +16,72 @@ shader_param/blend = Color( 1, 1, 1, 1 ) shader_param/schedule = 0.0 +[sub_resource type="AtlasTexture" id=7] +atlas = ExtResource( 3 ) +region = Rect2( 0, 24, 16, 24 ) + +[sub_resource type="AtlasTexture" id=8] +atlas = ExtResource( 3 ) +region = Rect2( 16, 24, 16, 24 ) + +[sub_resource type="AtlasTexture" id=9] +atlas = ExtResource( 3 ) +region = Rect2( 32, 24, 16, 24 ) + +[sub_resource type="AtlasTexture" id=10] +atlas = ExtResource( 3 ) +region = Rect2( 48, 24, 16, 24 ) + +[sub_resource type="AtlasTexture" id=11] +atlas = ExtResource( 3 ) +region = Rect2( 0, 48, 16, 24 ) + +[sub_resource type="AtlasTexture" id=12] +atlas = ExtResource( 3 ) +region = Rect2( 16, 48, 16, 24 ) + +[sub_resource type="AtlasTexture" id=13] +atlas = ExtResource( 3 ) +region = Rect2( 32, 48, 16, 24 ) + +[sub_resource type="AtlasTexture" id=14] +atlas = ExtResource( 3 ) +region = Rect2( 48, 48, 16, 24 ) + +[sub_resource type="AtlasTexture" id=15] +atlas = ExtResource( 3 ) +region = Rect2( 0, 48, 16, 24 ) + +[sub_resource type="AtlasTexture" id=16] +atlas = ExtResource( 3 ) +region = Rect2( 16, 48, 16, 24 ) + +[sub_resource type="AtlasTexture" id=17] +atlas = ExtResource( 3 ) +region = Rect2( 32, 48, 16, 24 ) + +[sub_resource type="AtlasTexture" id=18] +atlas = ExtResource( 3 ) +region = Rect2( 48, 48, 16, 24 ) + +[sub_resource type="SpriteFrames" id=19] +animations = [ { +"frames": [ SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ) ], +"loop": true, +"name": "idle", +"speed": 7.0 +}, { +"frames": [ SubResource( 11 ), SubResource( 12 ), SubResource( 13 ), SubResource( 14 ) ], +"loop": true, +"name": "reverseRun", +"speed": 10.0 +}, { +"frames": [ SubResource( 15 ), SubResource( 16 ), SubResource( 17 ), SubResource( 18 ) ], +"loop": true, +"name": "run", +"speed": 10.0 +} ] + [node name="Enemy" instance=ExtResource( 1 )] CollisionLayer = 16 CollisionMask = 25 @@ -24,6 +91,8 @@ [node name="AnimatedSprite" parent="." index="2"] material = SubResource( 2 ) +frames = SubResource( 19 ) +playing = true [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 fafdc9d..2bc57cd 100644 --- a/DungeonShooting_Godot/prefab/role/Player.tscn +++ b/DungeonShooting_Godot/prefab/role/Player.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=19 format=2] [ext_resource path="res://prefab/role/Role.tscn" type="PackedScene" id=1] [ext_resource path="res://resource/materlal/Blend.gdshader" type="Shader" id=2] +[ext_resource path="res://resource/sprite/role/role2.png" type="Texture" id=3] [sub_resource type="ShaderMaterial" id=1] resource_local_to_scene = true @@ -15,6 +16,72 @@ shader_param/blend = Color( 1, 1, 1, 1 ) shader_param/schedule = 0.0 +[sub_resource type="AtlasTexture" id=20] +atlas = ExtResource( 3 ) +region = Rect2( 0, 24, 16, 24 ) + +[sub_resource type="AtlasTexture" id=21] +atlas = ExtResource( 3 ) +region = Rect2( 16, 24, 16, 24 ) + +[sub_resource type="AtlasTexture" id=22] +atlas = ExtResource( 3 ) +region = Rect2( 32, 24, 16, 24 ) + +[sub_resource type="AtlasTexture" id=23] +atlas = ExtResource( 3 ) +region = Rect2( 48, 24, 16, 24 ) + +[sub_resource type="AtlasTexture" id=24] +atlas = ExtResource( 3 ) +region = Rect2( 0, 48, 16, 24 ) + +[sub_resource type="AtlasTexture" id=25] +atlas = ExtResource( 3 ) +region = Rect2( 16, 48, 16, 24 ) + +[sub_resource type="AtlasTexture" id=26] +atlas = ExtResource( 3 ) +region = Rect2( 32, 48, 16, 24 ) + +[sub_resource type="AtlasTexture" id=27] +atlas = ExtResource( 3 ) +region = Rect2( 48, 48, 16, 24 ) + +[sub_resource type="AtlasTexture" id=28] +atlas = ExtResource( 3 ) +region = Rect2( 0, 48, 16, 24 ) + +[sub_resource type="AtlasTexture" id=29] +atlas = ExtResource( 3 ) +region = Rect2( 16, 48, 16, 24 ) + +[sub_resource type="AtlasTexture" id=30] +atlas = ExtResource( 3 ) +region = Rect2( 32, 48, 16, 24 ) + +[sub_resource type="AtlasTexture" id=31] +atlas = ExtResource( 3 ) +region = Rect2( 48, 48, 16, 24 ) + +[sub_resource type="SpriteFrames" id=19] +animations = [ { +"frames": [ SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 23 ) ], +"loop": true, +"name": "idle", +"speed": 7.0 +}, { +"frames": [ SubResource( 24 ), SubResource( 25 ), SubResource( 26 ), SubResource( 27 ) ], +"loop": true, +"name": "reverseRun", +"speed": 10.0 +}, { +"frames": [ SubResource( 28 ), SubResource( 29 ), SubResource( 30 ), SubResource( 31 ) ], +"loop": true, +"name": "run", +"speed": 10.0 +} ] + [node name="Player" instance=ExtResource( 1 )] CollisionLayer = 8 CollisionMask = 25 @@ -24,4 +91,5 @@ [node name="AnimatedSprite" parent="." index="2"] material = SubResource( 2 ) -frame = 0 +frames = SubResource( 19 ) +playing = true diff --git a/DungeonShooting_Godot/prefab/role/Role.tscn b/DungeonShooting_Godot/prefab/role/Role.tscn index e19e22b..fe7b6c2 100644 --- a/DungeonShooting_Godot/prefab/role/Role.tscn +++ b/DungeonShooting_Godot/prefab/role/Role.tscn @@ -1,12 +1,9 @@ -[gd_scene load_steps=25 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://addons/dungeonShooting_plugin/ActivityObjectTemplate.cs" type="Script" id=2] -[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=33] resource_local_to_scene = true @@ -14,72 +11,6 @@ shader_param/blend = Color( 1, 1, 1, 1 ) shader_param/schedule = 0.0 -[sub_resource type="AtlasTexture" id=17] -atlas = ExtResource( 3 ) -region = Rect2( 0, 24, 16, 24 ) - -[sub_resource type="AtlasTexture" id=18] -atlas = ExtResource( 3 ) -region = Rect2( 16, 24, 16, 24 ) - -[sub_resource type="AtlasTexture" id=19] -atlas = ExtResource( 3 ) -region = Rect2( 32, 24, 16, 24 ) - -[sub_resource type="AtlasTexture" id=20] -atlas = ExtResource( 3 ) -region = Rect2( 48, 24, 16, 24 ) - -[sub_resource type="AtlasTexture" id=25] -atlas = ExtResource( 3 ) -region = Rect2( 48, 48, 16, 24 ) - -[sub_resource type="AtlasTexture" id=26] -atlas = ExtResource( 3 ) -region = Rect2( 32, 48, 16, 24 ) - -[sub_resource type="AtlasTexture" id=27] -atlas = ExtResource( 3 ) -region = Rect2( 16, 48, 16, 24 ) - -[sub_resource type="AtlasTexture" id=28] -atlas = ExtResource( 3 ) -region = Rect2( 0, 48, 16, 24 ) - -[sub_resource type="AtlasTexture" id=21] -atlas = ExtResource( 3 ) -region = Rect2( 0, 48, 16, 24 ) - -[sub_resource type="AtlasTexture" id=22] -atlas = ExtResource( 3 ) -region = Rect2( 16, 48, 16, 24 ) - -[sub_resource type="AtlasTexture" id=23] -atlas = ExtResource( 3 ) -region = Rect2( 32, 48, 16, 24 ) - -[sub_resource type="AtlasTexture" id=24] -atlas = ExtResource( 3 ) -region = Rect2( 48, 48, 16, 24 ) - -[sub_resource type="SpriteFrames" id=6] -animations = [ { -"frames": [ SubResource( 17 ), SubResource( 18 ), SubResource( 19 ), SubResource( 20 ) ], -"loop": true, -"name": "idle", -"speed": 7.0 -}, { -"frames": [ SubResource( 25 ), SubResource( 26 ), SubResource( 27 ), SubResource( 28 ) ], -"loop": true, -"name": "reverseRun", -"speed": 10.0 -}, { -"frames": [ SubResource( 21 ), SubResource( 22 ), SubResource( 23 ), SubResource( 24 ) ], -"loop": true, -"name": "run", -"speed": 10.0 -} ] - [sub_resource type="CircleShape2D" id=34] radius = 4.0 @@ -103,10 +34,6 @@ [node name="AnimatedSprite" type="AnimatedSprite" parent="."] material = SubResource( 33 ) position = Vector2( 0, -12 ) -frames = SubResource( 6 ) -animation = "idle" -frame = 3 -playing = true [node name="Collision" type="CollisionShape2D" parent="."] visible = false @@ -137,5 +64,3 @@ script = ExtResource( 4 ) [node name="AnimationPlayer" type="AnimationPlayer" parent="."] -anims/RESET = ExtResource( 6 ) -anims/hit = ExtResource( 7 ) diff --git a/DungeonShooting_Godot/prefab/weapon/Weapon.tscn b/DungeonShooting_Godot/prefab/weapon/Weapon.tscn index cfec691..71e722c 100644 --- a/DungeonShooting_Godot/prefab/weapon/Weapon.tscn +++ b/DungeonShooting_Godot/prefab/weapon/Weapon.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=2] +[gd_scene load_steps=8 format=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] @@ -62,23 +62,6 @@ "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 ) @@ -112,4 +95,3 @@ [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 7685a37..d2ad542 100644 --- a/DungeonShooting_Godot/prefab/weapon/bullet/Bullet.tscn +++ b/DungeonShooting_Godot/prefab/weapon/bullet/Bullet.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://addons/dungeonShooting_plugin/ActivityObjectTemplate.cs" type="Script" id=1] [ext_resource path="res://resource/materlal/Blend.gdshader" type="Shader" id=2] @@ -27,38 +27,6 @@ [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 ) CollisionMask = 1 @@ -85,5 +53,3 @@ 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 4f9b26f..36862b8 100644 --- a/DungeonShooting_Godot/prefab/weapon/shell/ShellCase.tscn +++ b/DungeonShooting_Godot/prefab/weapon/shell/ShellCase.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://resource/sprite/shell/shellCase.png" type="Texture" id=1] [ext_resource path="res://resource/materlal/Blend.gdshader" type="Shader" id=2] @@ -24,38 +24,6 @@ "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 ) @@ -69,5 +37,3 @@ [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/map/dungeon_test.tmx b/DungeonShooting_Godot/resource/map/dungeon_test.tmx index 79128e0..13de468 100644 --- a/DungeonShooting_Godot/resource/map/dungeon_test.tmx +++ b/DungeonShooting_Godot/resource/map/dungeon_test.tmx @@ -21,7 +21,7 @@ 51,51,52,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,50,51,52,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,50,51,51, 51,51,44,35,35,35,35,35,35,35,35,35,35,36,129,129,34,35,46,51,44,35,36,129,129,34,35,35,35,35,35,35,35,35,35,35,35,46,51,51, 51,51,12,99,99,99,99,99,99,99,99,99,99,100,129,129,98,99,99,99,99,99,100,129,129,98,99,99,99,99,99,99,99,99,99,99,99,14,51,51, -51,51,52,19,19,19,19,19,19,19,19,19,19,20,129,129,18,19,19,19,19,19,20,129,129,18,19,19,19,19,19,19,19,19,19,19,19,50,51,51, +51,51,52,19,19,19,19,19,121,122,122,122,122,123,129,129,18,19,19,19,19,19,20,129,129,18,19,19,19,19,19,19,19,19,19,19,19,50,51,51, 51,51,52,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,50,51,51, 51,51,52,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,50,51,51, 51,51,52,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,50,51,51, diff --git a/DungeonShooting_Godot/resource/map/itch-io-DungeonTileset4.tsx b/DungeonShooting_Godot/resource/map/itch-io-DungeonTileset4.tsx index 178db25..2ffa4f1 100644 --- a/DungeonShooting_Godot/resource/map/itch-io-DungeonTileset4.tsx +++ b/DungeonShooting_Godot/resource/map/itch-io-DungeonTileset4.tsx @@ -13,17 +13,17 @@ - + - + - + @@ -83,37 +83,37 @@ - + - + - + - + - + - + - + diff --git a/DungeonShooting_Godot/resource/materlal/Blend.tres b/DungeonShooting_Godot/resource/materlal/Blend.tres index aa8db2d..1bfd155 100644 --- a/DungeonShooting_Godot/resource/materlal/Blend.tres +++ b/DungeonShooting_Godot/resource/materlal/Blend.tres @@ -4,6 +4,7 @@ [resource] resource_local_to_scene = true +render_priority = 4 shader = ExtResource( 1 ) shader_param/blend = Color( 0, 0, 0, 0.470588 ) shader_param/schedule = 1 diff --git a/DungeonShooting_Godot/src/framework/ActivityObject.cs b/DungeonShooting_Godot/src/framework/ActivityObject.cs index a527242..bec83d7 100644 --- a/DungeonShooting_Godot/src/framework/ActivityObject.cs +++ b/DungeonShooting_Godot/src/framework/ActivityObject.cs @@ -62,10 +62,21 @@ //组件集合 private List> _components = new List>(); - private bool initShadow; + //是否初始化阴影 + private bool _initShadow; + //上一帧动画名称 private string _prevAnimation; + //上一帧动画 private int _prevAnimationFrame; + //播放 Hit 动画 + private bool _playHit; + private float _playHitSchedule; + + //混色shader材质 + private ShaderMaterial _blendShaderMaterial; + + //存储投抛该物体时所产生的数据 private ObjectThrowData _throwData; @@ -99,6 +110,7 @@ { case "AnimatedSprite": AnimatedSprite = (AnimatedSprite)body; + _blendShaderMaterial = AnimatedSprite.Material as ShaderMaterial; break; case "ShadowSprite": ShadowSprite = (Sprite)body; @@ -120,18 +132,23 @@ /// public void ShowShadowSprite() { - if (!initShadow) + if (!_initShadow) { - initShadow = true; + _initShadow = true; ShadowSprite.Material = ResourceManager.BlendMaterial; } var anim = AnimatedSprite.Animation; + var frame = AnimatedSprite.Frame; if (_prevAnimation != anim || _prevAnimationFrame != frame) { - //切换阴影动画 - ShadowSprite.Texture = AnimatedSprite.Frames.GetFrame(anim, frame); + var frames = AnimatedSprite.Frames; + if (frames.HasAnimation(anim)) + { + //切换阴影动画 + ShadowSprite.Texture = frames.GetFrame(anim, frame); + } } _prevAnimation = anim; @@ -150,9 +167,8 @@ } /// - /// 设置默认序列帧动画的第一帧, 即将删除, 请直接设置 AnimatedSprite.Frames + /// 设置默认序列帧动画的第一帧 /// - [Obsolete] public void SetDefaultTexture(Texture texture) { if (AnimatedSprite.Frames == null) @@ -166,26 +182,26 @@ SpriteFrames spriteFrames = AnimatedSprite.Frames; spriteFrames.SetFrame("default", 0, texture); } - + AnimatedSprite.Animation = "default"; AnimatedSprite.Playing = true; } /// - /// 获取当前序列帧动画的 Texture - /// - public Texture GetCurrentTexture() - { - return AnimatedSprite.Frames.GetFrame(AnimatedSprite.Name, AnimatedSprite.Frame); - } - - /// /// 获取默认序列帧动画的第一帧 /// public Texture GetDefaultTexture() { return AnimatedSprite.Frames.GetFrame("default", 0); } + + /// + /// 获取当前序列帧动画的 Texture + /// + public Texture GetCurrentTexture() + { + return AnimatedSprite.Frames.GetFrame(AnimatedSprite.Name, AnimatedSprite.Frame); + } /// /// 返回是否能与其他ActivityObject互动 @@ -451,10 +467,12 @@ _throwData.Y += _throwData.YSpeed * delta; _throwData.YSpeed -= GameConfig.G * delta; + AnimatedSprite.ZIndex = Mathf.Max(0, (int)_throwData.Y); + //达到最高点 if (ysp * _throwData.YSpeed < 0) { - ZIndex = 0; + //ZIndex = 0; OnThrowMaxHeight(_throwData.Y); } @@ -481,8 +499,6 @@ _throwData.YSpeed = _throwData.StartYSpeed = _throwData.StartYSpeed * _throwData.BounceStrength; _throwData.RotateSpeed = _throwData.RotateSpeed * _throwData.BounceStrength; _throwData.LinearVelocity *= _throwData.BounceSpeed; - // _throwData.LinearVelocity = - // new Vector2(_throwData.XSpeed, 0).Rotated(_throwData.Direction * Mathf.Pi / 180); _throwData.FirstOver = false; _throwData.IsOver = false; @@ -501,6 +517,7 @@ } } + //阴影 if (ShadowSprite.Visible) { //更新阴影贴图, 使其和动画一致 @@ -519,6 +536,29 @@ CalcShadow(); } + // Hit 动画 + if (_playHit && _blendShaderMaterial != null) + { + if (_playHitSchedule < 0.05f) + { + _blendShaderMaterial.SetShaderParam("schedule", 1); + } + else if (_playHitSchedule < 0.15f) + { + _blendShaderMaterial.SetShaderParam("schedule", Mathf.Lerp(1, 0, (_playHitSchedule - 0.05f) / 0.1f)); + } + if (_playHitSchedule >= 0.15f) + { + _blendShaderMaterial.SetShaderParam("schedule", 0); + _playHitSchedule = 0; + _playHit = false; + } + else + { + _playHitSchedule += delta; + } + } + //调试绘制 if (IsDebug) { @@ -670,6 +710,7 @@ _throwData.OriginRotation = Collision.Rotation; _throwData.OriginScale = Collision.Scale; _throwData.OriginZIndex = ZIndex; + _throwData.OriginSpriteZIndex = AnimatedSprite.ZIndex; _throwData.OriginCollisionEnable = Collision.Disabled; _throwData.OriginCollisionPosition = Collision.Position; _throwData.OriginCollisionRotation = Collision.Rotation; @@ -687,6 +728,7 @@ Collision.Rotation = 0; Collision.Scale = Vector2.One; ZIndex = 0; + AnimatedSprite.ZIndex = 0; //ZIndex = 2; Collision.Disabled = false; Collision.Position = Vector2.Zero; @@ -710,6 +752,7 @@ Collision.Rotation = _throwData.OriginRotation; Collision.Scale = _throwData.OriginScale; ZIndex = _throwData.OriginZIndex; + AnimatedSprite.ZIndex = _throwData.OriginSpriteZIndex; Collision.Disabled = _throwData.OriginCollisionEnable; Collision.Position = _throwData.OriginCollisionPosition; Collision.Rotation = _throwData.OriginCollisionRotation; @@ -800,6 +843,15 @@ } /// + /// 播放受伤动画, 该动画不与 Animation 节点的动画冲突 + /// + public void PlayHitAnimation() + { + _playHit = true; + _playHitSchedule = 0; + } + + /// /// 通过 ItemId 实例化 ActivityObject 对象 /// public static T Create(string itemId) where T : ActivityObject diff --git a/DungeonShooting_Godot/src/framework/ObjectThrowData.cs b/DungeonShooting_Godot/src/framework/ObjectThrowData.cs index 21d31f3..11e7f94 100644 --- a/DungeonShooting_Godot/src/framework/ObjectThrowData.cs +++ b/DungeonShooting_Godot/src/framework/ObjectThrowData.cs @@ -83,6 +83,7 @@ public float OriginRotation; public Vector2 OriginScale; public int OriginZIndex; + public int OriginSpriteZIndex; public bool OriginCollisionEnable; public Vector2 OriginCollisionPosition; public float OriginCollisionRotation; diff --git a/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs b/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs index 6c5ca8e..09e3edb 100644 --- a/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs +++ b/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs @@ -180,9 +180,8 @@ ShellPoint = GetNode("WeaponBody/ShellPoint"); CollisionShape2D = GetNode("WeaponBody/Collision"); - //更新图片 - var texture = ResourceLoader.Load(Attribute.Sprite); - SetDefaultTexture(texture); + //图标 + SetDefaultTexture(ResourceLoader.Load(Attribute.Sprite)); AnimatedSprite.Position = Attribute.CenterPosition; //开火位置 @@ -911,11 +910,13 @@ if (master.Face == FaceDirection.Left) { Scale *= new Vector2(1, -1); - RotationDegrees = 180; } + var angle = master.MountPoint.GlobalRotationDegrees; + GlobalRotationDegrees = angle; + var startHeight = 6; - var direction = master.GlobalRotationDegrees + Utils.RandRangeInt(-20, 20); + var direction = angle + Utils.RandRangeInt(-20, 20); var xf = 30; var yf = Utils.RandRangeInt(60, 120); var rotate = Utils.RandRangeInt(-180, 180); diff --git a/DungeonShooting_Godot/src/game/role/Role.cs b/DungeonShooting_Godot/src/game/role/Role.cs index b1ee678..d46d517 100644 --- a/DungeonShooting_Godot/src/game/role/Role.cs +++ b/DungeonShooting_Godot/src/game/role/Role.cs @@ -18,12 +18,6 @@ public Area2D HurtArea { get; private set; } /// - /// 重写的纹理, 即将删除, 请直接更改 AnimatedSprite.Frames - /// - [Obsolete] - public Texture OverrideTexture { get; protected set; } - - /// /// 移动速度 /// public float MoveSpeed = 120f; @@ -243,14 +237,6 @@ HurtArea.CollisionLayer = CollisionLayer; HurtArea.CollisionMask = 0; - //即将删除 - if (OverrideTexture != null) - { - // 更改纹理 - ChangeFrameTexture(AnimatorNames.Idle, AnimatedSprite); - ChangeFrameTexture(AnimatorNames.Run, AnimatedSprite); - ChangeFrameTexture(AnimatorNames.ReverseRun, AnimatedSprite); - } Face = FaceDirection.Right; //连接互动物体信号 @@ -504,8 +490,7 @@ Hp -= damage; } - AnimationPlayer.Stop(); - AnimationPlayer.Play("hit"); + PlayHitAnimation(); //死亡判定 if (Hp <= 0) @@ -539,25 +524,7 @@ } } } - - /// - /// 更改指定动画的纹理, 即将删除 - /// - [Obsolete] - private void ChangeFrameTexture(string anim, AnimatedSprite animatedSprite) - { - SpriteFrames spriteFrames = animatedSprite.Frames; - if (spriteFrames != null) - { - int count = spriteFrames.GetFrameCount(anim); - for (int i = 0; i < count; i++) - { - AtlasTexture temp = spriteFrames.GetFrame(anim, i) as AtlasTexture; - temp.Atlas = OverrideTexture; - } - } - } - + /// /// 连接信号: InteractiveArea.area_entered /// 与物体碰撞