Added state component

This commit is contained in:
2024-02-15 13:45:17 +01:00
parent 17a507d07c
commit 37ed8890ec
19 changed files with 172 additions and 86 deletions

View File

@ -0,0 +1,17 @@
class_name AreaSkillInstance
extends SkillInstance
var area: Area3D
func _enter_tree():
super._enter_tree()
area = get_node("Area")
func area_damage(before_time: float, active_time: float, after_time: float):
await get_tree().create_timer(before_time).timeout
area.monitoring = true
await get_tree().create_timer(active_time).timeout
area.monitoring = false
await get_tree().create_timer(after_time).timeout

View File

@ -1,14 +1,15 @@
class_name SkillInstance
extends Node3D
extends Node
func play_animation(animation_name: String, duration: float, speed: float):
var character := get_parent()
var animation := character.get_node("Animation") as AnimationComponent
animation.play_with_duration(animation_name, duration, speed)
var state: StateComponent
var animation: AnimationComponent
func melee_damage(wait_time: float):
var area := get_node("Area")
await get_tree().create_timer(wait_time).timeout
area.monitoring = true
await get_tree().create_timer(0.1).timeout
area.monitoring = false
func _enter_tree():
state = get_parent().get_node("State") as StateComponent
animation = get_parent().get_node("Animation") as AnimationComponent
state.current = StateComponent.State.Skill
func end():
animation.player.speed_scale = 1.0
state.current = state.next_state()
queue_free()

View File

@ -0,0 +1,6 @@
extends SkillInstance
func _ready():
animation.play("human/roll")
await get_tree().create_timer(1.0).timeout
end()

View File

@ -0,0 +1,11 @@
[gd_resource type="Resource" script_class="Skill" load_steps=3 format=3 uid="uid://cnusbw23jf672"]
[ext_resource type="PackedScene" uid="uid://1u5qbxotvgo4" path="res://skill/dash/dash.tscn" id="1_0n3i4"]
[ext_resource type="Script" path="res://skill/Skill.gd" id="2_2m415"]
[resource]
script = ExtResource("2_2m415")
id = "dash"
name = "Dash"
cooldown = 0.0
scene = ExtResource("1_0n3i4")

View File

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://1u5qbxotvgo4"]
[ext_resource type="Script" path="res://skill/dash/dash.gd" id="1_rxa7a"]
[node name="Dash" type="Node"]
script = ExtResource("1_rxa7a")

View File

@ -1,6 +1,6 @@
extends SkillInstance
extends AreaSkillInstance
func _ready():
play_animation("human/slash", 0.8, 1.7)
await melee_damage(0.5)
queue_free()
animation.play("human/slash", 1.7)
await area_damage(0.5, 0.1, 0.2)
end()

View File

@ -1,6 +1,6 @@
extends SkillInstance
extends AreaSkillInstance
func _ready():
play_animation("human/spin", 1.0, 2.0)
await melee_damage(0.5)
queue_free()
animation.play("human/spin", 2.0)
await area_damage(0.5, 0.1, 0.4)
end()

View File

@ -1,6 +1,6 @@
extends SkillInstance
extends AreaSkillInstance
func _ready():
play_animation("human/thrust", 1.0, 2.0)
await melee_damage(0.5)
queue_free()
animation.play("human/thrust", 2.0)
await area_damage(0.5, 0.1, 0.4)
end()