diff --git a/DungeonShooting_Godot/DungeonShooting.csproj b/DungeonShooting_Godot/DungeonShooting.csproj index 672ba00..97e725f 100644 --- a/DungeonShooting_Godot/DungeonShooting.csproj +++ b/DungeonShooting_Godot/DungeonShooting.csproj @@ -1,4 +1,4 @@ - + net7.0 true diff --git a/DungeonShooting_Godot/prefab/effect/enemy/EbenyDead0001.tscn b/DungeonShooting_Godot/prefab/effect/enemy/EbenyDead0001.tscn index a73e62c..d92969c 100644 --- a/DungeonShooting_Godot/prefab/effect/enemy/EbenyDead0001.tscn +++ b/DungeonShooting_Godot/prefab/effect/enemy/EbenyDead0001.tscn @@ -15,6 +15,7 @@ shader_parameter/outline_color = Color(0, 0, 0, 1) shader_parameter/outline_rainbow = false shader_parameter/outline_use_blend = true +shader_parameter/grey = 0.0 [sub_resource type="ShaderMaterial" id="ShaderMaterial_08fn3"] shader = ExtResource("2_s7bee") @@ -25,6 +26,7 @@ shader_parameter/outline_color = Color(0, 0, 0, 1) shader_parameter/outline_rainbow = false shader_parameter/outline_use_blend = true +shader_parameter/grey = 0.0 [sub_resource type="AtlasTexture" id="AtlasTexture_cldwb"] atlas = ExtResource("3_uinig") diff --git a/DungeonShooting_Godot/prefab/effect/enemy/EbenyDead0002.tscn b/DungeonShooting_Godot/prefab/effect/enemy/EbenyDead0002.tscn index 92abec4..92f5491 100644 --- a/DungeonShooting_Godot/prefab/effect/enemy/EbenyDead0002.tscn +++ b/DungeonShooting_Godot/prefab/effect/enemy/EbenyDead0002.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=19 format=3 uid="uid://nfx3lhkdhv6a"] -[ext_resource type="Script" path="res://src/framework/activity/ActivityObject.cs" id="1_5vjr8"] +[ext_resource type="Script" path="res://src/game/activity/common/AutoFreezeObject.cs" id="1_iop26"] [ext_resource type="Texture2D" uid="uid://x3tjqgdgp43n" path="res://resource/sprite/role/enemy0002/Enemy0002_dead.png" id="2_3cyjy"] [ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="2_4hojo"] [ext_resource type="Texture2D" uid="uid://h7hkgbwj1li" path="res://resource/sprite/effects/common/Smoke.png" id="4_m7xko"] @@ -15,6 +15,7 @@ shader_parameter/outline_color = Color(0, 0, 0, 1) shader_parameter/outline_rainbow = false shader_parameter/outline_use_blend = true +shader_parameter/grey = 0.0 [sub_resource type="ShaderMaterial" id="ShaderMaterial_08fn3"] resource_local_to_scene = true @@ -22,10 +23,11 @@ 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 = false +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 +shader_parameter/grey = 0.0 [sub_resource type="AtlasTexture" id="AtlasTexture_ag5h2"] atlas = ExtResource("2_3cyjy") @@ -59,7 +61,7 @@ "texture": SubResource("AtlasTexture_lx5fo") }], "loop": false, -"name": &"default", +"name": &"dead", "speed": 5.0 }] @@ -98,10 +100,13 @@ [node name="Effect0002" type="CharacterBody2D" node_paths=PackedStringArray("ShadowSprite", "AnimatedSprite", "Collision")] collision_layer = 128 -script = ExtResource("1_5vjr8") +script = ExtResource("1_iop26") +AnimationName = "dead" +AutoToGrey = true ShadowSprite = NodePath("ShadowSprite") AnimatedSprite = NodePath("AnimatedSprite") Collision = NodePath("Collision") +ThrowCollisionSize = Vector2(14, 14) [node name="ShadowSprite" type="Sprite2D" parent="."] z_index = -1 @@ -110,7 +115,7 @@ [node name="AnimatedSprite" type="AnimatedSprite2D" parent="."] material = SubResource("ShaderMaterial_08fn3") sprite_frames = SubResource("SpriteFrames_vhsqr") -autoplay = "default" +animation = &"dead" offset = Vector2(0, -9) [node name="Collision" type="CollisionShape2D" parent="."] diff --git a/DungeonShooting_Godot/prefab/shell/Shell0001.tscn b/DungeonShooting_Godot/prefab/shell/Shell0001.tscn index eceaf5d..c1b2535 100644 --- a/DungeonShooting_Godot/prefab/shell/Shell0001.tscn +++ b/DungeonShooting_Godot/prefab/shell/Shell0001.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=7 format=3 uid="uid://bj4yr6ru8nhwr"] -[ext_resource type="Script" path="res://src/game/activity/shell/Shell.cs" id="1_2g70c"] +[ext_resource type="Script" path="res://src/game/activity/common/AutoFreezeObject.cs" id="1_2g70c"] [ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="2_tdny6"] [ext_resource type="SpriteFrames" uid="uid://b8gksxl7auquc" path="res://resource/spriteFrames/shell/Shell0001.tres" id="3_ujn5y"] @@ -35,6 +35,8 @@ ShadowSprite = NodePath("ShadowSprite") AnimatedSprite = NodePath("AnimatedSprite") Collision = NodePath("Collision") +ShadowOffset = Vector2(0, 1) +ThrowCollisionSize = Vector2(5, 5) [node name="ShadowSprite" type="Sprite2D" parent="."] z_index = -1 diff --git a/DungeonShooting_Godot/prefab/shell/Shell0002.tscn b/DungeonShooting_Godot/prefab/shell/Shell0002.tscn index 7fc2e03..aa42706 100644 --- a/DungeonShooting_Godot/prefab/shell/Shell0002.tscn +++ b/DungeonShooting_Godot/prefab/shell/Shell0002.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=7 format=3 uid="uid://cdhinm8rnppxt"] -[ext_resource type="Script" path="res://src/game/activity/shell/Shell.cs" id="1_qi64y"] +[ext_resource type="Script" path="res://src/game/activity/common/AutoFreezeObject.cs" id="1_qi64y"] [ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="2_s28nu"] [ext_resource type="SpriteFrames" uid="uid://cj8psdl2pova6" path="res://resource/spriteFrames/shell/Shell0002.tres" id="3_r560h"] @@ -35,6 +35,8 @@ ShadowSprite = NodePath("ShadowSprite") AnimatedSprite = NodePath("AnimatedSprite") Collision = NodePath("Collision") +ShadowOffset = Vector2(0, 1) +ThrowCollisionSize = Vector2(5, 5) [node name="ShadowSprite" type="Sprite2D" parent="."] z_index = -1 diff --git a/DungeonShooting_Godot/prefab/shell/Shell0003.tscn b/DungeonShooting_Godot/prefab/shell/Shell0003.tscn index fecfbcb..f50ef2f 100644 --- a/DungeonShooting_Godot/prefab/shell/Shell0003.tscn +++ b/DungeonShooting_Godot/prefab/shell/Shell0003.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=7 format=3 uid="uid://ba5sxxjaappbj"] -[ext_resource type="Script" path="res://src/game/activity/shell/Shell.cs" id="1_5hfb2"] +[ext_resource type="Script" path="res://src/game/activity/common/AutoFreezeObject.cs" id="1_5hfb2"] [ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="2_586dn"] [ext_resource type="SpriteFrames" uid="uid://kc1jwvwdg660" path="res://resource/spriteFrames/shell/Shell0003.tres" id="3_j2kre"] @@ -35,6 +35,8 @@ ShadowSprite = NodePath("ShadowSprite") AnimatedSprite = NodePath("AnimatedSprite") Collision = NodePath("Collision") +ShadowOffset = Vector2(0, 1) +ThrowCollisionSize = Vector2(5, 5) [node name="ShadowSprite" type="Sprite2D" parent="."] z_index = -1 diff --git a/DungeonShooting_Godot/prefab/shell/Shell0004.tscn b/DungeonShooting_Godot/prefab/shell/Shell0004.tscn index 42d8fd0..fc18f6b 100644 --- a/DungeonShooting_Godot/prefab/shell/Shell0004.tscn +++ b/DungeonShooting_Godot/prefab/shell/Shell0004.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=7 format=3 uid="uid://ycr5mjr25302"] -[ext_resource type="Script" path="res://src/game/activity/shell/Shell.cs" id="1_ridlp"] +[ext_resource type="Script" path="res://src/game/activity/common/AutoFreezeObject.cs" id="1_ridlp"] [ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="2_guwkk"] [ext_resource type="SpriteFrames" uid="uid://b8b0ye3iv1vwp" path="res://resource/spriteFrames/shell/Shell0004.tres" id="3_1s5f3"] @@ -35,6 +35,8 @@ ShadowSprite = NodePath("ShadowSprite") AnimatedSprite = NodePath("AnimatedSprite") Collision = NodePath("Collision") +ShadowOffset = Vector2(0, 1) +ThrowCollisionSize = Vector2(5, 5) [node name="ShadowSprite" type="Sprite2D" parent="."] z_index = -1 diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Battle2/Preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Battle2/Preinstall.json index 80edbe9..d380491 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Battle2/Preinstall.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Battle2/Preinstall.json @@ -1 +1 @@ -[{"Name":"test1","Weight":100,"Remark":"","WaveList":[[{"Position":{"X":178,"Y":-21},"Size":{"X":92,"Y":73},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":"weapon0007","CurrAmmon":"60","ResidueAmmo":"60"},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":76,"Y":168},"Size":{"X":43,"Y":77},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]}],[{"Position":{"X":89,"Y":19},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":65,"Y":142},"Size":{"X":48,"Y":160},"SpecialMarkType":0,"DelayTime":0.5,"MarkList":[{"Id":"weapon0005","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"40"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":79,"Y":45},"Size":{"X":46,"Y":121},"SpecialMarkType":0,"DelayTime":0.5,"MarkList":[{"Id":"weapon0005","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"40"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":181,"Y":203},"Size":{"X":66,"Y":33},"SpecialMarkType":0,"DelayTime":1,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":-19,"Y":100},"Size":{"X":97,"Y":63},"SpecialMarkType":0,"DelayTime":1.5,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":117,"Y":-14},"Size":{"X":122,"Y":78},"SpecialMarkType":0,"DelayTime":2,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]}],[{"Position":{"X":78,"Y":89},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":-79,"Y":15},"Size":{"X":30,"Y":140},"SpecialMarkType":0,"DelayTime":1,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":"weapon0007","CurrAmmon":"60","ResidueAmmo":"60"},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":-50,"Y":114},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":2,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":"weapon0003","CurrAmmon":"12","ResidueAmmo":"12"},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":45,"Y":187},"Size":{"X":42,"Y":72},"SpecialMarkType":0,"DelayTime":3,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":"weapon0003","CurrAmmon":"12","ResidueAmmo":"12"},"Altitude":0,"VerticalSpeed":0}]}]]}] \ No newline at end of file +[{"Name":"test1","Weight":100,"Remark":"","WaveList":[[{"Position":{"X":178,"Y":-21},"Size":{"X":92,"Y":73},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":"weapon0007","CurrAmmon":"60","ResidueAmmo":"60"},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":76,"Y":168},"Size":{"X":43,"Y":77},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":24,"Y":103},"Size":{"X":66,"Y":48},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0002","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]}],[{"Position":{"X":89,"Y":19},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":65,"Y":142},"Size":{"X":48,"Y":160},"SpecialMarkType":0,"DelayTime":0.5,"MarkList":[{"Id":"weapon0005","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"40"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":79,"Y":45},"Size":{"X":46,"Y":121},"SpecialMarkType":0,"DelayTime":0.5,"MarkList":[{"Id":"weapon0005","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"40"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":181,"Y":203},"Size":{"X":66,"Y":33},"SpecialMarkType":0,"DelayTime":1,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":-19,"Y":100},"Size":{"X":97,"Y":63},"SpecialMarkType":0,"DelayTime":1.5,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":117,"Y":-14},"Size":{"X":122,"Y":78},"SpecialMarkType":0,"DelayTime":2,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":126,"Y":207},"Size":{"X":81,"Y":27},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0002","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]}],[{"Position":{"X":78,"Y":89},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":-79,"Y":15},"Size":{"X":30,"Y":140},"SpecialMarkType":0,"DelayTime":1,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":"weapon0007","CurrAmmon":"60","ResidueAmmo":"60"},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":-50,"Y":114},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":2,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":"weapon0003","CurrAmmon":"12","ResidueAmmo":"12"},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":45,"Y":187},"Size":{"X":42,"Y":72},"SpecialMarkType":0,"DelayTime":3,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":"weapon0003","CurrAmmon":"12","ResidueAmmo":"12"},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":119,"Y":-45},"Size":{"X":91,"Y":37},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0002","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":-27,"Y":80},"Size":{"X":112,"Y":34},"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/resource/material/Blend.gdshader b/DungeonShooting_Godot/resource/material/Blend.gdshader index f952fc5..bbd35e5 100644 --- a/DungeonShooting_Godot/resource/material/Blend.gdshader +++ b/DungeonShooting_Godot/resource/material/Blend.gdshader @@ -15,6 +15,8 @@ uniform bool outline_rainbow = false; //轮廓是否使用 blend uniform bool outline_use_blend = true; +//灰度 +uniform float grey : hint_range(0.0, 1.0, 0.01) = 0.0; //彩虹轮廓变化周期 const float frequency = 0.25; @@ -46,13 +48,16 @@ a = outline_color.a; } } + if (outline_use_blend) { COLOR = mix(COLOR, blend, schedule); } } else { //非轮廓 COLOR = mix(COLOR, blend, schedule); + //灰度 + float grayColor = dot(COLOR.rgb, vec3(0.299, 0.587, 0.114)); + COLOR.rgb = mix(COLOR.rgb, vec3(grayColor), grey); } - COLOR.a *= a; COLOR *= modulate; } diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs index f81f952..f533803 100644 --- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs +++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs @@ -74,6 +74,7 @@ /// /// 阴影偏移 /// + [Export] public Vector2 ShadowOffset { get; protected set; } = new Vector2(0, 2); /// @@ -216,21 +217,11 @@ /// public bool ShowOutline { - get => _showOutline; + get => _blendShaderMaterial.GetShaderParameter(_shader_show_outline).AsBool(); set { - if (_blendShaderMaterial != null) - { - if (value != _showOutline) - { - _blendShaderMaterial.SetShaderParameter("show_outline", value); - if (_shadowBlendShaderMaterial != null) - { - _shadowBlendShaderMaterial.SetShaderParameter("show_outline", value); - } - _showOutline = value; - } - } + _blendShaderMaterial.SetShaderParameter(_shader_show_outline, value); + _shadowBlendShaderMaterial.SetShaderParameter(_shader_show_outline, value); } } @@ -239,33 +230,25 @@ /// public Color OutlineColor { - get - { - if (!_initOutlineColor) - { - _initOutlineColor = true; - if (_blendShaderMaterial != null) - { - _outlineColor = _blendShaderMaterial.GetShaderParameter("outline_color").AsColor(); - } - } + get => _blendShaderMaterial.GetShaderParameter(_shader_outline_color).AsColor(); + set => _blendShaderMaterial.SetShaderParameter(_shader_outline_color, value); + } - return _outlineColor; - } - set - { - _initOutlineColor = true; - if (value != _outlineColor) - { - _blendShaderMaterial.SetShaderParameter("outline_color", value); - } - - _outlineColor = value; - } + /// + /// 灰度 + /// + public float Grey + { + get => _blendShaderMaterial.GetShaderParameter(_shader_grey).AsSingle(); + set => _blendShaderMaterial.SetShaderParameter(_shader_grey, value); } // -------------------------------------------------------------------------------- + private static readonly StringName _shader_grey = "grey"; + private static readonly StringName _shader_outline_color = "outline_color"; + private static readonly StringName _shader_show_outline = "show_outline"; + //是否正在调用组件 Update 函数 private bool _updatingComp = false; //组件集合 @@ -326,13 +309,6 @@ //实例索引 private static long _instanceIndex = 0; - - //是否启用描边 - private bool _showOutline = false; - - //描边颜色 - private bool _initOutlineColor = false; - private Color _outlineColor = new Color(0, 0, 0, 1); //冻结显示的Sprite private FreezeSprite _freezeSprite; @@ -370,14 +346,12 @@ Id = _instanceIndex; _blendShaderMaterial = AnimatedSprite.Material as ShaderMaterial; _shadowBlendShaderMaterial = ShadowSprite.Material as ShaderMaterial; - if (_blendShaderMaterial != null) - { - _showOutline = _blendShaderMaterial.GetShaderParameter("show_outline").AsBool(); - } - if (_shadowBlendShaderMaterial != null) + + if (_shadowBlendShaderMaterial != null && _blendShaderMaterial != null) { - _shadowBlendShaderMaterial.SetShaderParameter("show_outline", _showOutline); + var value = _blendShaderMaterial.GetShaderParameter(_shader_show_outline); + _shadowBlendShaderMaterial.SetShaderParameter(_shader_show_outline, value); } ShadowSprite.Visible = false; @@ -1738,4 +1712,15 @@ { return AnimatedSprite.Position + Position; } + + /// + /// 设置物体朝向 + /// + public void SetFace(FaceDirection face) + { + if ((face == FaceDirection.Left && Scale.X > 0) || (face == FaceDirection.Right && Scale.X < 0)) + { + Scale *= new Vector2(-1, 1); + } + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/activity/Component.cs b/DungeonShooting_Godot/src/framework/activity/Component.cs index be0680d..e8fa947 100644 --- a/DungeonShooting_Godot/src/framework/activity/Component.cs +++ b/DungeonShooting_Godot/src/framework/activity/Component.cs @@ -169,7 +169,6 @@ /// /// 如果启用了组件, 则每帧会调用一次 Process /// - /// public virtual void Process(float delta) { } @@ -177,7 +176,6 @@ /// /// 如果启用了组件, 则每物理帧会调用一次 PhysicsProcess /// - /// public virtual void PhysicsProcess(float delta) { } diff --git a/DungeonShooting_Godot/src/game/activity/common/AutoFreezeObject.cs b/DungeonShooting_Godot/src/game/activity/common/AutoFreezeObject.cs new file mode 100644 index 0000000..cd245fd --- /dev/null +++ b/DungeonShooting_Godot/src/game/activity/common/AutoFreezeObject.cs @@ -0,0 +1,63 @@ + +using Godot; + +/// +/// 停止移动后自动冻结对象 +/// +[Tool] +public partial class AutoFreezeObject : ActivityObject +{ + /// + /// 自动播放的动画, 物体会等待该动画播完完成后进入冻结状态, 该动画不能是循环动画 + /// + [Export] + public string AnimationName { get; set; } + + /// + /// 在冻结前是否变灰 + /// + [Export] + public bool AutoToGrey { get; set; } + + private bool _playFlag = false; + private float _grey = 0; + + public override void OnInit() + { + if (!string.IsNullOrEmpty(AnimationName)) + { + _playFlag = true; + AnimatedSprite.AnimationFinished += OnAnimationFinished; + AnimatedSprite.Play(AnimationName); + } + } + + protected override void Process(float delta) + { + //落地静止后将弹壳变为静态贴图 + if (!_playFlag &&!IsThrowing && Altitude <= 0 && MoveController.IsMotionless()) + { + if (AutoToGrey && _grey < 1) + { + //变灰动画时间, 0.5秒 + _grey = Mathf.Min(1, _grey + delta / 0.5f); + Grey = _grey; + return; + } + if (AffiliationArea != null) + { + Freeze(); + } + else + { + Debug.Log(Name + "投抛到画布外了, 强制消除..."); + Destroy(); + } + } + } + + private void OnAnimationFinished() + { + _playFlag = false; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs index 745a057..5bae563 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs @@ -41,6 +41,7 @@ var debris = Create(Ids.Id_enemy_dead0002); debris.PutDown(effPos, RoomLayerEnum.NormalLayer); debris.InheritVelocity(this); + debris.SetFace(Face); //派发敌人死亡信号 EventManager.EmitEvent(EventEnum.OnEnemyDie, this); diff --git a/DungeonShooting_Godot/src/game/activity/shell/Shell.cs b/DungeonShooting_Godot/src/game/activity/shell/Shell.cs deleted file mode 100644 index 379448d..0000000 --- a/DungeonShooting_Godot/src/game/activity/shell/Shell.cs +++ /dev/null @@ -1,32 +0,0 @@ - -using Godot; - -/// -/// 弹壳类 -/// -[Tool] -public partial class Shell : ActivityObject -{ - public override void OnInit() - { - ShadowOffset = new Vector2(0, 1); - ThrowCollisionSize = new Vector2(5, 5); - } - - protected override void Process(float delta) - { - //落地静止后将弹壳变为静态贴图 - if (!IsThrowing && Altitude <= 0 && MoveController.IsMotionless()) - { - if (AffiliationArea != null) - { - Freeze(); - } - else - { - Debug.Log("弹壳投抛到画布外了, 强制消除..."); - Destroy(); - } - } - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs index 7a7eb31..2b8e3fe 100644 --- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs +++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs @@ -19,6 +19,7 @@ public const string prefab_effect_Blood_tscn = "res://prefab/effect/Blood.tscn"; public const string prefab_effect_common_Effect1_tscn = "res://prefab/effect/common/Effect1.tscn"; public const string prefab_effect_enemy_EbenyDead0001_tscn = "res://prefab/effect/enemy/EbenyDead0001.tscn"; + public const string prefab_effect_enemy_EbenyDead0002_tscn = "res://prefab/effect/enemy/EbenyDead0002.tscn"; public const string prefab_effect_enemy_EnemyBlood0001_tscn = "res://prefab/effect/enemy/EnemyBlood0001.tscn"; public const string prefab_effect_weapon_BulletDisappear_tscn = "res://prefab/effect/weapon/BulletDisappear.tscn"; public const string prefab_effect_weapon_BulletSmoke_tscn = "res://prefab/effect/weapon/BulletSmoke.tscn";