boss fix
This commit is contained in:
parent
100572749a
commit
11a54f2b94
22 changed files with 304 additions and 532 deletions
22
Spawner.gd
22
Spawner.gd
|
@ -4,7 +4,8 @@ extends Node2D
|
|||
@export var wave_label: Label
|
||||
var portal = preload("res://portal.tscn")
|
||||
var enemies_previous = false
|
||||
var wave_count = 0
|
||||
@export var start_wave = 0
|
||||
var wave_count = start_wave
|
||||
|
||||
func _ready():
|
||||
spawn_loop()
|
||||
|
@ -19,48 +20,55 @@ func check_enemies_loop():
|
|||
enemies_previous = has_enemies
|
||||
|
||||
func spawn_loop():
|
||||
for wave in waves:
|
||||
for wave in waves.slice(start_wave):
|
||||
wave_count += 1
|
||||
wave_label.text = "Wave %d" % wave_count
|
||||
print("Starting Next Wave")
|
||||
for i in range(len(wave.enemies)):
|
||||
spawn_enemies(wave.quantities[i], wave.spawning_duration, wave.enemies[i])
|
||||
await get_tree().create_timer(wave.spawning_duration).timeout
|
||||
if wave.wait_for_killed:
|
||||
enemies_previous = true
|
||||
await all_enemies_perished
|
||||
else:
|
||||
await get_tree().create_timer(wave.spawning_duration).timeout
|
||||
print("all enemies perished")
|
||||
await get_tree().create_timer(wave.wait).timeout
|
||||
wave_complete.emit()
|
||||
|
||||
|
||||
wave_count += 1
|
||||
$"../GameOver".text = "YOU WIN!"
|
||||
$"../Player".destroy()
|
||||
|
||||
func spawn_enemies(count: int, duration: float, enemy: WaveEnemy):
|
||||
var delay = duration / count
|
||||
for i in range(count):
|
||||
await get_tree().create_timer(delay).timeout
|
||||
spawn(enemy)
|
||||
await get_tree().create_timer(delay).timeout
|
||||
|
||||
func spawn(item: WaveEnemy):
|
||||
|
||||
var spawn_loc = Vector2.ZERO
|
||||
|
||||
if item.boss:
|
||||
print("Spawning Boss!")
|
||||
spawn_loc = Vector2(1920/2, 1080/2)
|
||||
else:
|
||||
for i in range(10):
|
||||
for i in range(100):
|
||||
var test_pos = Vector2(randf(), randf()) * Vector2(1920, 1080)
|
||||
if not $"../CollisionCheck".is_clear(test_pos, item.check_distance):
|
||||
continue
|
||||
spawn_loc = test_pos
|
||||
break
|
||||
|
||||
if spawn_loc == Vector2.ZERO:
|
||||
return
|
||||
|
||||
if not item.boss:
|
||||
var portal_effect = portal.instantiate()
|
||||
portal_effect.global_position = spawn_loc
|
||||
portal_effect.sprite_frames = item.portal_texture
|
||||
$/root/Node2D.add_child(portal_effect)
|
||||
await get_tree().create_timer(0.6).timeout
|
||||
await get_tree().create_timer((item.portal_texture.get_frame_count("default") / 2) * (1 / item.portal_texture.get_animation_speed("default"))).timeout
|
||||
var node = item.enemy.instantiate()
|
||||
node.global_position = spawn_loc
|
||||
if not item.boss:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue