added chest and chest spawners but they don't always show up?
This commit is contained in:
@@ -15,9 +15,11 @@ class_name level
|
||||
@onready var crown = preload("res://assets/crown.tscn")
|
||||
var dead_player = preload("res://assets/dead_cam.tscn")
|
||||
const DEAD_ANNOUNCE = preload("res://assets/dead_announce.tscn")
|
||||
const CHEST_1 = preload("res://chest1.tscn")
|
||||
|
||||
var level_name
|
||||
var paused = false
|
||||
var chest_spawners = []
|
||||
var pickups = []
|
||||
|
||||
var keys = []
|
||||
@@ -32,6 +34,7 @@ var respawn_cam_rotation
|
||||
var respawn_rot
|
||||
var engine_time_scale_cache : float = 1.0
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
level_name = self.get_name()
|
||||
@@ -72,7 +75,7 @@ func _ready():
|
||||
#global randomize function
|
||||
randomize()
|
||||
|
||||
|
||||
|
||||
#clear spawned in objects
|
||||
for node in get_tree().get_nodes_in_group("spawned"):
|
||||
node.queue_free()
|
||||
@@ -82,6 +85,23 @@ func _ready():
|
||||
enemy_hiveminds.append(node)
|
||||
#count starting enemies
|
||||
enemy_count()
|
||||
|
||||
chest_spawners = get_tree().get_nodes_in_group("chest_spawner")
|
||||
if chest_spawners.size() > 0:
|
||||
for i in chest_spawners:
|
||||
i.visible = false
|
||||
|
||||
var number_chests = randi_range(1,gamemode.max_number_of_chests)
|
||||
|
||||
while number_chests > 0:
|
||||
var chest_loc = chest_spawners.pick_random()
|
||||
var instance_chest = CHEST_1.instantiate()
|
||||
print("SPAWNING CHEST AT : ",chest_loc.name)
|
||||
instance_chest.global_position = chest_loc.global_position
|
||||
instance_chest.global_rotation = chest_loc.global_rotation
|
||||
get_tree().current_scene.add_child(instance_chest)
|
||||
number_chests -= 1
|
||||
|
||||
|
||||
func refresh_scene():
|
||||
GameGlobals.health = gamemode.start_health
|
||||
|
||||
Reference in New Issue
Block a user