diff --git a/config/character/monster00.tres b/config/character/monster00.tres index 5a46fd0..c2f29a0 100644 --- a/config/character/monster00.tres +++ b/config/character/monster00.tres @@ -23,3 +23,5 @@ ai = ExtResource("1_lsd6j") hp_max = 1000.0 attack = 10.0 sub_character_auto_create = false +material_on = 1 +material_off = 1 diff --git a/render/material/fragment.tres b/render/material/fragment.tres new file mode 100644 index 0000000..2c61bde --- /dev/null +++ b/render/material/fragment.tres @@ -0,0 +1,9 @@ +[gd_resource type="ShaderMaterial" load_steps=3 format=3 uid="uid://b3mpocbc8svx2"] + +[ext_resource type="Shader" path="res://render/shader/fragment.gdshader" id="1_hr2a5"] +[ext_resource type="Texture2D" uid="uid://bcrr12gbos636" path="res://render/texture/particle/shape/fragment1.png" id="2_r0lv7"] + +[resource] +render_priority = 0 +shader = ExtResource("1_hr2a5") +shader_parameter/tex_main = ExtResource("2_r0lv7") diff --git a/render/shader/fragment.gdshader b/render/shader/fragment.gdshader new file mode 100644 index 0000000..eab3a59 --- /dev/null +++ b/render/shader/fragment.gdshader @@ -0,0 +1,10 @@ +shader_type spatial; +render_mode unshaded; + +uniform sampler2D tex_main : source_color; + +void fragment() { + vec4 col = texture(tex_main, UV); + ALBEDO = COLOR.rgb * col.r; + ALPHA = COLOR.a * col.r; +} diff --git a/render/texture/particle/gradient/gradient3.png b/render/texture/particle/gradient/gradient3.png new file mode 100644 index 0000000..e355fd5 Binary files /dev/null and b/render/texture/particle/gradient/gradient3.png differ diff --git a/render/texture/particle/gradient/gradient3.png.import b/render/texture/particle/gradient/gradient3.png.import new file mode 100644 index 0000000..cfbc163 --- /dev/null +++ b/render/texture/particle/gradient/gradient3.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d2tcm2g7sh1ne" +path="res://.godot/imported/gradient3.png-b722dde19beb65f5e22df2428d9b9ef1.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://render/texture/particle/gradient/gradient3.png" +dest_files=["res://.godot/imported/gradient3.png-b722dde19beb65f5e22df2428d9b9ef1.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=0 +compress/normal_map=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=false +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/render/texture/particle/shape/circle2.png b/render/texture/particle/shape/circle2.png index c98836c..5241c3b 100644 Binary files a/render/texture/particle/shape/circle2.png and b/render/texture/particle/shape/circle2.png differ diff --git a/render/texture/particle/shape/fragment1.png b/render/texture/particle/shape/fragment1.png new file mode 100644 index 0000000..1fe307d Binary files /dev/null and b/render/texture/particle/shape/fragment1.png differ diff --git a/render/texture/particle/shape/fragment1.png.import b/render/texture/particle/shape/fragment1.png.import new file mode 100644 index 0000000..add09c1 --- /dev/null +++ b/render/texture/particle/shape/fragment1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bcrr12gbos636" +path="res://.godot/imported/fragment1.png-81795d09090ef39d00ef7ac6d73d6291.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://render/texture/particle/shape/fragment1.png" +dest_files=["res://.godot/imported/fragment1.png-81795d09090ef39d00ef7ac6d73d6291.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=0 +compress/normal_map=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=false +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/render/texture/particle/shape/water1.png b/render/texture/particle/shape/water1.png new file mode 100644 index 0000000..e23643e Binary files /dev/null and b/render/texture/particle/shape/water1.png differ diff --git a/render/texture/particle/shape/water1.png.import b/render/texture/particle/shape/water1.png.import new file mode 100644 index 0000000..b09a636 --- /dev/null +++ b/render/texture/particle/shape/water1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dcj75sifltene" +path="res://.godot/imported/water1.png-d5bc510fd51cdecdbbc1f1f7e7841665.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://render/texture/particle/shape/water1.png" +dest_files=["res://.godot/imported/water1.png-d5bc510fd51cdecdbbc1f1f7e7841665.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=0 +compress/normal_map=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=false +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/scene/effect/particle/particle_blood_decal.tscn b/scene/effect/particle/particle_blood_decal.tscn new file mode 100644 index 0000000..40023bb --- /dev/null +++ b/scene/effect/particle/particle_blood_decal.tscn @@ -0,0 +1,29 @@ +[gd_scene load_steps=6 format=3 uid="uid://ccxyyunj4ohqt"] + +[ext_resource type="Script" path="res://script/effect/particle.gd" id="1_6r6qw"] +[ext_resource type="Script" path="res://script/effect/particle_decal.gd" id="3_yeg2u"] +[ext_resource type="Texture2D" uid="uid://b6bfacouwy2hi" path="res://render/texture/decal/decal_glow.png" id="6_8db0o"] + +[sub_resource type="Gradient" id="Gradient_jevf8"] +offsets = PackedFloat32Array(0, 0.82808, 1) +colors = PackedColorArray(1, 0, 0, 1, 1, 0, 0, 0.805158, 1, 0, 0, 0) + +[sub_resource type="Curve" id="Curve_w5jkx"] +max_value = 0.6 +_data = [Vector2(0, 0.31259), 0.0, 0.953112, 0, 0, Vector2(0.0742705, 0.500205), 0.0, 0.0, 0, 0, Vector2(0.143236, 0.456295), 0.0, 0.0, 0, 0, Vector2(1, 0.6), 0.0, 0.0, 0, 0] +point_count = 4 + +[node name="Particle" type="Node3D"] +script = ExtResource("1_6r6qw") + +[node name="DecalBlood" type="Decal" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.358925, 0) +size = Vector3(0.5, 5, 0.5) +texture_albedo = ExtResource("6_8db0o") +modulate = Color(0, 0, 0, 1) +upper_fade = 21.3037 +cull_mask = 1 +script = ExtResource("3_yeg2u") +lifetime = 3.0 +gradient = SubResource("Gradient_jevf8") +scale_curve = SubResource("Curve_w5jkx") diff --git a/scene/effect/particle/particle_fragment.tscn b/scene/effect/particle/particle_fragment.tscn new file mode 100644 index 0000000..694a167 --- /dev/null +++ b/scene/effect/particle/particle_fragment.tscn @@ -0,0 +1,28 @@ +[gd_scene load_steps=6 format=3 uid="uid://b0ogpoluxbsxx"] + +[ext_resource type="Script" path="res://script/effect/fragment.gd" id="1_blddo"] +[ext_resource type="Material" uid="uid://b3mpocbc8svx2" path="res://render/material/fragment.tres" id="2_cd8nd"] +[ext_resource type="PackedScene" uid="uid://ccxyyunj4ohqt" path="res://scene/effect/particle/particle_blood_decal.tscn" id="2_hrv13"] +[ext_resource type="Texture2D" uid="uid://bcrr12gbos636" path="res://render/texture/particle/shape/fragment1.png" id="3_vu5gy"] + +[sub_resource type="SphereShape3D" id="SphereShape3D_1r022"] +radius = 0.1 + +[node name="Fragment" type="CharacterBody3D"] +collision_layer = 256 +script = ExtResource("1_blddo") +sub = ExtResource("2_hrv13") +velocity_min = Vector2(1, 2) +velocity_max = Vector2(2, 4) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +shape = SubResource("SphereShape3D_1r022") + +[node name="Sprite3D" type="Sprite3D" parent="."] +unique_name_in_owner = true +material_override = ExtResource("2_cd8nd") +modulate = Color(1, 0, 0, 1) +pixel_size = 0.004 +texture = ExtResource("3_vu5gy") +hframes = 2 +vframes = 2 diff --git a/scene/effect/particle/particle_material_cloth.tscn b/scene/effect/particle/particle_material_cloth.tscn new file mode 100644 index 0000000..d50a8fe --- /dev/null +++ b/scene/effect/particle/particle_material_cloth.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=4 format=3 uid="uid://j0wrno4hl0hp"] + +[ext_resource type="Script" path="res://script/effect/particle.gd" id="1_kd50q"] +[ext_resource type="Script" path="res://script/effect/particle_sub_emitter.gd" id="2_osya7"] +[ext_resource type="PackedScene" uid="uid://b0ogpoluxbsxx" path="res://scene/effect/particle/particle_fragment.tscn" id="3_o8j15"] + +[node name="Particle" type="Node3D"] +script = ExtResource("1_kd50q") + +[node name="ParticleSubEmitter" type="Node3D" parent="."] +script = ExtResource("2_osya7") +sub = ExtResource("3_o8j15") +count = 2 diff --git a/scene/level/level.tscn b/scene/level/level.tscn index 3a38080..de737fd 100644 --- a/scene/level/level.tscn +++ b/scene/level/level.tscn @@ -73,7 +73,7 @@ metadata/_editor_floor_ = Vector3(0, 1, 0) [node name="BornPos" type="Node3D" parent="."] unique_name_in_owner = true -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 45.961, 5.12, 5.12) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.56, 2.56, 0) [node name="Levels" type="Node3D" parent="."] unique_name_in_owner = true diff --git a/script/_global/enum.gd b/script/_global/enum.gd index 5fb684e..2f58f39 100644 --- a/script/_global/enum.gd +++ b/script/_global/enum.gd @@ -18,4 +18,5 @@ enum EBreakLevel {None, Cancel, Jump, Break, Walk} #不可打断 取消技打断 enum ECoreType {Active, Passive} enum EGlobalEffect {CameraSize, CameraShake, ColorShift, Blur, SpeedLine} enum EAIRoleType {None, Saber, Assassin, Caster} -enum ESkillWarnType {None, Normal, Mid, Heavy} \ No newline at end of file +enum ESkillWarnType {None, Normal, Mid, Heavy} +enum EMaterial {None, Cloth, Steel} \ No newline at end of file diff --git a/script/_global/setting.gd b/script/_global/setting.gd index 726cb60..47c5eab 100644 --- a/script/_global/setting.gd +++ b/script/_global/setting.gd @@ -4,7 +4,7 @@ extends Node3D const pixel_size: float = 0.02 const grid_pixel_size: float = 32 const animation_frame_rate: float = 0.1 -const animation_speed_scale: float = 1.1 +const animation_speed_scale: float = 1.0 #技能系统 const input_alive_time: float = 0.5 #移动 diff --git a/script/_global/util.gd b/script/_global/util.gd index 1e4f794..ac9960e 100644 --- a/script/_global/util.gd +++ b/script/_global/util.gd @@ -15,6 +15,10 @@ func dir_angle(dir: Vector2) -> float: return dir.angle_to(Vector2.RIGHT) +func angle_dir(angle: float) -> Vector2: + return Vector2.RIGHT.rotated(angle) + + func vector_reduce(vector: Vector2, reduce: float) -> Vector2: var length: float = vector.length() if length == 0: diff --git a/script/character/battle.gd b/script/character/battle.gd index 673d9fb..837add1 100644 --- a/script/character/battle.gd +++ b/script/character/battle.gd @@ -243,6 +243,13 @@ func add_attack(from: int, to: int, dir: Vector2, attack: AttackCfg) -> HitResul Enum.EDamageType.Blunt: character_to.cast_particle(ResourceManager.particle_hit_blunt, false) Enum.EDamageType.Ground: character_to.cast_particle(ResourceManager.particle_hit_ground, false) _: pass + + #受击材质特效 + if damage>0: + var material: Enum.EMaterial = cfg_to.material_on if has_shield else cfg_to.material_off + match material: + Enum.EMaterial.Cloth: character_to.cast_particle(ResourceManager.particle_material_cloth, false) + _: pass #抖动 character_to.add_buff("shake_x", 0.2, true) diff --git a/script/config/character_cfg.gd b/script/config/character_cfg.gd index 5d45b69..e95f2cc 100644 --- a/script/config/character_cfg.gd +++ b/script/config/character_cfg.gd @@ -24,6 +24,9 @@ class_name CharacterCfg @export var attack2_box: AttackBoxCfg @export var sub_character: CharacterCfg @export var sub_character_auto_create: bool +#材质 +@export var material_on: Enum.EMaterial = Enum.EMaterial.None #有护盾时材质 +@export var material_off: Enum.EMaterial = Enum.EMaterial.None #无护盾时材质 var core_cfg_list: Array[CoreCfg] diff --git a/script/effect/fragment.gd b/script/effect/fragment.gd new file mode 100644 index 0000000..2d18e00 --- /dev/null +++ b/script/effect/fragment.gd @@ -0,0 +1,34 @@ +extends CharacterBody3D +class_name Fragment + +@export var sub: PackedScene +@export var gravity_scale: float = 1.0 +@export var velocity_min: Vector2 = Vector2.ONE +@export var velocity_max: Vector2 = Vector2.ONE + +@onready var sprite3D: Sprite3D = %Sprite3D as Sprite3D + +var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") +var frame_rate: float = 0.1 +var frame_time: float = 0 + + +func _ready(): + var dir: Vector2 = Util.angle_dir(randf_range(0, 360)) * randf_range(velocity_min.x, velocity_max.x) + velocity.x = dir.x + velocity.z = dir.y + velocity.y = randf_range(velocity_min.y, velocity_max.y) + + +func _process(delta: float) -> void: + velocity.y -= gravity * gravity_scale * delta + var frame_count: int = sprite3D.hframes * sprite3D.vframes + var frame_time_all: float = frame_rate * frame_count + frame_time += delta + sprite3D.frame = int(frame_time / frame_rate) % frame_count + frame_time = fmod(frame_time, frame_time_all) + if move_and_slide(): + var sub_particle: Node3D = sub.instantiate() as Node3D + SignalManager.effect_create.emit(sub_particle) + sub_particle.global_position = global_position + queue_free() diff --git a/script/effect/particle.gd b/script/effect/particle.gd index 2495d69..49c15f4 100644 --- a/script/effect/particle.gd +++ b/script/effect/particle.gd @@ -3,10 +3,11 @@ class_name Particle @export var is_billboard: bool -var sub_particle_list: Array[Particle] -var particle_list: Array[GPUParticles3D] -var speed_scale_list: Array[Variant] = [] -var decal_list: Array[Variant] = [] +var sub_particle_list: Array[Particle] = [] +var particle_list: Array[GPUParticles3D] = [] +var speed_scale_list: Array[float] = [] +var decal_list: Array[ParticleDecal] = [] +var sub_emitter_list: Array[ParticleSubEmitter] = [] func on_ready(): @@ -19,7 +20,10 @@ func on_ready(): speed_scale_list.append(particle.speed_scale) particle.restart() elif child is ParticleDecal: + child.on_ready() decal_list.append(child) + elif child is ParticleSubEmitter: + sub_emitter_list.append(child) else: continue if child.lifetime > lifetime_now: @@ -38,7 +42,7 @@ func on_process(delta: float): func on_set_pause(is_pause_set: bool): for i in range(len(particle_list)): var particle: GPUParticles3D = particle_list[i] - var speed_scale = speed_scale_list[i] + var speed_scale: float = speed_scale_list[i] particle.speed_scale = 0 if is_pause else speed_scale for sub_particle: Particle in sub_particle_list: sub_particle.set_pause(is_pause_set) diff --git a/script/effect/particle_decal.gd b/script/effect/particle_decal.gd index db207ba..07b7dd8 100644 --- a/script/effect/particle_decal.gd +++ b/script/effect/particle_decal.gd @@ -9,6 +9,11 @@ class_name ParticleDecal var lifetime_now: float +func on_ready() -> void: + var scale_sample: float = scale_curve.sample(0) + scale = Vector3(scale_sample, 1, scale_sample) + + func on_process(delta: float) -> void: lifetime_now += delta var rate: float = lifetime_now / lifetime diff --git a/script/effect/particle_sub_emitter.gd b/script/effect/particle_sub_emitter.gd new file mode 100644 index 0000000..16b2bd6 --- /dev/null +++ b/script/effect/particle_sub_emitter.gd @@ -0,0 +1,12 @@ +extends EffectBase +class_name ParticleSubEmitter + +@export var sub: PackedScene +@export var count: int = 1 + + +func on_ready(): + for i in range(count): + var sub_particle: Node3D = sub.instantiate() as Node3D + SignalManager.effect_create.emit(sub_particle) + sub_particle.global_position = global_position diff --git a/script/manager/resource_manager.gd b/script/manager/resource_manager.gd index a7a3774..e5934b5 100644 --- a/script/manager/resource_manager.gd +++ b/script/manager/resource_manager.gd @@ -14,6 +14,8 @@ var material_character_sub: Material = load("res://render/material/character_sub var particle_hit_sharp: PackedScene = load("res://scene/effect/particle/particle_hit_sharp.tscn") var particle_hit_blunt: PackedScene = load("res://scene/effect/particle/particle_hit_blunt.tscn") var particle_hit_ground: PackedScene = load("res://scene/effect/particle/particle_hit_ground.tscn") +#hit_material +var particle_material_cloth: PackedScene = load("res://scene/effect/particle/particle_material_cloth.tscn") #warn var particle_warn_normal: PackedScene = load("res://scene/effect/particle/particle_warn_normal.tscn") var particle_warn_mid: PackedScene = load("res://scene/effect/particle/particle_warn_mid.tscn")