update
This commit is contained in:
@@ -7,7 +7,7 @@ var active := false
|
||||
|
||||
func _ready() -> void:
|
||||
if not is_exit:
|
||||
if GameState.dungeon_cleared:
|
||||
if PlayerData.dungeon_cleared:
|
||||
queue_free()
|
||||
return
|
||||
get_tree().create_timer(0.5).timeout.connect(_check_overlapping)
|
||||
@@ -23,11 +23,11 @@ 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)
|
||||
PlayerData.save_cache()
|
||||
if is_exit:
|
||||
GameState.returning_from_dungeon = true
|
||||
PlayerData.returning_from_dungeon = true
|
||||
else:
|
||||
GameState.portal_position = global_position
|
||||
PlayerData.portal_position = global_position
|
||||
call_deferred("_change_scene")
|
||||
|
||||
func _change_scene() -> void:
|
||||
|
||||
14
scenes/portal/init.gd
Normal file
14
scenes/portal/init.gd
Normal file
@@ -0,0 +1,14 @@
|
||||
extends StaticBody3D
|
||||
|
||||
@export var stats: PortalStats
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group("portals")
|
||||
PortalData.register(self, stats)
|
||||
|
||||
func _exit_tree() -> void:
|
||||
PortalData.deregister(self)
|
||||
|
||||
func _on_detection_area_body_entered(body: Node3D) -> void:
|
||||
if body is CharacterBody3D and body.name == "Player":
|
||||
EventBus.portal_entered.emit(self, body)
|
||||
1
scenes/portal/init.gd.uid
Normal file
1
scenes/portal/init.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dlexijybbqxop
|
||||
@@ -1,33 +0,0 @@
|
||||
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 +0,0 @@
|
||||
uid://byjxj4mq84gki
|
||||
@@ -1,7 +1,6 @@
|
||||
[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="Script" path="res://scenes/portal/init.gd" id="1"]
|
||||
[ext_resource type="Resource" path="res://scenes/portal/portal_stats.tres" id="6"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_1"]
|
||||
@@ -59,7 +58,6 @@ shape = SubResource("SphereShape3D_1")
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user