update
This commit is contained in:
30
scenes/player/camera.gd
Normal file
30
scenes/player/camera.gd
Normal file
@@ -0,0 +1,30 @@
|
||||
extends Node3D
|
||||
|
||||
const SENSITIVITY := 0.003
|
||||
const PITCH_MIN := -80.0
|
||||
const PITCH_MAX := 80.0
|
||||
|
||||
var pitch := -0.3
|
||||
var camera_yaw := 0.0
|
||||
var player_yaw := -2.356
|
||||
|
||||
func _ready() -> void:
|
||||
get_parent().rotation.y = player_yaw
|
||||
rotation = Vector3(pitch, camera_yaw, 0)
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
var lmb := Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT)
|
||||
var rmb := Input.is_mouse_button_pressed(MOUSE_BUTTON_RIGHT)
|
||||
|
||||
if lmb or rmb:
|
||||
pitch -= event.relative.y * SENSITIVITY
|
||||
pitch = clamp(pitch, deg_to_rad(PITCH_MIN), deg_to_rad(PITCH_MAX))
|
||||
|
||||
if rmb:
|
||||
player_yaw -= event.relative.x * SENSITIVITY
|
||||
get_parent().rotation.y = player_yaw
|
||||
else:
|
||||
camera_yaw -= event.relative.x * SENSITIVITY
|
||||
|
||||
rotation = Vector3(pitch, camera_yaw, 0)
|
||||
1
scenes/player/camera.gd.uid
Normal file
1
scenes/player/camera.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cohjyjge1kqxb
|
||||
9
scenes/player/combat.gd
Normal file
9
scenes/player/combat.gd
Normal file
@@ -0,0 +1,9 @@
|
||||
extends Node
|
||||
|
||||
@onready var player: CharacterBody3D = get_parent()
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
for i in range(5):
|
||||
if event.is_action_pressed("ability_%s" % (i + 1)):
|
||||
EventBus.ability_use_requested.emit(player, i)
|
||||
return
|
||||
1
scenes/player/combat.gd.uid
Normal file
1
scenes/player/combat.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d15til6fsxw5b
|
||||
36
scenes/player/movement.gd
Normal file
36
scenes/player/movement.gd
Normal file
@@ -0,0 +1,36 @@
|
||||
extends Node
|
||||
|
||||
var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity")
|
||||
|
||||
@onready var player: CharacterBody3D = get_parent()
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if not player.is_on_floor():
|
||||
player.velocity.y -= gravity * delta
|
||||
|
||||
var base: BaseStats = Stats.get_base(player)
|
||||
var speed: float = base.speed if base is PlayerStats else 5.0
|
||||
var jump_velocity: float = base.jump_velocity if base is PlayerStats else 4.5
|
||||
|
||||
if Input.is_action_just_pressed("ui_accept") and player.is_on_floor():
|
||||
player.velocity.y = jump_velocity
|
||||
|
||||
var input_dir := Input.get_vector("move_left", "move_right", "move_forward", "move_back")
|
||||
var camera_pivot := player.get_node("CameraPivot") as Node3D
|
||||
var forward := -camera_pivot.global_transform.basis.z
|
||||
forward.y = 0
|
||||
forward = forward.normalized()
|
||||
var right := camera_pivot.global_transform.basis.x
|
||||
right.y = 0
|
||||
right = right.normalized()
|
||||
|
||||
var direction := (forward * -input_dir.y + right * input_dir.x).normalized()
|
||||
|
||||
if direction:
|
||||
player.velocity.x = direction.x * speed
|
||||
player.velocity.z = direction.z * speed
|
||||
else:
|
||||
player.velocity.x = move_toward(player.velocity.x, 0, speed)
|
||||
player.velocity.z = move_toward(player.velocity.z, 0, speed)
|
||||
|
||||
player.move_and_slide()
|
||||
1
scenes/player/movement.gd.uid
Normal file
1
scenes/player/movement.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://fg87dh8fbc8
|
||||
28
scenes/player/player.gd
Normal file
28
scenes/player/player.gd
Normal file
@@ -0,0 +1,28 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
@export var stats: BaseStats
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group("player")
|
||||
Stats.register(self, stats)
|
||||
var cooldown_system: Node = get_tree().get_first_node_in_group("cooldown_system")
|
||||
if cooldown_system:
|
||||
cooldown_system.register(self, 5)
|
||||
if GameState.returning_from_dungeon:
|
||||
GameState.restore_player(self)
|
||||
global_position = GameState.portal_position + Vector3(0, 1, -5)
|
||||
GameState.returning_from_dungeon = false
|
||||
elif GameState.dungeon_cleared:
|
||||
GameState.clear()
|
||||
var health: float = Stats.get_stat(self, "health")
|
||||
var max_health: float = Stats.get_stat(self, "max_health")
|
||||
var shield: float = Stats.get_stat(self, "shield")
|
||||
var max_shield: float = Stats.get_stat(self, "max_shield")
|
||||
EventBus.health_changed.emit(self, health, max_health)
|
||||
EventBus.shield_changed.emit(self, shield, max_shield)
|
||||
|
||||
func _exit_tree() -> void:
|
||||
Stats.deregister(self)
|
||||
var cooldown_system: Node = get_tree().get_first_node_in_group("cooldown_system")
|
||||
if cooldown_system:
|
||||
cooldown_system.deregister(self)
|
||||
1
scenes/player/player.gd.uid
Normal file
1
scenes/player/player.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bfpt2p7uucfyb
|
||||
52
scenes/player/player.tscn
Normal file
52
scenes/player/player.tscn
Normal file
@@ -0,0 +1,52 @@
|
||||
[gd_scene format=3 uid="uid://cdnkbt1f0db7e"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bfpt2p7uucfyb" path="res://scenes/player/player.gd" id="1"]
|
||||
[ext_resource type="Script" uid="uid://cohjyjge1kqxb" path="res://scenes/player/camera.gd" id="2"]
|
||||
[ext_resource type="Script" uid="uid://fg87dh8fbc8" path="res://scenes/player/movement.gd" id="3"]
|
||||
[ext_resource type="Script" uid="uid://d15til6fsxw5b" path="res://scenes/player/combat.gd" id="4"]
|
||||
[ext_resource type="Script" uid="uid://b05nkuryipwny" path="res://scenes/player/targeting.gd" id="8"]
|
||||
[ext_resource type="Script" path="res://scenes/player/role/role.gd" id="10"]
|
||||
[ext_resource type="Resource" uid="uid://cgxtn7dfs40bh" path="res://scenes/player/role/tank/set.tres" id="11"]
|
||||
[ext_resource type="Resource" uid="uid://beodknb6i1pm4" path="res://scenes/player/role/damage/set.tres" id="12"]
|
||||
[ext_resource type="Resource" uid="uid://kcwuhnqy34mj" path="res://scenes/player/role/healer/set.tres" id="13"]
|
||||
[ext_resource type="Resource" path="res://scenes/player/player_stats.tres" id="14"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_1"]
|
||||
radius = 0.3
|
||||
height = 1.8
|
||||
|
||||
[sub_resource type="CapsuleMesh" id="CapsuleMesh_1"]
|
||||
radius = 0.3
|
||||
height = 1.8
|
||||
|
||||
[node name="Player" type="CharacterBody3D" unique_id=1350215040]
|
||||
script = ExtResource("1")
|
||||
stats = ExtResource("14")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=33887999]
|
||||
shape = SubResource("CapsuleShape3D_1")
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="." unique_id=1346931672]
|
||||
mesh = SubResource("CapsuleMesh_1")
|
||||
|
||||
[node name="CameraPivot" type="Node3D" parent="." unique_id=1292689540]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="CameraPivot" unique_id=1225820651]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.966, 0.259, 0, -0.259, 0.966, 0, 2, 5)
|
||||
|
||||
[node name="Movement" type="Node" parent="." unique_id=654979387]
|
||||
script = ExtResource("3")
|
||||
|
||||
[node name="Combat" type="Node" parent="." unique_id=1754235583]
|
||||
script = ExtResource("4")
|
||||
|
||||
[node name="Targeting" type="Node" parent="." unique_id=592540710]
|
||||
script = ExtResource("8")
|
||||
|
||||
[node name="Role" type="Node" parent="." unique_id=134158295]
|
||||
script = ExtResource("10")
|
||||
tank_set = ExtResource("11")
|
||||
damage_set = ExtResource("12")
|
||||
healer_set = ExtResource("13")
|
||||
10
scenes/player/player_stats.gd
Normal file
10
scenes/player/player_stats.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
extends BaseStats
|
||||
class_name PlayerStats
|
||||
|
||||
@export var speed := 5.0
|
||||
@export var jump_velocity := 4.5
|
||||
@export var target_range := 20.0
|
||||
@export var combat_timeout := 3.0
|
||||
@export var respawn_time := 3.0
|
||||
@export var gcd_time := 0.5
|
||||
@export var aa_cooldown := 0.5
|
||||
1
scenes/player/player_stats.gd.uid
Normal file
1
scenes/player/player_stats.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ypyntbavbsto
|
||||
8
scenes/player/player_stats.tres
Normal file
8
scenes/player/player_stats.tres
Normal file
@@ -0,0 +1,8 @@
|
||||
[gd_resource type="Resource" script_class="PlayerStats" format=3 uid="uid://btd0g0oiulssq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ypyntbavbsto" path="res://scenes/player/player_stats.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
health_regen = 1.0
|
||||
max_shield = 50.0
|
||||
15
scenes/player/role/ability.gd
Normal file
15
scenes/player/role/ability.gd
Normal file
@@ -0,0 +1,15 @@
|
||||
extends Resource
|
||||
class_name Ability
|
||||
|
||||
enum Type { SINGLE, AOE, UTILITY, ULT, PASSIVE }
|
||||
|
||||
@export var ability_name: String = ""
|
||||
@export var type: Type = Type.SINGLE
|
||||
@export var damage: float = 0.0
|
||||
@export var ability_range: float = 3.0
|
||||
@export var cooldown: float = 0.0
|
||||
@export var uses_gcd: bool = true
|
||||
@export var aoe_radius: float = 0.0
|
||||
@export var icon: String = ""
|
||||
@export var is_heal: bool = false
|
||||
@export var passive_stat: String = "damage"
|
||||
1
scenes/player/role/ability.gd.uid
Normal file
1
scenes/player/role/ability.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c03xbbf3yhfl3
|
||||
7
scenes/player/role/ability_set.gd
Normal file
7
scenes/player/role/ability_set.gd
Normal file
@@ -0,0 +1,7 @@
|
||||
extends Resource
|
||||
class_name AbilitySet
|
||||
|
||||
@export var abilities: Array[Ability] = []
|
||||
@export var aa_damage: float = 10.0
|
||||
@export var aa_range: float = 10.0
|
||||
@export var aa_is_heal: bool = false
|
||||
1
scenes/player/role/ability_set.gd.uid
Normal file
1
scenes/player/role/ability_set.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://voedgs25cwrb
|
||||
12
scenes/player/role/damage/abilities/aoe.tres
Normal file
12
scenes/player/role/damage/abilities/aoe.tres
Normal file
@@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="Ability" format=3 uid="uid://bpx3l13iuynfv"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
ability_name = "AOE"
|
||||
type = 1
|
||||
damage = 20.0
|
||||
ability_range = 5.0
|
||||
cooldown = 3.0
|
||||
icon = "2"
|
||||
12
scenes/player/role/damage/abilities/passive.tres
Normal file
12
scenes/player/role/damage/abilities/passive.tres
Normal file
@@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="Ability" format=3 uid="uid://dadpl32yujwhe"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
ability_name = "Damage Boost"
|
||||
type = 4
|
||||
damage = 50.0
|
||||
ability_range = 0.0
|
||||
uses_gcd = false
|
||||
icon = "P"
|
||||
11
scenes/player/role/damage/abilities/single.tres
Normal file
11
scenes/player/role/damage/abilities/single.tres
Normal file
@@ -0,0 +1,11 @@
|
||||
[gd_resource type="Resource" script_class="Ability" format=3 uid="uid://dwvc8b3cmce8l"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
ability_name = "Single"
|
||||
damage = 30.0
|
||||
ability_range = 20.0
|
||||
cooldown = 2.0
|
||||
icon = "1"
|
||||
13
scenes/player/role/damage/abilities/ult.tres
Normal file
13
scenes/player/role/damage/abilities/ult.tres
Normal file
@@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="Ability" format=3 uid="uid://s32wvlww2ls2"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
ability_name = "Burst"
|
||||
type = 3
|
||||
damage = 10.0
|
||||
ability_range = 20.0
|
||||
cooldown = 15.0
|
||||
aoe_radius = 3.0
|
||||
icon = "4"
|
||||
12
scenes/player/role/damage/abilities/utility.tres
Normal file
12
scenes/player/role/damage/abilities/utility.tres
Normal file
@@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="Ability" format=3]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
ability_name = "Shield Reset"
|
||||
type = 2
|
||||
ability_range = 0.0
|
||||
cooldown = 5.0
|
||||
uses_gcd = false
|
||||
icon = "3"
|
||||
14
scenes/player/role/damage/set.tres
Normal file
14
scenes/player/role/damage/set.tres
Normal file
@@ -0,0 +1,14 @@
|
||||
[gd_resource type="Resource" script_class="AbilitySet" format=3 uid="uid://beodknb6i1pm4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://voedgs25cwrb" path="res://scenes/player/role/ability_set.gd" id="1"]
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1_ability"]
|
||||
[ext_resource type="Resource" uid="uid://dwvc8b3cmce8l" path="res://scenes/player/role/damage/abilities/single.tres" id="2"]
|
||||
[ext_resource type="Resource" uid="uid://bpx3l13iuynfv" path="res://scenes/player/role/damage/abilities/aoe.tres" id="3"]
|
||||
[ext_resource type="Resource" path="res://scenes/player/role/damage/abilities/utility.tres" id="4"]
|
||||
[ext_resource type="Resource" uid="uid://s32wvlww2ls2" path="res://scenes/player/role/damage/abilities/ult.tres" id="5"]
|
||||
[ext_resource type="Resource" uid="uid://dadpl32yujwhe" path="res://scenes/player/role/damage/abilities/passive.tres" id="6"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
abilities = Array[ExtResource("1_ability")]([ExtResource("2"), ExtResource("3"), ExtResource("4"), ExtResource("5"), ExtResource("6")])
|
||||
aa_damage = 25.0
|
||||
13
scenes/player/role/healer/abilities/aoe.tres
Normal file
13
scenes/player/role/healer/abilities/aoe.tres
Normal file
@@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="Ability" format=3 uid="uid://m1kgk2uugnex"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
ability_name = "Circle of Healing"
|
||||
type = 1
|
||||
damage = 10.0
|
||||
ability_range = 20.0
|
||||
cooldown = 3.0
|
||||
icon = "2"
|
||||
is_heal = true
|
||||
13
scenes/player/role/healer/abilities/passive.tres
Normal file
13
scenes/player/role/healer/abilities/passive.tres
Normal file
@@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="Ability" format=3]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
ability_name = "Heal Aura"
|
||||
type = 4
|
||||
damage = 50.0
|
||||
ability_range = 0.0
|
||||
uses_gcd = false
|
||||
icon = "P"
|
||||
passive_stat = "heal"
|
||||
12
scenes/player/role/healer/abilities/single.tres
Normal file
12
scenes/player/role/healer/abilities/single.tres
Normal file
@@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="Ability" format=3 uid="uid://cqw1jy6kqvmnj"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
ability_name = "Heal"
|
||||
damage = 15.0
|
||||
ability_range = 20.0
|
||||
cooldown = 2.0
|
||||
icon = "1"
|
||||
is_heal = true
|
||||
14
scenes/player/role/healer/abilities/ult.tres
Normal file
14
scenes/player/role/healer/abilities/ult.tres
Normal file
@@ -0,0 +1,14 @@
|
||||
[gd_resource type="Resource" script_class="Ability" format=3 uid="uid://d04nu1leyki16"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
ability_name = "Divine Light"
|
||||
type = 3
|
||||
damage = 25.0
|
||||
ability_range = 20.0
|
||||
cooldown = 15.0
|
||||
aoe_radius = 3.0
|
||||
icon = "4"
|
||||
is_heal = true
|
||||
12
scenes/player/role/healer/abilities/utility.tres
Normal file
12
scenes/player/role/healer/abilities/utility.tres
Normal file
@@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="Ability" format=3]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
ability_name = "Shield Reset"
|
||||
type = 2
|
||||
ability_range = 0.0
|
||||
cooldown = 5.0
|
||||
uses_gcd = false
|
||||
icon = "3"
|
||||
16
scenes/player/role/healer/set.tres
Normal file
16
scenes/player/role/healer/set.tres
Normal file
@@ -0,0 +1,16 @@
|
||||
[gd_resource type="Resource" script_class="AbilitySet" format=3 uid="uid://kcwuhnqy34mj"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://voedgs25cwrb" path="res://scenes/player/role/ability_set.gd" id="1"]
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1_ability"]
|
||||
[ext_resource type="Resource" path="res://scenes/player/role/healer/abilities/single.tres" id="2"]
|
||||
[ext_resource type="Resource" path="res://scenes/player/role/healer/abilities/aoe.tres" id="3"]
|
||||
[ext_resource type="Resource" path="res://scenes/player/role/healer/abilities/utility.tres" id="4"]
|
||||
[ext_resource type="Resource" path="res://scenes/player/role/healer/abilities/ult.tres" id="5"]
|
||||
[ext_resource type="Resource" path="res://scenes/player/role/healer/abilities/passive.tres" id="6"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
abilities = Array[ExtResource("1_ability")]([ExtResource("2"), ExtResource("3"), ExtResource("4"), ExtResource("5"), ExtResource("6")])
|
||||
aa_damage = 1.0
|
||||
aa_range = 20.0
|
||||
aa_is_heal = true
|
||||
37
scenes/player/role/role.gd
Normal file
37
scenes/player/role/role.gd
Normal file
@@ -0,0 +1,37 @@
|
||||
extends Node
|
||||
|
||||
enum Role { TANK, DAMAGE, HEALER }
|
||||
|
||||
var current_role: int = Role.DAMAGE
|
||||
|
||||
@export var tank_set: AbilitySet
|
||||
@export var damage_set: AbilitySet
|
||||
@export var healer_set: AbilitySet
|
||||
|
||||
@onready var player: CharacterBody3D = get_parent()
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("class_tank"):
|
||||
set_role(Role.TANK)
|
||||
elif event.is_action_pressed("class_damage"):
|
||||
set_role(Role.DAMAGE)
|
||||
elif event.is_action_pressed("class_healer"):
|
||||
set_role(Role.HEALER)
|
||||
|
||||
func set_role(new_role: int) -> void:
|
||||
current_role = new_role
|
||||
EventBus.role_changed.emit(player, current_role)
|
||||
|
||||
func get_role_icon() -> String:
|
||||
match current_role:
|
||||
Role.TANK: return "T"
|
||||
Role.DAMAGE: return "D"
|
||||
Role.HEALER: return "H"
|
||||
return ""
|
||||
|
||||
func get_ability_set() -> AbilitySet:
|
||||
match current_role:
|
||||
Role.TANK: return tank_set
|
||||
Role.DAMAGE: return damage_set
|
||||
Role.HEALER: return healer_set
|
||||
return damage_set
|
||||
1
scenes/player/role/role.gd.uid
Normal file
1
scenes/player/role/role.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dhomrampxola4
|
||||
12
scenes/player/role/tank/abilities/aoe.tres
Normal file
12
scenes/player/role/tank/abilities/aoe.tres
Normal file
@@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="Ability" format=3]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
ability_name = "Tank AOE"
|
||||
type = 1
|
||||
damage = 10.0
|
||||
ability_range = 10.0
|
||||
cooldown = 3.0
|
||||
icon = "2"
|
||||
13
scenes/player/role/tank/abilities/passive.tres
Normal file
13
scenes/player/role/tank/abilities/passive.tres
Normal file
@@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="Ability" format=3]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
ability_name = "Shield Aura"
|
||||
type = 4
|
||||
damage = 50.0
|
||||
ability_range = 0.0
|
||||
uses_gcd = false
|
||||
icon = "P"
|
||||
passive_stat = "shield"
|
||||
11
scenes/player/role/tank/abilities/single.tres
Normal file
11
scenes/player/role/tank/abilities/single.tres
Normal file
@@ -0,0 +1,11 @@
|
||||
[gd_resource type="Resource" script_class="Ability" format=3]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
ability_name = "Tank Strike"
|
||||
damage = 15.0
|
||||
ability_range = 3.0
|
||||
cooldown = 2.0
|
||||
icon = "1"
|
||||
11
scenes/player/role/tank/abilities/ult.tres
Normal file
11
scenes/player/role/tank/abilities/ult.tres
Normal file
@@ -0,0 +1,11 @@
|
||||
[gd_resource type="Resource" script_class="Ability" format=3]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
ability_name = "Fortress"
|
||||
type = 2
|
||||
damage = 300.0
|
||||
cooldown = 20.0
|
||||
icon = "4"
|
||||
12
scenes/player/role/tank/abilities/utility.tres
Normal file
12
scenes/player/role/tank/abilities/utility.tres
Normal file
@@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="Ability" format=3]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
ability_name = "Shield Reset"
|
||||
type = 2
|
||||
ability_range = 0.0
|
||||
cooldown = 5.0
|
||||
uses_gcd = false
|
||||
icon = "3"
|
||||
15
scenes/player/role/tank/set.tres
Normal file
15
scenes/player/role/tank/set.tres
Normal file
@@ -0,0 +1,15 @@
|
||||
[gd_resource type="Resource" script_class="AbilitySet" format=3 uid="uid://cgxtn7dfs40bh"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://voedgs25cwrb" path="res://scenes/player/role/ability_set.gd" id="1"]
|
||||
[ext_resource type="Script" uid="uid://c03xbbf3yhfl3" path="res://scenes/player/role/ability.gd" id="1_ability"]
|
||||
[ext_resource type="Resource" path="res://scenes/player/role/tank/abilities/single.tres" id="2"]
|
||||
[ext_resource type="Resource" path="res://scenes/player/role/tank/abilities/aoe.tres" id="3"]
|
||||
[ext_resource type="Resource" path="res://scenes/player/role/tank/abilities/utility.tres" id="4"]
|
||||
[ext_resource type="Resource" path="res://scenes/player/role/tank/abilities/ult.tres" id="5"]
|
||||
[ext_resource type="Resource" path="res://scenes/player/role/tank/abilities/passive.tres" id="6"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
abilities = Array[ExtResource("1_ability")]([ExtResource("2"), ExtResource("3"), ExtResource("4"), ExtResource("5"), ExtResource("6")])
|
||||
aa_damage = 5.0
|
||||
aa_range = 3.0
|
||||
114
scenes/player/targeting.gd
Normal file
114
scenes/player/targeting.gd
Normal file
@@ -0,0 +1,114 @@
|
||||
extends Node
|
||||
|
||||
const TARGET_RANGE := 20.0
|
||||
const COMBAT_TIMEOUT := 3.0
|
||||
|
||||
var current_target: Node3D = null
|
||||
var mouse_press_pos: Vector2 = Vector2.ZERO
|
||||
var in_combat := false
|
||||
var combat_timer := 0.0
|
||||
|
||||
@onready var player: CharacterBody3D = get_parent()
|
||||
@onready var camera: Camera3D = get_parent().get_node("CameraPivot/Camera3D")
|
||||
|
||||
func _ready() -> void:
|
||||
EventBus.damage_dealt.connect(_on_damage_dealt)
|
||||
EventBus.entity_died.connect(_on_entity_died)
|
||||
EventBus.enemy_engaged.connect(_on_enemy_engaged)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if in_combat:
|
||||
combat_timer -= delta
|
||||
if combat_timer <= 0:
|
||||
in_combat = false
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
if event.pressed:
|
||||
mouse_press_pos = event.position
|
||||
else:
|
||||
var drag: float = event.position.distance_to(mouse_press_pos)
|
||||
if drag < 5.0:
|
||||
_try_target_under_mouse(event.position)
|
||||
if event.is_action_pressed("target_next"):
|
||||
_cycle_target()
|
||||
|
||||
func _try_target_under_mouse(mouse_pos: Vector2) -> void:
|
||||
var from := camera.project_ray_origin(mouse_pos)
|
||||
var to := from + camera.project_ray_normal(mouse_pos) * TARGET_RANGE
|
||||
var space := player.get_world_3d().direct_space_state
|
||||
var query := PhysicsRayQueryParameters3D.create(from, to)
|
||||
query.collision_mask = 4
|
||||
query.collide_with_areas = true
|
||||
query.collide_with_bodies = false
|
||||
var result := space.intersect_ray(query)
|
||||
if result:
|
||||
var hit_target := result.collider.get_parent() as Node3D
|
||||
set_target(hit_target)
|
||||
else:
|
||||
set_target(null)
|
||||
|
||||
func _cycle_target() -> void:
|
||||
var targets := get_tree().get_nodes_in_group("enemies") + get_tree().get_nodes_in_group("portals")
|
||||
if targets.is_empty():
|
||||
set_target(null)
|
||||
return
|
||||
if current_target == null or current_target not in targets:
|
||||
set_target(targets[0])
|
||||
return
|
||||
var idx := targets.find(current_target)
|
||||
var next_idx := (idx + 1) % targets.size()
|
||||
set_target(targets[next_idx])
|
||||
|
||||
func set_target(target: Node3D) -> void:
|
||||
current_target = target
|
||||
EventBus.target_changed.emit(player, target)
|
||||
|
||||
func _on_enemy_engaged(_enemy: Node, target: Node) -> void:
|
||||
if target == player:
|
||||
combat_timer = COMBAT_TIMEOUT
|
||||
if not in_combat:
|
||||
in_combat = true
|
||||
if current_target == null:
|
||||
_auto_target()
|
||||
|
||||
func _on_damage_dealt(attacker: Node, target: Node, _amount: float) -> void:
|
||||
if target == player:
|
||||
combat_timer = COMBAT_TIMEOUT
|
||||
if not in_combat:
|
||||
in_combat = true
|
||||
if current_target == null:
|
||||
_auto_target()
|
||||
elif attacker == player and in_combat:
|
||||
combat_timer = COMBAT_TIMEOUT
|
||||
|
||||
func _on_entity_died(entity: Node) -> void:
|
||||
if entity == current_target:
|
||||
set_target(null)
|
||||
if in_combat:
|
||||
_auto_target(entity)
|
||||
|
||||
func _auto_target(exclude: Node = null) -> void:
|
||||
# Priorität 1: Nächster Gegner
|
||||
var enemies := get_tree().get_nodes_in_group("enemies")
|
||||
var nearest: Node3D = null
|
||||
var nearest_dist: float = INF
|
||||
for enemy in enemies:
|
||||
if is_instance_valid(enemy) and enemy != exclude:
|
||||
var dist: float = player.global_position.distance_to(enemy.global_position)
|
||||
if dist < nearest_dist:
|
||||
nearest_dist = dist
|
||||
nearest = enemy
|
||||
if nearest:
|
||||
set_target(nearest)
|
||||
return
|
||||
# Priorität 2: Nächstes Portal
|
||||
var portals := get_tree().get_nodes_in_group("portals")
|
||||
for p in portals:
|
||||
if is_instance_valid(p) and p != exclude:
|
||||
var dist: float = player.global_position.distance_to(p.global_position)
|
||||
if dist < nearest_dist:
|
||||
nearest_dist = dist
|
||||
nearest = p
|
||||
if nearest:
|
||||
set_target(nearest)
|
||||
1
scenes/player/targeting.gd.uid
Normal file
1
scenes/player/targeting.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b05nkuryipwny
|
||||
Reference in New Issue
Block a user