From a363d83355dd107b09326440cd90f2ecb9afd780 Mon Sep 17 00:00:00 2001 From: chendian <-> Date: Fri, 20 Oct 2023 01:16:10 +0800 Subject: [PATCH] afterimage --- .../skill_animation/hero01_long_flash.tres | 23 +++++++++++++++++++ scene/character/character.tscn | 16 +++++++------ scene/effect/afterimage/normal.tscn | 9 ++++++++ scene/launcher.tscn | 6 ++++- script/character/character.gd | 2 ++ script/character/effect.gd | 20 ++++++++++++++++ script/character/view.gd | 8 ++++++- script/effect/afterimage.gd | 22 ++++++++++++++++++ script/manager/effect_manager.gd | 11 +++++++++ script/manager/signal_manager.gd | 3 +++ 10 files changed, 111 insertions(+), 9 deletions(-) create mode 100644 scene/effect/afterimage/normal.tscn create mode 100644 script/character/effect.gd create mode 100644 script/effect/afterimage.gd create mode 100644 script/manager/effect_manager.gd diff --git a/resource/skill_animation/hero01_long_flash.tres b/resource/skill_animation/hero01_long_flash.tres index 0edd5ce..f4a8118 100644 --- a/resource/skill_animation/hero01_long_flash.tres +++ b/resource/skill_animation/hero01_long_flash.tres @@ -77,3 +77,26 @@ tracks/5/keys = { "update": 1, "values": [4.0, 0.0] } +tracks/6/type = "method" +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/path = NodePath("Effect") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"values": [{ +"args": [], +"method": &"cast_after_image" +}, { +"args": [], +"method": &"cast_after_image" +}, { +"args": [], +"method": &"cast_after_image" +}, { +"args": [], +"method": &"cast_after_image" +}] +} diff --git a/scene/character/character.tscn b/scene/character/character.tscn index 0433991..27d76c8 100644 --- a/scene/character/character.tscn +++ b/scene/character/character.tscn @@ -1,16 +1,17 @@ -[gd_scene load_steps=14 format=3 uid="uid://ksxwg0alt2us"] +[gd_scene load_steps=15 format=3 uid="uid://ksxwg0alt2us"] [ext_resource type="Script" path="res://script/character/character.gd" id="1_tonbs"] [ext_resource type="Script" path="res://script/character/status.gd" id="2_txdip"] [ext_resource type="Shader" path="res://render/shader/character.gdshader" id="3_ed424"] -[ext_resource type="SpriteFrames" uid="uid://ce83cuqwgwwi4" path="res://resource/animation/character/hero01_long_attack.aseprite" id="3_q8i10"] [ext_resource type="Script" path="res://script/character/move.gd" id="4_66r53"] [ext_resource type="Texture2D" uid="uid://daqn6aqfp1hva" path="res://resource/animation/character/hero01_long_attack.png" id="4_fcd8a"] [ext_resource type="Script" path="res://script/character/view.gd" id="4_vijjv"] +[ext_resource type="SpriteFrames" uid="uid://dhfqj1dxldqao" path="res://resource/animation/character/hero01_long_skill01.aseprite" id="5_7jbf8"] [ext_resource type="Script" path="res://script/character/skill.gd" id="6_h4xqy"] [ext_resource type="AnimationLibrary" uid="uid://croik07a1qko5" path="res://resource/skill_animation_library/animation_library.tres" id="6_pakq5"] [ext_resource type="Script" path="res://script/character/battle.gd" id="8_w84sf"] [ext_resource type="Script" path="res://script/character/buff.gd" id="9_jlnhy"] +[ext_resource type="Script" path="res://script/character/effect.gd" id="12_eyfcd"] [sub_resource type="BoxShape3D" id="BoxShape3D_ty8lx"] @@ -31,8 +32,6 @@ shape = SubResource("BoxShape3D_ty8lx") [node name="Status" type="Node3D" parent="."] unique_name_in_owner = true script = ExtResource("2_txdip") -speed_up_rate = -1.0 -break_level = 4 [node name="View" type="AnimatedSprite3D" parent="."] unique_name_in_owner = true @@ -44,9 +43,8 @@ gi_mode = 0 double_sided = false alpha_cut = 2 texture_filter = 0 -sprite_frames = ExtResource("3_q8i10") -animation = &"long_air_attack01" -frame = 8 +sprite_frames = ExtResource("5_7jbf8") +animation = &"long_flash" script = ExtResource("4_vijjv") [node name="Move" type="Node3D" parent="."] @@ -68,5 +66,9 @@ script = ExtResource("8_w84sf") unique_name_in_owner = true script = ExtResource("9_jlnhy") +[node name="Effect" type="Node3D" parent="."] +unique_name_in_owner = true +script = ExtResource("12_eyfcd") + [connection signal="animation_finished" from="View" to="View" method="_on_animation_finished"] [connection signal="animation_finished" from="Skill" to="Skill" method="_on_animation_finished"] diff --git a/scene/effect/afterimage/normal.tscn b/scene/effect/afterimage/normal.tscn new file mode 100644 index 0000000..01f120e --- /dev/null +++ b/scene/effect/afterimage/normal.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=3 format=3 uid="uid://b12fa5bpdmhms"] + +[ext_resource type="SpriteFrames" uid="uid://cwe8setoi6bd" path="res://resource/animation/character/hero01_move.aseprite" id="1_1twno"] +[ext_resource type="Script" path="res://script/effect/afterimage.gd" id="2_grtq1"] + +[node name="AfterImage" type="AnimatedSprite3D"] +sprite_frames = ExtResource("1_1twno") +animation = &"idle_loop" +script = ExtResource("2_grtq1") diff --git a/scene/launcher.tscn b/scene/launcher.tscn index d440e77..6d31b34 100644 --- a/scene/launcher.tscn +++ b/scene/launcher.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://bkhnhc6bk3w7l"] +[gd_scene load_steps=12 format=3 uid="uid://bkhnhc6bk3w7l"] [ext_resource type="Script" path="res://script/manager/game_manager.gd" id="1_q2t80"] [ext_resource type="ArrayMesh" uid="uid://cap7t5iwpjpi2" path="res://resource/level/levelground0000.vox" id="1_u51ir"] @@ -9,6 +9,7 @@ [ext_resource type="PackedScene" uid="uid://cc525u8auypjf" path="res://scene/ui/profile_screen.tscn" id="6_u1fxn"] [ext_resource type="PackedScene" uid="uid://126wph4owvoy" path="res://scene/ui/hud_screen.tscn" id="7_gx646"] [ext_resource type="Texture2D" uid="uid://bjv7f83tdgq17" path="res://render/texture/explodeDecal.png" id="7_hqv3v"] +[ext_resource type="Script" path="res://script/manager/effect_manager.gd" id="8_0jv87"] [sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_2mxa4"] data = PackedVector3Array(-6.4, 0, -6.4, -3.2, 0, -6.4, -3.2, 0, 6.4, -3.2, 0, 6.4, -6.4, 0, 6.4, -6.4, 0, -6.4, -3.2, 0, 3.2, 6.4, 0, 3.2, 6.4, 0, 6.4, 6.4, 0, 6.4, -3.2, 0, 6.4, -3.2, 0, 3.2, -3.2, 0, -3.2, 3.2, 0, -3.2, 3.2, 0, 3.2, 3.2, 0, 3.2, -3.2, 0, 3.2, -3.2, 0, -3.2, -3.2, 0, -6.4, 6.4, 0, -6.4, 6.4, 0, -3.2, 6.4, 0, -3.2, -3.2, 0, -3.2, -3.2, 0, -6.4, 3.2, 0, -3.2, 6.4, 0, -3.2, 6.4, 0, 3.2, 6.4, 0, 3.2, 3.2, 0, 3.2, 3.2, 0, -3.2, -3.2, -0.1, 6.4, -3.2, -0.1, -6.4, -6.4, -0.1, -6.4, -6.4, -0.1, -6.4, -6.4, -0.1, 6.4, -3.2, -0.1, 6.4, 6.4, -0.1, 6.4, 6.4, -0.1, 3.2, -3.2, -0.1, 3.2, -3.2, -0.1, 3.2, -3.2, -0.1, 6.4, 6.4, -0.1, 6.4, 3.2, -0.1, 3.2, 3.2, -0.1, -3.2, -3.2, -0.1, -3.2, -3.2, -0.1, -3.2, -3.2, -0.1, 3.2, 3.2, -0.1, 3.2, 6.4, -0.1, -3.2, 6.4, -0.1, -6.4, -3.2, -0.1, -6.4, -3.2, -0.1, -6.4, -3.2, -0.1, -3.2, 6.4, -0.1, -3.2, 6.4, -0.1, 3.2, 6.4, -0.1, -3.2, 3.2, -0.1, -3.2, 3.2, -0.1, -3.2, 3.2, -0.1, 3.2, 6.4, -0.1, 3.2, -6.4, 0, -6.4, -6.4, 0, 6.4, -6.4, -0.1, 6.4, -6.4, -0.1, 6.4, -6.4, -0.1, -6.4, -6.4, 0, -6.4, 6.4, 0, -6.4, 6.4, -0.1, -6.4, 6.4, -0.1, 6.4, 6.4, -0.1, 6.4, 6.4, 0, 6.4, 6.4, 0, -6.4, -6.4, -0.1, 6.4, -6.4, 0, 6.4, 6.4, 0, 6.4, 6.4, 0, 6.4, 6.4, -0.1, 6.4, -6.4, -0.1, 6.4, 6.4, 0, -6.4, -6.4, 0, -6.4, -6.4, -0.1, -6.4, -6.4, -0.1, -6.4, 6.4, -0.1, -6.4, 6.4, 0, -6.4) @@ -59,6 +60,9 @@ script = ExtResource("4_oonkb") [node name="HudScreen" parent="GameManager/UIManager" instance=ExtResource("7_gx646")] +[node name="EffectManager" type="Node3D" parent="GameManager"] +script = ExtResource("8_0jv87") + [node name="EditorTool" type="Node3D" parent="."] script = ExtResource("5_n3qhi") diff --git a/script/character/character.gd b/script/character/character.gd index a02f775..6c24312 100644 --- a/script/character/character.gd +++ b/script/character/character.gd @@ -24,6 +24,7 @@ func build_view(cfg:CharacterCfg): collision.position = Vector3(0,half_height,0) collision.scale = Vector3(width,half_height*2,width) status.basic_offset = Vector3(0,half_height,0) + view.scale = Vector3(1,Setting.sprite_scale,1) view.init(cfg.sprite_frames) skill.init() @@ -41,6 +42,7 @@ func manager()->CharacterManager:return character_manager func id()->int:return status.id func team()->Enum.ETeam:return status.team func pos()->Vector2:return Vector2(position.x,position.z) +func view_pos()->Vector3:return position + view.position #==interface== func set_pos(pos:Vector3):position = pos diff --git a/script/character/effect.gd b/script/character/effect.gd new file mode 100644 index 0000000..acaf8f9 --- /dev/null +++ b/script/character/effect.gd @@ -0,0 +1,20 @@ +extends Node + +@onready var afterimage = preload("res://scene/effect/afterimage/normal.tscn") + +@onready var character = (get_owner() as Character) +@onready var view = (%View as View) + +func _ready(): + pass # Replace with function body. + +func _process(delta): + pass + +func cast_after_image(): + var new_afterimage = afterimage.instantiate() as Afterimage + new_afterimage.position = character.view_pos() + new_afterimage.name = "afterimage" + new_afterimage.velocity = character.velocity / 4 + view.clone(new_afterimage) + SignalManager.effect_create.emit(new_afterimage) diff --git a/script/character/view.gd b/script/character/view.gd index eaa51fd..ed02b43 100644 --- a/script/character/view.gd +++ b/script/character/view.gd @@ -138,4 +138,10 @@ func update_texture(): func update_flash_white(): var material = material_override as ShaderMaterial material.set_shader_parameter("flash_white",status.flash_white_rate) - + +func clone(target:AnimatedSprite3D): + target.sprite_frames = sprite_frames + target.animation = animation + target.frame = frame + target.frame_progress = frame_progress + target.scale = scale diff --git a/script/effect/afterimage.gd b/script/effect/afterimage.gd new file mode 100644 index 0000000..b5ca10d --- /dev/null +++ b/script/effect/afterimage.gd @@ -0,0 +1,22 @@ +extends AnimatedSprite3D +class_name Afterimage + +@export var duration_max:float = 0.2 +@export var is_moving:bool = true + +var duration:float +var velocity:Vector3 + +func _ready(): + duration = duration_max + +func _process(delta): + if is_moving: + position += velocity*delta + + var rate = duration / duration_max + modulate.a = rate + + duration-=delta + if duration<=0: + queue_free() diff --git a/script/manager/effect_manager.gd b/script/manager/effect_manager.gd new file mode 100644 index 0000000..2fc2854 --- /dev/null +++ b/script/manager/effect_manager.gd @@ -0,0 +1,11 @@ +extends Node3D + + +func _ready(): + SignalManager.effect_create.connect(on_effect_create) + +func _process(delta): + pass + +func on_effect_create(effect:Node3D): + add_child(effect) diff --git a/script/manager/signal_manager.gd b/script/manager/signal_manager.gd index 4647b8a..42f8caf 100644 --- a/script/manager/signal_manager.gd +++ b/script/manager/signal_manager.gd @@ -4,3 +4,6 @@ extends Node3D signal input_action_pressed signal input_action_released signal input_action_move(Vector2) + +#effect +signal effect_create