update
This commit is contained in:
211
scenes/dungeon/dungeon.tscn
Normal file
211
scenes/dungeon/dungeon.tscn
Normal file
@@ -0,0 +1,211 @@
|
||||
[gd_scene format=3]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://scenes/player/player.tscn" id="player"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/hud/hud.tscn" id="hud"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/enemy/enemy.tscn" id="enemy"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/enemy/boss.tscn" id="boss"]
|
||||
[ext_resource type="Script" path="res://scenes/dungeon/dungeon_manager.gd" id="dungeon_manager"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/portal/gate.tscn" id="gate"]
|
||||
[ext_resource type="Script" path="res://systems/health_system.gd" id="health_system"]
|
||||
[ext_resource type="Script" path="res://systems/shield_system.gd" id="shield_system"]
|
||||
[ext_resource type="Script" path="res://systems/damage_system.gd" id="damage_system"]
|
||||
[ext_resource type="Script" path="res://systems/ability_system.gd" id="ability_system"]
|
||||
[ext_resource type="Script" path="res://systems/cooldown_system.gd" id="cooldown_system"]
|
||||
[ext_resource type="Script" path="res://systems/aggro/aggro_system.gd" id="aggro_system"]
|
||||
[ext_resource type="Script" path="res://systems/aggro/aggro_tracker.gd" id="aggro_tracker"]
|
||||
[ext_resource type="Script" path="res://systems/aggro/aggro_decay.gd" id="aggro_decay"]
|
||||
[ext_resource type="Script" path="res://systems/aggro/aggro_events.gd" id="aggro_events"]
|
||||
[ext_resource type="Script" path="res://systems/enemy_ai_system.gd" id="enemy_ai_system"]
|
||||
[ext_resource type="Script" path="res://systems/respawn_system.gd" id="respawn_system"]
|
||||
[ext_resource type="Script" path="res://systems/spawn_system.gd" id="spawn_system"]
|
||||
[ext_resource type="Script" path="res://systems/buff_system.gd" id="buff_system"]
|
||||
|
||||
[sub_resource type="NavigationMesh" id="NavigationMesh_1"]
|
||||
vertices = PackedVector3Array(-7.0, 0.5, -7.0, -7.0, 0.5, 87.0, 7.0, 0.5, 87.0, 7.0, 0.5, -7.0)
|
||||
polygons = [PackedInt32Array(3, 2, 0), PackedInt32Array(0, 2, 1)]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_floor"]
|
||||
albedo_color = Color(0.2, 0.18, 0.15, 1)
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_1"]
|
||||
material = SubResource("StandardMaterial3D_floor")
|
||||
size = Vector2(15, 90)
|
||||
|
||||
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_1"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_wall"]
|
||||
albedo_color = Color(0.25, 0.22, 0.2, 1)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_north_south"]
|
||||
material = SubResource("StandardMaterial3D_wall")
|
||||
size = Vector3(15, 3, 0.5)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_north_south"]
|
||||
size = Vector3(15, 3, 0.5)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_east_west"]
|
||||
material = SubResource("StandardMaterial3D_wall")
|
||||
size = Vector3(0.5, 3, 90)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_east_west"]
|
||||
size = Vector3(0.5, 3, 90)
|
||||
|
||||
[node name="Dungeon" type="Node3D"]
|
||||
|
||||
[node name="Systems" type="Node" parent="."]
|
||||
|
||||
[node name="HealthSystem" type="Node" parent="Systems"]
|
||||
script = ExtResource("health_system")
|
||||
|
||||
[node name="ShieldSystem" type="Node" parent="Systems"]
|
||||
script = ExtResource("shield_system")
|
||||
|
||||
[node name="DamageSystem" type="Node" parent="Systems"]
|
||||
script = ExtResource("damage_system")
|
||||
|
||||
[node name="AbilitySystem" type="Node" parent="Systems"]
|
||||
script = ExtResource("ability_system")
|
||||
|
||||
[node name="CooldownSystem" type="Node" parent="Systems"]
|
||||
script = ExtResource("cooldown_system")
|
||||
|
||||
[node name="AggroSystem" type="Node" parent="Systems"]
|
||||
script = ExtResource("aggro_system")
|
||||
|
||||
[node name="AggroTracker" type="Node" parent="Systems/AggroSystem"]
|
||||
script = ExtResource("aggro_tracker")
|
||||
|
||||
[node name="AggroDecay" type="Node" parent="Systems/AggroSystem"]
|
||||
script = ExtResource("aggro_decay")
|
||||
|
||||
[node name="AggroEvents" type="Node" parent="Systems/AggroSystem"]
|
||||
script = ExtResource("aggro_events")
|
||||
|
||||
[node name="EnemyAISystem" type="Node" parent="Systems"]
|
||||
script = ExtResource("enemy_ai_system")
|
||||
|
||||
[node name="RespawnSystem" type="Node" parent="Systems"]
|
||||
script = ExtResource("respawn_system")
|
||||
|
||||
[node name="SpawnSystem" type="Node" parent="Systems"]
|
||||
script = ExtResource("spawn_system")
|
||||
|
||||
[node name="BuffSystem" type="Node" parent="Systems"]
|
||||
script = ExtResource("buff_system")
|
||||
|
||||
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="."]
|
||||
navigation_mesh = SubResource("NavigationMesh_1")
|
||||
|
||||
[node name="Boden" type="MeshInstance3D" parent="NavigationRegion3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 40)
|
||||
mesh = SubResource("PlaneMesh_1")
|
||||
|
||||
[node name="BodenCollision" type="StaticBody3D" parent="."]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="BodenCollision"]
|
||||
shape = SubResource("WorldBoundaryShape3D_1")
|
||||
|
||||
[node name="WallSouth" type="StaticBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, -5.25)
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="WallSouth"]
|
||||
mesh = SubResource("BoxMesh_north_south")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="WallSouth"]
|
||||
shape = SubResource("BoxShape3D_north_south")
|
||||
|
||||
[node name="WallNorth" type="StaticBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 85.25)
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="WallNorth"]
|
||||
mesh = SubResource("BoxMesh_north_south")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="WallNorth"]
|
||||
shape = SubResource("BoxShape3D_north_south")
|
||||
|
||||
[node name="WallEast" type="StaticBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7.75, 1.5, 40)
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="WallEast"]
|
||||
mesh = SubResource("BoxMesh_east_west")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="WallEast"]
|
||||
shape = SubResource("BoxShape3D_east_west")
|
||||
|
||||
[node name="WallWest" type="StaticBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.75, 1.5, 40)
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="WallWest"]
|
||||
mesh = SubResource("BoxMesh_east_west")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="WallWest"]
|
||||
shape = SubResource("BoxShape3D_east_west")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.707, 0.707, 0, -0.707, 0.707, 0, 10, 40)
|
||||
light_energy = 0.6
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("player")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -3)
|
||||
|
||||
[node name="HUD" parent="." instance=ExtResource("hud")]
|
||||
|
||||
[node name="Enemy1a" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 15)
|
||||
|
||||
[node name="Enemy1b" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 0, 15)
|
||||
|
||||
[node name="Enemy1c" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 15)
|
||||
|
||||
[node name="Enemy1d" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 15)
|
||||
|
||||
[node name="Enemy2a" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 30)
|
||||
|
||||
[node name="Enemy2b" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 0, 30)
|
||||
|
||||
[node name="Enemy2c" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 30)
|
||||
|
||||
[node name="Enemy2d" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 30)
|
||||
|
||||
[node name="Enemy3a" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 45)
|
||||
|
||||
[node name="Enemy3b" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 0, 45)
|
||||
|
||||
[node name="Enemy3c" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 45)
|
||||
|
||||
[node name="Enemy3d" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 45)
|
||||
|
||||
[node name="Enemy4a" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 60)
|
||||
|
||||
[node name="Enemy4b" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 0, 60)
|
||||
|
||||
[node name="Enemy4c" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 60)
|
||||
|
||||
[node name="Enemy4d" parent="." instance=ExtResource("enemy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 60)
|
||||
|
||||
[node name="Boss" parent="." instance=ExtResource("boss")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 75)
|
||||
|
||||
[node name="ExitGate" parent="." instance=ExtResource("gate")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, -4)
|
||||
target_scene = "res://scenes/world/world.tscn"
|
||||
is_exit = true
|
||||
|
||||
[node name="DungeonManager" type="Node" parent="."]
|
||||
script = ExtResource("dungeon_manager")
|
||||
16
scenes/dungeon/dungeon_manager.gd
Normal file
16
scenes/dungeon/dungeon_manager.gd
Normal file
@@ -0,0 +1,16 @@
|
||||
extends Node
|
||||
|
||||
func _ready() -> void:
|
||||
var player: Node = get_tree().get_first_node_in_group("player")
|
||||
if player:
|
||||
GameState.restore_player(player)
|
||||
EventBus.entity_died.connect(_on_entity_died)
|
||||
|
||||
func _on_entity_died(entity: Node) -> void:
|
||||
if entity.is_in_group("boss"):
|
||||
await get_tree().create_timer(2.0).timeout
|
||||
GameState.dungeon_cleared = true
|
||||
GameState.returning_from_dungeon = false
|
||||
GameState.clear()
|
||||
EventBus.dungeon_cleared.emit()
|
||||
get_tree().change_scene_to_file("res://scenes/world/world.tscn")
|
||||
1
scenes/dungeon/dungeon_manager.gd.uid
Normal file
1
scenes/dungeon/dungeon_manager.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://drn4h1lxx5t1j
|
||||
5
scenes/enemy/boss.gd
Normal file
5
scenes/enemy/boss.gd
Normal file
@@ -0,0 +1,5 @@
|
||||
extends "res://scenes/enemy/enemy.gd"
|
||||
|
||||
func _ready() -> void:
|
||||
super._ready()
|
||||
add_to_group("boss")
|
||||
1
scenes/enemy/boss.gd.uid
Normal file
1
scenes/enemy/boss.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bkehq3dqyp2yd
|
||||
108
scenes/enemy/boss.tscn
Normal file
108
scenes/enemy/boss.tscn
Normal file
@@ -0,0 +1,108 @@
|
||||
[gd_scene load_steps=6 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/enemy/boss.gd" id="1"]
|
||||
[ext_resource type="Script" path="res://scenes/healthbar.gd" id="4"]
|
||||
[ext_resource type="Script" path="res://scenes/enemy/enemy_movement.gd" id="5"]
|
||||
[ext_resource type="Resource" path="res://scenes/enemy/boss_stats.tres" id="8"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_1"]
|
||||
radius = 0.6
|
||||
height = 2.0
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2"]
|
||||
radius = 0.6
|
||||
height = 2.0
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_health_bg"]
|
||||
bg_color = Color(0.3, 0.1, 0.1, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_health_fill"]
|
||||
bg_color = Color(0.2, 0.8, 0.2, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_shield_bg"]
|
||||
bg_color = Color(0.1, 0.1, 0.3, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_shield_fill"]
|
||||
bg_color = Color(0.2, 0.5, 0.9, 1)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1"]
|
||||
albedo_color = Color(0.6, 0.1, 0.6, 1)
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_1"]
|
||||
radius = 0.75
|
||||
height = 1.5
|
||||
material = SubResource("StandardMaterial3D_1")
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_1"]
|
||||
radius = 8.0
|
||||
|
||||
[node name="Boss" type="CharacterBody3D"]
|
||||
script = ExtResource("1")
|
||||
stats = ExtResource("8")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("CapsuleShape3D_1")
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, 0, 0)
|
||||
mesh = SubResource("SphereMesh_1")
|
||||
|
||||
[node name="HitArea" type="Area3D" parent="."]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="HitArea"]
|
||||
shape = SubResource("CapsuleShape3D_2")
|
||||
|
||||
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="."]
|
||||
|
||||
[node name="EnemyMovement" type="Node" parent="."]
|
||||
script = ExtResource("5")
|
||||
|
||||
[node name="DetectionArea" type="Area3D" parent="."]
|
||||
collision_layer = 0
|
||||
collision_mask = 1
|
||||
monitoring = true
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="DetectionArea"]
|
||||
shape = SubResource("SphereShape3D_1")
|
||||
|
||||
[node name="Healthbar" type="Sprite3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.0, 0)
|
||||
billboard = 1
|
||||
pixel_size = 0.01
|
||||
script = ExtResource("4")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="Healthbar"]
|
||||
transparent_bg = true
|
||||
size = Vector2i(104, 29)
|
||||
|
||||
[node name="Border" type="ColorRect" parent="Healthbar/SubViewport"]
|
||||
offset_right = 104.0
|
||||
offset_bottom = 29.0
|
||||
color = Color(1, 0.9, 0.2, 1)
|
||||
|
||||
[node name="HealthBar" type="ProgressBar" parent="Healthbar/SubViewport"]
|
||||
offset_left = 2.0
|
||||
offset_top = 2.0
|
||||
offset_right = 102.0
|
||||
offset_bottom = 12.0
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_health_bg")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_health_fill")
|
||||
max_value = 500.0
|
||||
value = 500.0
|
||||
show_percentage = false
|
||||
|
||||
[node name="ShieldBar" type="ProgressBar" parent="Healthbar/SubViewport"]
|
||||
offset_left = 2.0
|
||||
offset_top = 15.0
|
||||
offset_right = 102.0
|
||||
offset_bottom = 27.0
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_shield_bg")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_shield_fill")
|
||||
max_value = 100.0
|
||||
value = 100.0
|
||||
show_percentage = false
|
||||
|
||||
[connection signal="body_entered" from="DetectionArea" to="." method="_on_detection_area_body_entered"]
|
||||
[connection signal="body_exited" from="DetectionArea" to="." method="_on_detection_area_body_exited"]
|
||||
2
scenes/enemy/boss_stats.gd
Normal file
2
scenes/enemy/boss_stats.gd
Normal file
@@ -0,0 +1,2 @@
|
||||
extends EnemyStats
|
||||
class_name BossStats
|
||||
1
scenes/enemy/boss_stats.gd.uid
Normal file
1
scenes/enemy/boss_stats.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bio01w2gd5e7q
|
||||
20
scenes/enemy/boss_stats.tres
Normal file
20
scenes/enemy/boss_stats.tres
Normal file
@@ -0,0 +1,20 @@
|
||||
[gd_resource type="Resource" script_class="BossStats" load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/enemy/boss_stats.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
max_health = 500.0
|
||||
health_regen = 0.0
|
||||
max_shield = 100.0
|
||||
shield_regen_delay = 5.0
|
||||
shield_regen_time = 8.0
|
||||
speed = 3.0
|
||||
attack_range = 2.0
|
||||
attack_cooldown = 1.5
|
||||
attack_damage = 5.0
|
||||
regen_fast = 0.1
|
||||
regen_slow = 0.01
|
||||
aggro_decay = 1.0
|
||||
portal_radius = 10.0
|
||||
alert_radius = 10.0
|
||||
37
scenes/enemy/enemy.gd
Normal file
37
scenes/enemy/enemy.gd
Normal file
@@ -0,0 +1,37 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
enum State { IDLE, CHASE, ATTACK, RETURN }
|
||||
|
||||
@export var stats: BaseStats
|
||||
|
||||
var state: int = State.IDLE
|
||||
var target: Node3D = null
|
||||
var spawn_position: Vector3
|
||||
var portal: Node3D = null
|
||||
var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity")
|
||||
|
||||
func _ready() -> void:
|
||||
spawn_position = global_position
|
||||
add_to_group("enemies")
|
||||
Stats.register(self, stats)
|
||||
EventBus.entity_died.connect(_on_entity_died)
|
||||
|
||||
func _exit_tree() -> void:
|
||||
Stats.deregister(self)
|
||||
|
||||
func _on_entity_died(entity: Node) -> void:
|
||||
if entity == self:
|
||||
queue_free()
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if not is_on_floor():
|
||||
velocity.y -= gravity * delta
|
||||
move_and_slide()
|
||||
|
||||
func _on_detection_area_body_entered(body: Node3D) -> void:
|
||||
if body is CharacterBody3D and body.name == "Player":
|
||||
EventBus.enemy_detected.emit(self, body)
|
||||
|
||||
func _on_detection_area_body_exited(body: Node3D) -> void:
|
||||
if body is CharacterBody3D and body.name == "Player":
|
||||
EventBus.enemy_lost.emit(self, body)
|
||||
1
scenes/enemy/enemy.gd.uid
Normal file
1
scenes/enemy/enemy.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bwi75jx0agktd
|
||||
107
scenes/enemy/enemy.tscn
Normal file
107
scenes/enemy/enemy.tscn
Normal file
@@ -0,0 +1,107 @@
|
||||
[gd_scene load_steps=6 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/enemy/enemy.gd" id="1"]
|
||||
[ext_resource type="Script" path="res://scenes/healthbar.gd" id="4"]
|
||||
[ext_resource type="Script" path="res://scenes/enemy/enemy_movement.gd" id="5"]
|
||||
[ext_resource type="Resource" path="res://scenes/enemy/enemy_stats.tres" id="8"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_1"]
|
||||
radius = 0.4
|
||||
height = 1.5
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2"]
|
||||
radius = 0.4
|
||||
height = 1.5
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_health_bg"]
|
||||
bg_color = Color(0.3, 0.1, 0.1, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_health_fill"]
|
||||
bg_color = Color(0.2, 0.8, 0.2, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_shield_bg"]
|
||||
bg_color = Color(0.1, 0.1, 0.3, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_shield_fill"]
|
||||
bg_color = Color(0.2, 0.5, 0.9, 1)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1"]
|
||||
albedo_color = Color(0.8, 0.1, 0.1, 1)
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_1"]
|
||||
radius = 0.5
|
||||
height = 1.0
|
||||
material = SubResource("StandardMaterial3D_1")
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_1"]
|
||||
radius = 10.0
|
||||
|
||||
[node name="Enemy" type="CharacterBody3D"]
|
||||
script = ExtResource("1")
|
||||
stats = ExtResource("8")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("CapsuleShape3D_1")
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource("SphereMesh_1")
|
||||
|
||||
[node name="HitArea" type="Area3D" parent="."]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="HitArea"]
|
||||
shape = SubResource("CapsuleShape3D_2")
|
||||
|
||||
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="."]
|
||||
|
||||
[node name="EnemyMovement" type="Node" parent="."]
|
||||
script = ExtResource("5")
|
||||
|
||||
[node name="DetectionArea" type="Area3D" parent="."]
|
||||
collision_layer = 0
|
||||
collision_mask = 1
|
||||
monitoring = true
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="DetectionArea"]
|
||||
shape = SubResource("SphereShape3D_1")
|
||||
|
||||
[node name="Healthbar" type="Sprite3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
|
||||
billboard = 1
|
||||
pixel_size = 0.01
|
||||
script = ExtResource("4")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="Healthbar"]
|
||||
transparent_bg = true
|
||||
size = Vector2i(104, 29)
|
||||
|
||||
[node name="Border" type="ColorRect" parent="Healthbar/SubViewport"]
|
||||
offset_right = 104.0
|
||||
offset_bottom = 29.0
|
||||
color = Color(1, 0.9, 0.2, 1)
|
||||
|
||||
[node name="HealthBar" type="ProgressBar" parent="Healthbar/SubViewport"]
|
||||
offset_left = 2.0
|
||||
offset_top = 2.0
|
||||
offset_right = 102.0
|
||||
offset_bottom = 12.0
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_health_bg")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_health_fill")
|
||||
max_value = 100.0
|
||||
value = 100.0
|
||||
show_percentage = false
|
||||
|
||||
[node name="ShieldBar" type="ProgressBar" parent="Healthbar/SubViewport"]
|
||||
offset_left = 2.0
|
||||
offset_top = 15.0
|
||||
offset_right = 102.0
|
||||
offset_bottom = 27.0
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_shield_bg")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_shield_fill")
|
||||
max_value = 50.0
|
||||
value = 50.0
|
||||
show_percentage = false
|
||||
|
||||
[connection signal="body_entered" from="DetectionArea" to="." method="_on_detection_area_body_entered"]
|
||||
[connection signal="body_exited" from="DetectionArea" to="." method="_on_detection_area_body_exited"]
|
||||
62
scenes/enemy/enemy_movement.gd
Normal file
62
scenes/enemy/enemy_movement.gd
Normal file
@@ -0,0 +1,62 @@
|
||||
extends Node
|
||||
|
||||
const SPEED := 3.0
|
||||
const ATTACK_RANGE := 2.0
|
||||
const REGEN_FAST := 0.10
|
||||
const REGEN_SLOW := 0.01
|
||||
|
||||
@onready var enemy: CharacterBody3D = get_parent()
|
||||
@onready var nav_agent: NavigationAgent3D = get_parent().get_node("NavigationAgent3D")
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
match enemy.state:
|
||||
enemy.State.IDLE:
|
||||
enemy.velocity.x = 0
|
||||
enemy.velocity.z = 0
|
||||
enemy.State.CHASE:
|
||||
_chase()
|
||||
enemy.State.RETURN:
|
||||
_return_to_spawn(delta)
|
||||
|
||||
func _chase() -> void:
|
||||
if not is_instance_valid(enemy.target):
|
||||
enemy.state = enemy.State.RETURN
|
||||
return
|
||||
var dist_to_target := enemy.global_position.distance_to(enemy.target.global_position)
|
||||
if dist_to_target <= ATTACK_RANGE:
|
||||
enemy.state = enemy.State.ATTACK
|
||||
return
|
||||
nav_agent.target_position = enemy.target.global_position
|
||||
var next_pos := nav_agent.get_next_path_position()
|
||||
var direction := (next_pos - enemy.global_position).normalized()
|
||||
direction.y = 0
|
||||
enemy.velocity.x = direction.x * SPEED
|
||||
enemy.velocity.z = direction.z * SPEED
|
||||
|
||||
func _return_to_spawn(delta: float) -> void:
|
||||
var dist := enemy.global_position.distance_to(enemy.spawn_position)
|
||||
if dist < 1.0:
|
||||
enemy.state = enemy.State.IDLE
|
||||
enemy.velocity.x = 0
|
||||
enemy.velocity.z = 0
|
||||
return
|
||||
nav_agent.target_position = enemy.spawn_position
|
||||
var next_pos := nav_agent.get_next_path_position()
|
||||
var direction := (next_pos - enemy.global_position).normalized()
|
||||
direction.y = 0
|
||||
enemy.velocity.x = direction.x * SPEED
|
||||
enemy.velocity.z = direction.z * SPEED
|
||||
_regenerate(delta)
|
||||
|
||||
func _regenerate(delta: float) -> void:
|
||||
var health: float = Stats.get_stat(enemy, "health")
|
||||
var max_health: float = Stats.get_stat(enemy, "max_health")
|
||||
if health == null or max_health == null:
|
||||
return
|
||||
if health < max_health:
|
||||
var rate: float = REGEN_FAST
|
||||
if health >= max_health * 0.99:
|
||||
rate = REGEN_SLOW
|
||||
health = min(health + max_health * rate * delta, max_health)
|
||||
Stats.set_stat(enemy, "health", health)
|
||||
EventBus.health_changed.emit(enemy, health, max_health)
|
||||
1
scenes/enemy/enemy_movement.gd.uid
Normal file
1
scenes/enemy/enemy_movement.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://tnx6rbnnngn
|
||||
12
scenes/enemy/enemy_stats.gd
Normal file
12
scenes/enemy/enemy_stats.gd
Normal file
@@ -0,0 +1,12 @@
|
||||
extends BaseStats
|
||||
class_name EnemyStats
|
||||
|
||||
@export var speed := 3.0
|
||||
@export var attack_range := 2.0
|
||||
@export var attack_cooldown := 1.5
|
||||
@export var attack_damage := 5.0
|
||||
@export var regen_fast := 0.10
|
||||
@export var regen_slow := 0.01
|
||||
@export var aggro_decay := 1.0
|
||||
@export var portal_radius := 10.0
|
||||
@export var alert_radius := 10.0
|
||||
1
scenes/enemy/enemy_stats.gd.uid
Normal file
1
scenes/enemy/enemy_stats.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bh2uuuvl30y0x
|
||||
7
scenes/enemy/enemy_stats.tres
Normal file
7
scenes/enemy/enemy_stats.tres
Normal file
@@ -0,0 +1,7 @@
|
||||
[gd_resource type="Resource" script_class="EnemyStats" format=3 uid="uid://cj1shmjwf0xeo"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bh2uuuvl30y0x" path="res://scenes/enemy/enemy_stats.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
max_shield = 50.0
|
||||
57
scenes/healthbar.gd
Normal file
57
scenes/healthbar.gd
Normal file
@@ -0,0 +1,57 @@
|
||||
extends Sprite3D
|
||||
|
||||
@onready var viewport: SubViewport = $SubViewport
|
||||
@onready var health_bar: ProgressBar = $SubViewport/HealthBar
|
||||
@onready var border: ColorRect = $SubViewport/Border
|
||||
@onready var parent_node: Node = get_parent()
|
||||
|
||||
var shield_bar: ProgressBar = null
|
||||
var style_normal: StyleBoxFlat
|
||||
var style_aggro: StyleBoxFlat
|
||||
|
||||
func _ready() -> void:
|
||||
texture = viewport.get_texture()
|
||||
shield_bar = $SubViewport.get_node_or_null("ShieldBar")
|
||||
border.visible = false
|
||||
style_normal = health_bar.get_theme_stylebox("fill").duplicate()
|
||||
style_aggro = style_normal.duplicate()
|
||||
style_aggro.bg_color = Color(0.2, 0.4, 0.9, 1)
|
||||
EventBus.target_changed.connect(_on_target_changed)
|
||||
EventBus.health_changed.connect(_on_health_changed)
|
||||
EventBus.shield_changed.connect(_on_shield_changed)
|
||||
_init_bars()
|
||||
|
||||
func _init_bars() -> void:
|
||||
var max_health: Variant = Stats.get_stat(parent_node, "max_health")
|
||||
if max_health != null:
|
||||
health_bar.max_value = max_health
|
||||
health_bar.value = Stats.get_stat(parent_node, "health")
|
||||
var max_shield: Variant = Stats.get_stat(parent_node, "max_shield")
|
||||
if shield_bar:
|
||||
if max_shield != null and max_shield > 0:
|
||||
shield_bar.max_value = max_shield
|
||||
shield_bar.value = Stats.get_stat(parent_node, "shield")
|
||||
else:
|
||||
shield_bar.visible = false
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
var player: Node = get_tree().get_first_node_in_group("player")
|
||||
if player and "target" in parent_node and parent_node.target == player:
|
||||
health_bar.add_theme_stylebox_override("fill", style_aggro)
|
||||
else:
|
||||
health_bar.add_theme_stylebox_override("fill", style_normal)
|
||||
|
||||
func _on_health_changed(entity: Node, current: float, max_val: float) -> void:
|
||||
if entity != parent_node:
|
||||
return
|
||||
health_bar.max_value = max_val
|
||||
health_bar.value = current
|
||||
|
||||
func _on_shield_changed(entity: Node, current: float, max_val: float) -> void:
|
||||
if entity != parent_node or shield_bar == null:
|
||||
return
|
||||
shield_bar.max_value = max_val
|
||||
shield_bar.value = current
|
||||
|
||||
func _on_target_changed(_player: Node, target: Node) -> void:
|
||||
border.visible = (target == get_parent())
|
||||
1
scenes/healthbar.gd.uid
Normal file
1
scenes/healthbar.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d1w7vm7t3k3ts
|
||||
76
scenes/hud/hud.gd
Normal file
76
scenes/hud/hud.gd
Normal file
@@ -0,0 +1,76 @@
|
||||
extends CanvasLayer
|
||||
|
||||
const GCD_TIME := 0.5
|
||||
|
||||
@onready var health_bar: ProgressBar = $HealthBar
|
||||
@onready var health_label: Label = $HealthBar/HealthLabel
|
||||
@onready var shield_bar: ProgressBar = $ShieldBar
|
||||
@onready var shield_label: Label = $ShieldBar/ShieldLabel
|
||||
@onready var respawn_label: Label = $RespawnTimer
|
||||
@onready var class_icon: Label = $AbilityBar/ClassIcon/Label
|
||||
@onready var ability_panels: Array = [
|
||||
$AbilityBar/Ability1,
|
||||
$AbilityBar/Ability2,
|
||||
$AbilityBar/Ability3,
|
||||
$AbilityBar/Ability4,
|
||||
$AbilityBar/Ability5,
|
||||
]
|
||||
|
||||
var ability_labels: Array[String] = ["1", "2", "3", "4", "P"]
|
||||
|
||||
func _ready() -> void:
|
||||
respawn_label.visible = false
|
||||
EventBus.health_changed.connect(_on_health_changed)
|
||||
EventBus.shield_changed.connect(_on_shield_changed)
|
||||
EventBus.entity_died.connect(_on_entity_died)
|
||||
EventBus.player_respawned.connect(_on_player_respawned)
|
||||
EventBus.role_changed.connect(_on_role_changed)
|
||||
EventBus.respawn_tick.connect(_on_respawn_tick)
|
||||
EventBus.cooldown_tick.connect(_on_cooldown_tick)
|
||||
|
||||
func _on_health_changed(entity: Node, current: float, max_val: float) -> void:
|
||||
if entity.name == "Player":
|
||||
health_bar.max_value = max_val
|
||||
health_bar.value = current
|
||||
health_label.text = "%d/%d" % [current, max_val]
|
||||
|
||||
func _on_shield_changed(entity: Node, current: float, max_val: float) -> void:
|
||||
if entity.name == "Player":
|
||||
shield_bar.max_value = max_val
|
||||
shield_bar.value = current
|
||||
shield_label.text = "%d/%d" % [current, max_val]
|
||||
|
||||
func _on_entity_died(entity: Node) -> void:
|
||||
if entity.name == "Player":
|
||||
respawn_label.visible = true
|
||||
|
||||
func _on_player_respawned(_player: Node) -> void:
|
||||
respawn_label.visible = false
|
||||
|
||||
func _on_respawn_tick(timer: float) -> void:
|
||||
respawn_label.text = str(ceil(timer))
|
||||
|
||||
func _on_role_changed(_player: Node, role_type: int) -> void:
|
||||
match role_type:
|
||||
0: class_icon.text = "T"
|
||||
1: class_icon.text = "D"
|
||||
2: class_icon.text = "H"
|
||||
|
||||
func _on_cooldown_tick(cooldowns: Array, max_cooldowns: Array, gcd_timer: float) -> void:
|
||||
for i in range(min(ability_panels.size(), cooldowns.size())):
|
||||
var panel: Panel = ability_panels[i]
|
||||
var label: Label = panel.get_node("Label")
|
||||
var overlay: ColorRect = panel.get_node("CooldownOverlay")
|
||||
var cd: float = cooldowns[i]
|
||||
var gcd: float = gcd_timer if i != 2 and i != 4 else 0.0
|
||||
var active_cd: float = max(cd, gcd)
|
||||
var max_cd: float = max_cooldowns[i] if max_cooldowns[i] > 0 else GCD_TIME
|
||||
|
||||
if active_cd > 0:
|
||||
var ratio: float = clamp(active_cd / max_cd, 0.0, 1.0)
|
||||
overlay.visible = true
|
||||
overlay.anchor_bottom = ratio
|
||||
label.text = str(ceil(active_cd))
|
||||
else:
|
||||
overlay.visible = false
|
||||
label.text = ability_labels[i]
|
||||
1
scenes/hud/hud.gd.uid
Normal file
1
scenes/hud/hud.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c4jhr8k4uwoy7
|
||||
240
scenes/hud/hud.tscn
Normal file
240
scenes/hud/hud.tscn
Normal file
@@ -0,0 +1,240 @@
|
||||
[gd_scene format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/hud/hud.gd" id="1"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ability_active"]
|
||||
bg_color = Color(0.2, 0.2, 0.2, 0.8)
|
||||
border_width_bottom = 2
|
||||
border_width_left = 2
|
||||
border_width_right = 2
|
||||
border_width_top = 2
|
||||
border_color = Color(0.8, 0.8, 0.8, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ability_round"]
|
||||
bg_color = Color(0.2, 0.2, 0.2, 0.8)
|
||||
border_width_bottom = 2
|
||||
border_width_left = 2
|
||||
border_width_right = 2
|
||||
border_width_top = 2
|
||||
border_color = Color(0.8, 0.8, 0.8, 1)
|
||||
corner_radius_top_left = 22
|
||||
corner_radius_top_right = 22
|
||||
corner_radius_bottom_right = 22
|
||||
corner_radius_bottom_left = 22
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_health_bg"]
|
||||
bg_color = Color(0.3, 0.1, 0.1, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_health_fill"]
|
||||
bg_color = Color(0.2, 0.8, 0.2, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_shield_bg"]
|
||||
bg_color = Color(0.1, 0.1, 0.3, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_shield_fill"]
|
||||
bg_color = Color(0.2, 0.5, 0.9, 1)
|
||||
|
||||
[node name="HUD" type="CanvasLayer"]
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="HealthBar" type="ProgressBar" parent="."]
|
||||
offset_left = 10.0
|
||||
offset_top = 10.0
|
||||
offset_right = 210.0
|
||||
offset_bottom = 30.0
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_health_bg")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_health_fill")
|
||||
max_value = 100.0
|
||||
value = 100.0
|
||||
show_percentage = false
|
||||
|
||||
[node name="HealthLabel" type="Label" parent="HealthBar"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "100/100"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="ShieldBar" type="ProgressBar" parent="."]
|
||||
offset_left = 10.0
|
||||
offset_top = 35.0
|
||||
offset_right = 210.0
|
||||
offset_bottom = 55.0
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_shield_bg")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_shield_fill")
|
||||
max_value = 50.0
|
||||
value = 50.0
|
||||
show_percentage = false
|
||||
|
||||
[node name="ShieldLabel" type="Label" parent="ShieldBar"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "50/50"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="RespawnTimer" type="Label" parent="."]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -50.0
|
||||
offset_top = -30.0
|
||||
offset_right = 50.0
|
||||
offset_bottom = 30.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_font_sizes/font_size = 48
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="AbilityBar" type="HBoxContainer" parent="."]
|
||||
anchors_preset = 7
|
||||
anchor_left = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -130.0
|
||||
offset_top = -60.0
|
||||
offset_right = 130.0
|
||||
offset_bottom = -10.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
theme_override_constants/separation = 5
|
||||
|
||||
[node name="ClassIcon" type="Panel" parent="AbilityBar"]
|
||||
custom_minimum_size = Vector2(45, 45)
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_ability_round")
|
||||
|
||||
[node name="Label" type="Label" parent="AbilityBar/ClassIcon"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_font_sizes/font_size = 20
|
||||
text = "D"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Ability1" type="Panel" parent="AbilityBar"]
|
||||
custom_minimum_size = Vector2(45, 45)
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_ability_active")
|
||||
|
||||
[node name="CooldownOverlay" type="ColorRect" parent="AbilityBar/Ability1"]
|
||||
layout_mode = 1
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
color = Color(0, 0, 0, 0.6)
|
||||
visible = false
|
||||
|
||||
[node name="Label" type="Label" parent="AbilityBar/Ability1"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "1"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Ability2" type="Panel" parent="AbilityBar"]
|
||||
custom_minimum_size = Vector2(45, 45)
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_ability_active")
|
||||
|
||||
[node name="CooldownOverlay" type="ColorRect" parent="AbilityBar/Ability2"]
|
||||
layout_mode = 1
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
color = Color(0, 0, 0, 0.6)
|
||||
visible = false
|
||||
|
||||
[node name="Label" type="Label" parent="AbilityBar/Ability2"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "2"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Ability3" type="Panel" parent="AbilityBar"]
|
||||
custom_minimum_size = Vector2(45, 45)
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_ability_active")
|
||||
|
||||
[node name="CooldownOverlay" type="ColorRect" parent="AbilityBar/Ability3"]
|
||||
layout_mode = 1
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
color = Color(0, 0, 0, 0.6)
|
||||
visible = false
|
||||
|
||||
[node name="Label" type="Label" parent="AbilityBar/Ability3"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "3"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Ability4" type="Panel" parent="AbilityBar"]
|
||||
custom_minimum_size = Vector2(45, 45)
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_ability_active")
|
||||
|
||||
[node name="CooldownOverlay" type="ColorRect" parent="AbilityBar/Ability4"]
|
||||
layout_mode = 1
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
color = Color(0, 0, 0, 0.6)
|
||||
visible = false
|
||||
|
||||
[node name="Label" type="Label" parent="AbilityBar/Ability4"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "4"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Ability5" type="Panel" parent="AbilityBar"]
|
||||
custom_minimum_size = Vector2(45, 45)
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_ability_round")
|
||||
|
||||
[node name="CooldownOverlay" type="ColorRect" parent="AbilityBar/Ability5"]
|
||||
layout_mode = 1
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
color = Color(0, 0, 0, 0.6)
|
||||
visible = false
|
||||
|
||||
[node name="Label" type="Label" parent="AbilityBar/Ability5"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "P"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
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
|
||||
34
scenes/portal/gate.gd
Normal file
34
scenes/portal/gate.gd
Normal file
@@ -0,0 +1,34 @@
|
||||
extends StaticBody3D
|
||||
|
||||
@export var target_scene: String = "res://scenes/dungeon/dungeon.tscn"
|
||||
@export var is_exit: bool = false
|
||||
|
||||
var active := false
|
||||
|
||||
func _ready() -> void:
|
||||
if not is_exit:
|
||||
if GameState.dungeon_cleared:
|
||||
queue_free()
|
||||
return
|
||||
get_tree().create_timer(0.5).timeout.connect(_check_overlapping)
|
||||
else:
|
||||
get_tree().create_timer(1.0).timeout.connect(func() -> void: active = true)
|
||||
|
||||
func _check_overlapping() -> void:
|
||||
active = true
|
||||
for body in $GateArea.get_overlapping_bodies():
|
||||
_on_gate_area_body_entered(body)
|
||||
|
||||
func _on_gate_area_body_entered(body: Node3D) -> void:
|
||||
if not active:
|
||||
return
|
||||
if body is CharacterBody3D and body.name == "Player":
|
||||
GameState.save_player(body)
|
||||
if is_exit:
|
||||
GameState.returning_from_dungeon = true
|
||||
else:
|
||||
GameState.portal_position = global_position
|
||||
call_deferred("_change_scene")
|
||||
|
||||
func _change_scene() -> void:
|
||||
get_tree().change_scene_to_file(target_scene)
|
||||
1
scenes/portal/gate.gd.uid
Normal file
1
scenes/portal/gate.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ctci5mc3cd2ck
|
||||
36
scenes/portal/gate.tscn
Normal file
36
scenes/portal/gate.tscn
Normal file
@@ -0,0 +1,36 @@
|
||||
[gd_scene format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/portal/gate.gd" id="1"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1"]
|
||||
albedo_color = Color(0.1, 0.9, 0.3, 1)
|
||||
emission_enabled = true
|
||||
emission = Color(0.1, 0.9, 0.3, 1)
|
||||
emission_energy_multiplier = 0.5
|
||||
|
||||
[sub_resource type="CylinderMesh" id="CylinderMesh_1"]
|
||||
top_radius = 1.0
|
||||
bottom_radius = 1.0
|
||||
height = 2.0
|
||||
material = SubResource("StandardMaterial3D_1")
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_1"]
|
||||
radius = 3.0
|
||||
|
||||
[node name="Gate" type="StaticBody3D"]
|
||||
script = ExtResource("1")
|
||||
collision_layer = 0
|
||||
collision_mask = 0
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource("CylinderMesh_1")
|
||||
|
||||
[node name="GateArea" type="Area3D" parent="."]
|
||||
collision_layer = 0
|
||||
collision_mask = 1
|
||||
monitoring = true
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="GateArea"]
|
||||
shape = SubResource("SphereShape3D_1")
|
||||
|
||||
[connection signal="body_entered" from="GateArea" to="." method="_on_gate_area_body_entered"]
|
||||
33
scenes/portal/portal.gd
Normal file
33
scenes/portal/portal.gd
Normal file
@@ -0,0 +1,33 @@
|
||||
extends StaticBody3D
|
||||
|
||||
@export var stats: BaseStats
|
||||
|
||||
const GATE_SCENE: PackedScene = preload("res://scenes/portal/gate.tscn")
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group("portals")
|
||||
Stats.register(self, stats)
|
||||
EventBus.entity_died.connect(_on_entity_died)
|
||||
|
||||
func _exit_tree() -> void:
|
||||
Stats.deregister(self)
|
||||
|
||||
func _on_entity_died(entity: Node) -> void:
|
||||
if entity != self:
|
||||
return
|
||||
if not is_inside_tree():
|
||||
return
|
||||
var pos: Vector3 = global_position
|
||||
var gate: Node3D = GATE_SCENE.instantiate()
|
||||
get_parent().add_child(gate)
|
||||
gate.global_position = pos
|
||||
var enemies := get_tree().get_nodes_in_group("enemies")
|
||||
for enemy in enemies:
|
||||
if is_instance_valid(enemy):
|
||||
enemy.queue_free()
|
||||
EventBus.portal_defeated.emit(self)
|
||||
queue_free()
|
||||
|
||||
func _on_detection_area_body_entered(body: Node3D) -> void:
|
||||
if body is CharacterBody3D and body.name == "Player":
|
||||
EventBus.enemy_engaged.emit(self, body)
|
||||
1
scenes/portal/portal.gd.uid
Normal file
1
scenes/portal/portal.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://byjxj4mq84gki
|
||||
84
scenes/portal/portal.tscn
Normal file
84
scenes/portal/portal.tscn
Normal file
@@ -0,0 +1,84 @@
|
||||
[gd_scene format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/portal/portal.gd" id="1"]
|
||||
[ext_resource type="Script" path="res://scenes/healthbar.gd" id="3"]
|
||||
[ext_resource type="Resource" path="res://scenes/portal/portal_stats.tres" id="6"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_1"]
|
||||
radius = 10.0
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_1"]
|
||||
radius = 1.0
|
||||
height = 2.0
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_2"]
|
||||
radius = 1.0
|
||||
height = 2.0
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1"]
|
||||
albedo_color = Color(0.5, 0.1, 0.8, 1)
|
||||
|
||||
[sub_resource type="CylinderMesh" id="CylinderMesh_1"]
|
||||
top_radius = 1.0
|
||||
bottom_radius = 1.0
|
||||
height = 2.0
|
||||
material = SubResource("StandardMaterial3D_1")
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_health_bg"]
|
||||
bg_color = Color(0.3, 0.1, 0.1, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_health_fill"]
|
||||
bg_color = Color(0.2, 0.8, 0.2, 1)
|
||||
|
||||
[node name="Portal" type="StaticBody3D"]
|
||||
script = ExtResource("1")
|
||||
stats = ExtResource("6")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("CylinderShape3D_1")
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource("CylinderMesh_1")
|
||||
|
||||
[node name="HitArea" type="Area3D" parent="."]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="HitArea"]
|
||||
shape = SubResource("CylinderShape3D_2")
|
||||
|
||||
[node name="DetectionArea" type="Area3D" parent="."]
|
||||
collision_layer = 0
|
||||
collision_mask = 1
|
||||
monitoring = true
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="DetectionArea"]
|
||||
shape = SubResource("SphereShape3D_1")
|
||||
|
||||
[node name="Healthbar" type="Sprite3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, 0)
|
||||
billboard = 1
|
||||
pixel_size = 0.01
|
||||
script = ExtResource("3")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="Healthbar"]
|
||||
transparent_bg = true
|
||||
size = Vector2i(104, 15)
|
||||
|
||||
[node name="Border" type="ColorRect" parent="Healthbar/SubViewport"]
|
||||
offset_right = 104.0
|
||||
offset_bottom = 15.0
|
||||
color = Color(1, 0.9, 0.2, 1)
|
||||
|
||||
[node name="HealthBar" type="ProgressBar" parent="Healthbar/SubViewport"]
|
||||
offset_left = 2.0
|
||||
offset_top = 2.0
|
||||
offset_right = 102.0
|
||||
offset_bottom = 13.0
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_health_bg")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_health_fill")
|
||||
max_value = 500.0
|
||||
value = 500.0
|
||||
show_percentage = false
|
||||
|
||||
[connection signal="body_entered" from="DetectionArea" to="." method="_on_detection_area_body_entered"]
|
||||
5
scenes/portal/portal_stats.gd
Normal file
5
scenes/portal/portal_stats.gd
Normal file
@@ -0,0 +1,5 @@
|
||||
extends BaseStats
|
||||
class_name PortalStats
|
||||
|
||||
@export var spawn_count := 3
|
||||
@export var thresholds: Array[float] = [0.85, 0.70, 0.55, 0.40, 0.25, 0.10]
|
||||
1
scenes/portal/portal_stats.gd.uid
Normal file
1
scenes/portal/portal_stats.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bioid3s5oftxs
|
||||
7
scenes/portal/portal_stats.tres
Normal file
7
scenes/portal/portal_stats.tres
Normal file
@@ -0,0 +1,7 @@
|
||||
[gd_resource type="Resource" script_class="PortalStats" format=3 uid="uid://be2vv5u0jw0yw"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bioid3s5oftxs" path="res://scenes/portal/portal_stats.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
max_health = 500.0
|
||||
44
scenes/world/portal_spawner.gd
Normal file
44
scenes/world/portal_spawner.gd
Normal file
@@ -0,0 +1,44 @@
|
||||
extends Node
|
||||
|
||||
const PORTAL_SCENE: PackedScene = preload("res://scenes/portal/portal.tscn")
|
||||
const GATE_SCENE: PackedScene = preload("res://scenes/portal/gate.tscn")
|
||||
const SPAWN_INTERVAL := 30.0
|
||||
const MAX_PORTALS := 3
|
||||
const MIN_DISTANCE := 20.0
|
||||
const MAX_DISTANCE := 40.0
|
||||
|
||||
var portals: Array[Node] = []
|
||||
var timer := 0.0
|
||||
|
||||
func _ready() -> void:
|
||||
if GameState.portal_position != Vector3.ZERO and not GameState.dungeon_cleared:
|
||||
call_deferred("_restore_gate")
|
||||
else:
|
||||
if GameState.dungeon_cleared:
|
||||
GameState.clear()
|
||||
call_deferred("_spawn_portal")
|
||||
|
||||
func _restore_gate() -> void:
|
||||
var gate: Node3D = GATE_SCENE.instantiate()
|
||||
get_parent().add_child(gate)
|
||||
gate.global_position = GameState.portal_position
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
timer += delta
|
||||
if timer >= SPAWN_INTERVAL:
|
||||
timer = 0.0
|
||||
_cleanup_dead()
|
||||
if portals.size() < MAX_PORTALS:
|
||||
_spawn_portal()
|
||||
|
||||
func _spawn_portal() -> void:
|
||||
var angle: float = randf() * TAU
|
||||
var distance: float = randf_range(MIN_DISTANCE, MAX_DISTANCE)
|
||||
var pos := Vector3(cos(angle) * distance, 0, sin(angle) * distance)
|
||||
var portal: Node3D = PORTAL_SCENE.instantiate()
|
||||
get_parent().add_child(portal)
|
||||
portal.global_position = pos
|
||||
portals.append(portal)
|
||||
|
||||
func _cleanup_dead() -> void:
|
||||
portals = portals.filter(func(p: Node) -> bool: return is_instance_valid(p))
|
||||
1
scenes/world/portal_spawner.gd.uid
Normal file
1
scenes/world/portal_spawner.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cskx6o07iukwh
|
||||
129
scenes/world/world.tscn
Normal file
129
scenes/world/world.tscn
Normal file
@@ -0,0 +1,129 @@
|
||||
[gd_scene format=3 uid="uid://dy1icabu2ssbw"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://h0hts425epc6" path="res://systems/ability_system.gd" id="ability_system"]
|
||||
[ext_resource type="Script" uid="uid://cysg30lud2ta2" path="res://systems/aggro/aggro_decay.gd" id="aggro_decay"]
|
||||
[ext_resource type="Script" uid="uid://cyffo1g4uhmwh" path="res://systems/aggro/aggro_events.gd" id="aggro_events"]
|
||||
[ext_resource type="Script" uid="uid://cm7ehl2pexcst" path="res://systems/aggro/aggro_system.gd" id="aggro_system"]
|
||||
[ext_resource type="Script" uid="uid://c7gsu2qddsor6" path="res://systems/aggro/aggro_tracker.gd" id="aggro_tracker"]
|
||||
[ext_resource type="Script" uid="uid://da2jm0awq2lnh" path="res://systems/buff_system.gd" id="buff_system"]
|
||||
[ext_resource type="Script" uid="uid://ddos7mo8rahou" path="res://systems/cooldown_system.gd" id="cooldown_system"]
|
||||
[ext_resource type="Script" uid="uid://cbd1bryh0e2dw" path="res://systems/damage_system.gd" id="damage_system"]
|
||||
[ext_resource type="Script" uid="uid://bwhxu5586lc1l" path="res://systems/enemy_ai_system.gd" id="enemy_ai_system"]
|
||||
[ext_resource type="Script" uid="uid://b3wkn5118dimy" path="res://systems/health_system.gd" id="health_system"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/hud/hud.tscn" id="hud"]
|
||||
[ext_resource type="PackedScene" uid="uid://cdnkbt1f0db7e" path="res://scenes/player/player.tscn" id="player"]
|
||||
[ext_resource type="Script" uid="uid://cskx6o07iukwh" path="res://scenes/world/portal_spawner.gd" id="portal_spawner"]
|
||||
[ext_resource type="Script" uid="uid://b1qkvoqvmd21h" path="res://systems/respawn_system.gd" id="respawn_system"]
|
||||
[ext_resource type="Script" uid="uid://rsnpuf77o0sn" path="res://systems/shield_system.gd" id="shield_system"]
|
||||
[ext_resource type="Script" uid="uid://c84voxmnaifyt" path="res://systems/spawn_system.gd" id="spawn_system"]
|
||||
|
||||
[sub_resource type="NavigationMesh" id="NavigationMesh_1"]
|
||||
vertices = PackedVector3Array(-49.5, 0.5, -49.5, -49.5, 0.5, 49.5, 49.5, 0.5, 49.5, 49.5, 0.5, -49.5)
|
||||
polygons = [PackedInt32Array(3, 2, 0), PackedInt32Array(0, 2, 1)]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_1"]
|
||||
colors = PackedColorArray(0.15, 0.35, 0.05, 1, 0.3, 0.55, 0.1, 1)
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_1"]
|
||||
frequency = 0.05
|
||||
|
||||
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_1"]
|
||||
noise = SubResource("FastNoiseLite_1")
|
||||
color_ramp = SubResource("Gradient_1")
|
||||
seamless = true
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ground"]
|
||||
albedo_texture = SubResource("NoiseTexture2D_1")
|
||||
uv1_scale = Vector3(15, 15, 1)
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_1"]
|
||||
material = SubResource("StandardMaterial3D_ground")
|
||||
size = Vector2(100, 100)
|
||||
|
||||
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_1"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_tavern"]
|
||||
albedo_color = Color(0.45, 0.3, 0.15, 1)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_tavern"]
|
||||
material = SubResource("StandardMaterial3D_tavern")
|
||||
size = Vector3(5, 3, 5)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_tavern"]
|
||||
size = Vector3(5, 3, 5)
|
||||
|
||||
[node name="World" type="Node3D" unique_id=1865233338]
|
||||
|
||||
[node name="Systems" type="Node" parent="." unique_id=1813416478]
|
||||
|
||||
[node name="HealthSystem" type="Node" parent="Systems" unique_id=221270411]
|
||||
script = ExtResource("health_system")
|
||||
|
||||
[node name="ShieldSystem" type="Node" parent="Systems" unique_id=1790230220]
|
||||
script = ExtResource("shield_system")
|
||||
|
||||
[node name="DamageSystem" type="Node" parent="Systems" unique_id=2146323526]
|
||||
script = ExtResource("damage_system")
|
||||
|
||||
[node name="AbilitySystem" type="Node" parent="Systems" unique_id=391120092]
|
||||
script = ExtResource("ability_system")
|
||||
|
||||
[node name="CooldownSystem" type="Node" parent="Systems" unique_id=99457358]
|
||||
script = ExtResource("cooldown_system")
|
||||
|
||||
[node name="AggroSystem" type="Node" parent="Systems" unique_id=1539448343]
|
||||
script = ExtResource("aggro_system")
|
||||
|
||||
[node name="AggroTracker" type="Node" parent="Systems/AggroSystem" unique_id=1597893665]
|
||||
script = ExtResource("aggro_tracker")
|
||||
|
||||
[node name="AggroDecay" type="Node" parent="Systems/AggroSystem" unique_id=1571705506]
|
||||
script = ExtResource("aggro_decay")
|
||||
|
||||
[node name="AggroEvents" type="Node" parent="Systems/AggroSystem" unique_id=1936723580]
|
||||
script = ExtResource("aggro_events")
|
||||
|
||||
[node name="EnemyAISystem" type="Node" parent="Systems" unique_id=2089718042]
|
||||
script = ExtResource("enemy_ai_system")
|
||||
|
||||
[node name="RespawnSystem" type="Node" parent="Systems" unique_id=1586865573]
|
||||
script = ExtResource("respawn_system")
|
||||
|
||||
[node name="SpawnSystem" type="Node" parent="Systems" unique_id=1099032666]
|
||||
script = ExtResource("spawn_system")
|
||||
|
||||
[node name="BuffSystem" type="Node" parent="Systems" unique_id=1219368182]
|
||||
script = ExtResource("buff_system")
|
||||
|
||||
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="." unique_id=1265843679]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0027503967, 0.014227867, 0.023231506)
|
||||
navigation_mesh = SubResource("NavigationMesh_1")
|
||||
|
||||
[node name="Boden" type="MeshInstance3D" parent="NavigationRegion3D" unique_id=593226019]
|
||||
mesh = SubResource("PlaneMesh_1")
|
||||
|
||||
[node name="BodenCollision" type="StaticBody3D" parent="." unique_id=1112667638]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="BodenCollision" unique_id=621554623]
|
||||
shape = SubResource("WorldBoundaryShape3D_1")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1797472817]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.707, 0.707, 0, -0.707, 0.707, 0, 10, 0)
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="Taverne" type="StaticBody3D" parent="." unique_id=1978646562]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="Taverne" unique_id=2043279810]
|
||||
mesh = SubResource("BoxMesh_tavern")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Taverne" unique_id=2108564286]
|
||||
shape = SubResource("BoxShape3D_tavern")
|
||||
|
||||
[node name="Player" parent="." unique_id=585018813 instance=ExtResource("player")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -5)
|
||||
|
||||
[node name="HUD" parent="." unique_id=763693646 instance=ExtResource("hud")]
|
||||
|
||||
[node name="PortalSpawner" type="Node" parent="." unique_id=2100621428]
|
||||
script = ExtResource("portal_spawner")
|
||||
Reference in New Issue
Block a user