Added skill system
This commit is contained in:
7
client/skill/MeleeArea.gd
Normal file
7
client/skill/MeleeArea.gd
Normal file
@ -0,0 +1,7 @@
|
||||
extends Area3D
|
||||
|
||||
func on_body_entered(body: Node3D):
|
||||
var health := body.get_node_or_null("Health") as HealthComponent
|
||||
|
||||
if health:
|
||||
health.take_damage(DamageInstance.new(100))
|
8
client/skill/Skill.gd
Normal file
8
client/skill/Skill.gd
Normal file
@ -0,0 +1,8 @@
|
||||
class_name Skill
|
||||
extends Resource
|
||||
|
||||
@export var id: String
|
||||
@export var name: String
|
||||
@export var icon: Texture2D
|
||||
@export var cooldown: float
|
||||
@export var scene: PackedScene
|
14
client/skill/SkillInstance.gd
Normal file
14
client/skill/SkillInstance.gd
Normal file
@ -0,0 +1,14 @@
|
||||
class_name SkillInstance
|
||||
extends Node3D
|
||||
|
||||
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)
|
||||
|
||||
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
|
18
client/skill/melee_area.tscn
Normal file
18
client/skill/melee_area.tscn
Normal file
@ -0,0 +1,18 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://f1keiecsx5kw"]
|
||||
|
||||
[ext_resource type="Script" path="res://skill/MeleeArea.gd" id="1_qgaoh"]
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_4r7eu"]
|
||||
radius = 1.5
|
||||
|
||||
[node name="MeleeArea" type="Area3D"]
|
||||
collision_layer = 0
|
||||
collision_mask = 256
|
||||
monitoring = false
|
||||
monitorable = false
|
||||
script = ExtResource("1_qgaoh")
|
||||
|
||||
[node name="CylinderShape" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("CylinderShape3D_4r7eu")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="on_body_entered"]
|
6
client/skill/slash/slash.gd
Normal file
6
client/skill/slash/slash.gd
Normal file
@ -0,0 +1,6 @@
|
||||
extends SkillInstance
|
||||
|
||||
func _ready():
|
||||
play_animation("human/slash", 0.7, 1.4)
|
||||
await melee_damage(0.5)
|
||||
queue_free()
|
13
client/skill/slash/slash.tres
Normal file
13
client/skill/slash/slash.tres
Normal file
@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="Skill" load_steps=3 format=3 uid="uid://yaq8ui3f6fwa"]
|
||||
|
||||
[ext_resource type="Script" path="res://skill/Skill.gd" id="1_268fv"]
|
||||
[ext_resource type="PackedScene" uid="uid://bhy50ngwxib3i" path="res://skill/slash/slash.tscn" id="1_icaie"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_268fv")
|
||||
id = "slash"
|
||||
name = "Slash"
|
||||
cooldown = 0.0
|
||||
scene = ExtResource("1_icaie")
|
||||
cast_time = 0.7
|
||||
total_time = 1.0
|
10
client/skill/slash/slash.tscn
Normal file
10
client/skill/slash/slash.tscn
Normal file
@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://bhy50ngwxib3i"]
|
||||
|
||||
[ext_resource type="Script" path="res://skill/slash/slash.gd" id="1_dbiye"]
|
||||
[ext_resource type="PackedScene" uid="uid://f1keiecsx5kw" path="res://skill/melee_area.tscn" id="2_q0v6t"]
|
||||
|
||||
[node name="Slash" type="Node3D"]
|
||||
script = ExtResource("1_dbiye")
|
||||
|
||||
[node name="Area" parent="." instance=ExtResource("2_q0v6t")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1.8)
|
6
client/skill/spin/spin.gd
Normal file
6
client/skill/spin/spin.gd
Normal file
@ -0,0 +1,6 @@
|
||||
extends SkillInstance
|
||||
|
||||
func _ready():
|
||||
play_animation("human/spin", 1.0, 2.0)
|
||||
await melee_damage(0.5)
|
||||
queue_free()
|
13
client/skill/spin/spin.tres
Normal file
13
client/skill/spin/spin.tres
Normal file
@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="Skill" load_steps=3 format=3 uid="uid://ba1filjaldakv"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bhrlgrleih7d0" path="res://skill/spin/spin.tscn" id="1_1lnya"]
|
||||
[ext_resource type="Script" path="res://skill/Skill.gd" id="1_n5ckk"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_n5ckk")
|
||||
id = "spin"
|
||||
name = "Spin"
|
||||
cooldown = 0.0
|
||||
scene = ExtResource("1_1lnya")
|
||||
cast_time = 0.7
|
||||
total_time = 1.0
|
10
client/skill/spin/spin.tscn
Normal file
10
client/skill/spin/spin.tscn
Normal file
@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://bhrlgrleih7d0"]
|
||||
|
||||
[ext_resource type="Script" path="res://skill/spin/spin.gd" id="1_p5jmv"]
|
||||
[ext_resource type="PackedScene" uid="uid://f1keiecsx5kw" path="res://skill/melee_area.tscn" id="2_fjxc1"]
|
||||
|
||||
[node name="Spin" type="Node3D"]
|
||||
script = ExtResource("1_p5jmv")
|
||||
|
||||
[node name="Area" parent="." instance=ExtResource("2_fjxc1")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1.8)
|
Reference in New Issue
Block a user