mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-27 22:41:56 +08:00
refactor(特效系统): 重构爆炸效果并删除旧炸弹资源
将炸弹效果重构为更复杂的爆炸效果,包含粒子系统和着色器动画 删除旧的Bomb.tscn资源文件 添加新的Explosion.gdshader着色器实现爆炸效果 创建Explosion.tscn场景包含粒子效果和动画控制
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://bsqq3oqcidjve"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bcvuuy2m0pke0" path="res://components/Abstracts/EffectBase.tscn" id="1_6fayo"]
|
||||
[ext_resource type="Shader" path="res://shaders/Bomb.gdshader" id="2_fmma6"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_1h4c2"]
|
||||
shader = ExtResource("2_fmma6")
|
||||
shader_parameter/explosion_radius = 0.0
|
||||
shader_parameter/explosion_intensity = 1.0
|
||||
shader_parameter/explosion_color = Color(1, 0.5, 0, 1)
|
||||
shader_parameter/time_scale = 1.0
|
||||
|
||||
[node name="EffectBase" instance=ExtResource("1_6fayo")]
|
||||
|
||||
[node name="stage" parent="." index="1"]
|
||||
material = SubResource("ShaderMaterial_1h4c2")
|
||||
@@ -0,0 +1,91 @@
|
||||
[gd_scene load_steps=14 format=3 uid="uid://dn0iwwnq3n8e2"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bcvuuy2m0pke0" path="res://components/Abstracts/EffectBase.tscn" id="1_1mab3"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_jf41v"]
|
||||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_8rfho"]
|
||||
curve = SubResource("Curve_jf41v")
|
||||
|
||||
[sub_resource type="Curve" id="Curve_cxxkf"]
|
||||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_fp3qe"]
|
||||
curve = SubResource("Curve_cxxkf")
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_v1v0w"]
|
||||
colors = PackedColorArray(1, 0, 0, 1, 1, 0.796875, 0, 1)
|
||||
|
||||
[sub_resource type="GradientTexture1D" id="GradientTexture1D_7jhwh"]
|
||||
gradient = SubResource("Gradient_v1v0w")
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_jbp28"]
|
||||
colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="GradientTexture1D" id="GradientTexture1D_30y3h"]
|
||||
gradient = SubResource("Gradient_jbp28")
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_w52ko"]
|
||||
particle_flag_disable_z = true
|
||||
angle_min = 1.07288e-05
|
||||
angle_max = 360.0
|
||||
angle_curve = SubResource("CurveTexture_fp3qe")
|
||||
direction = Vector3(0, -1, 0)
|
||||
spread = 180.0
|
||||
initial_velocity_max = 200.0
|
||||
gravity = Vector3(0, 300, 0)
|
||||
scale_min = 3.0
|
||||
scale_max = 8.0
|
||||
color_ramp = SubResource("GradientTexture1D_30y3h")
|
||||
color_initial_ramp = SubResource("GradientTexture1D_7jhwh")
|
||||
alpha_curve = SubResource("CurveTexture_8rfho")
|
||||
|
||||
[sub_resource type="Animation" id="Animation_pa4et"]
|
||||
resource_name = "explosion"
|
||||
length = 2.0
|
||||
step = 0.1
|
||||
tracks/0/type = "bezier"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:material:shader_parameter/explosion_radius")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"handle_modes": PackedInt32Array(0, 0, 0),
|
||||
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 0.5, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0),
|
||||
"times": PackedFloat32Array(0, 1, 2)
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_rcc6g"]
|
||||
length = 0.001
|
||||
tracks/0/type = "bezier"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:material:shader_parameter/explosion_radius")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"handle_modes": PackedInt32Array(0),
|
||||
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0),
|
||||
"times": PackedFloat32Array(0)
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_n7i5u"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_rcc6g"),
|
||||
"explosion": SubResource("Animation_pa4et")
|
||||
}
|
||||
|
||||
[node name="Explosion" instance=ExtResource("1_1mab3")]
|
||||
|
||||
[node name="particles" parent="." index="0"]
|
||||
amount = 200
|
||||
process_material = SubResource("ParticleProcessMaterial_w52ko")
|
||||
|
||||
[node name="animator" parent="stage" index="0"]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_n7i5u")
|
||||
}
|
||||
@@ -72,6 +72,7 @@ func dotLoop():
|
||||
if await applyDot():
|
||||
await dotLoop()
|
||||
|
||||
# 抽象方法
|
||||
func ai():
|
||||
pass
|
||||
func destroy():
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform float explosion_radius : hint_range(0.0, 1.0) = 0.0;
|
||||
uniform float explosion_intensity : hint_range(0.0, 2.0) = 1.0;
|
||||
uniform vec4 explosion_color : source_color = vec4(1.0, 0.5, 0.0, 1.0);
|
||||
uniform float time_scale = 1.0;
|
||||
|
||||
void fragment() {
|
||||
// 计算当前像素到中心的距离
|
||||
vec2 center = vec2(0.5, 0.5);
|
||||
float dist = distance(UV, center);
|
||||
|
||||
// 使用TIME创建随时间变化的爆炸效果
|
||||
float time = TIME * time_scale;
|
||||
float explosion = smoothstep(explosion_radius, explosion_radius - 0.2, dist) * explosion_intensity;
|
||||
|
||||
// 添加一些噪声使爆炸看起来更自然
|
||||
float noise = sin(dist * 20.0 - time * 5.0) * 0.5 + 0.5;
|
||||
explosion *= noise;
|
||||
|
||||
// 限制explosion值在0-1范围内
|
||||
explosion = clamp(explosion, 0.0, 1.0);
|
||||
|
||||
// 计算最终颜色,混合原始纹理和爆炸效果
|
||||
vec4 original_color = texture(TEXTURE, UV);
|
||||
vec4 final_color = mix(original_color, explosion_color, explosion);
|
||||
|
||||
// 添加一些发光效果
|
||||
float glow = exp(-dist * 5.0) * explosion_intensity;
|
||||
final_color.rgb += glow * explosion_color.rgb;
|
||||
|
||||
// 确保alpha通道正确设置
|
||||
final_color.a = max(original_color.a, explosion);
|
||||
|
||||
// 输出最终颜色
|
||||
COLOR = final_color;
|
||||
}
|
||||
Reference in New Issue
Block a user