Second Map, and sound effects
This commit is contained in:
@ -8,10 +8,11 @@ const COBOLD = preload("res://Game/Mobs/cobold.tscn")
|
||||
|
||||
const enemies = [FORKMAN, COBOLD, ORK]
|
||||
|
||||
|
||||
var pause = 40
|
||||
func _ready() -> void:
|
||||
get_node("CanvasLayer/SidePanel").set_Lifes(20)
|
||||
get_node("CanvasLayer/SidePanel").Update_Coins(2000)
|
||||
get_node("CanvasLayer/SidePanel").Update_Coins(250)
|
||||
|
||||
|
||||
#the meaning of the columns inside my wave generation matris:
|
||||
# Number of enemies need to be spawned, chance of spawn an enemy, chance of forkman, chance of gobline, chance of ork
|
||||
@ -27,23 +28,26 @@ var currentwave = 0
|
||||
var endwave = false
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
if endwave:
|
||||
if not get_node("Path2D").get_children():
|
||||
endwave = false
|
||||
get_node("CanvasLayer/SidePanel").Update_waves(currentwave + 1) #updating waves
|
||||
if currentwave >= 4: #!!!!! CHECKS FOR THE LAST WAVE IF NEW WAVES ARE ADDED CHANGE ACCORDINGLY!!!
|
||||
get_node("CanvasLayer/SidePanel").GameWon()
|
||||
if pause <= 0:
|
||||
if endwave:
|
||||
if not get_node("Path2D").get_children():
|
||||
endwave = false
|
||||
get_node("CanvasLayer/SidePanel").Update_waves(currentwave + 1) #updating waves
|
||||
if currentwave >= 4: #!!!!! CHECKS FOR THE LAST WAVE IF NEW WAVES ARE ADDED CHANGE ACCORDINGLY!!!
|
||||
get_node("CanvasLayer/SidePanel").GameWon()
|
||||
else:
|
||||
spawnMonster()
|
||||
else:
|
||||
spawnMonster()
|
||||
pause -= 1
|
||||
|
||||
func spawnMonster():
|
||||
currentwave = 0
|
||||
for w in waves:
|
||||
if w[0] > 0:
|
||||
if randf() < w[1]: #chance of generating any kind of enemy
|
||||
w[0] -= 1
|
||||
if w[0] <= 0:
|
||||
endwave = true
|
||||
currentwave += 1
|
||||
var chosen = randf()
|
||||
var sum = 0.0
|
||||
for i in range(2,5):
|
||||
@ -55,9 +59,7 @@ func spawnMonster():
|
||||
path_2d.add_child(path)
|
||||
break
|
||||
break
|
||||
else:
|
||||
currentwave += 1
|
||||
|
||||
|
||||
|
||||
func decrease_life(damage) -> void:
|
||||
get_node("CanvasLayer/SidePanel").Update_Lifes(-damage)
|
||||
|
Reference in New Issue
Block a user