2018-05-23 01:40:45 -04:00
|
|
|
extends Node
|
2018-05-23 03:57:15 -04:00
|
|
|
|
2018-05-23 01:40:45 -04:00
|
|
|
export (PackedScene) var FirstBad
|
2018-05-23 03:57:15 -04:00
|
|
|
export (PackedScene) var BlobBad
|
|
|
|
|
2018-05-23 01:40:45 -04:00
|
|
|
var position = Vector2(200, 200)
|
|
|
|
var total_bads_spawned = 0
|
|
|
|
var upgrade_cost = 50
|
|
|
|
|
2018-05-23 21:35:16 -04:00
|
|
|
const BADDIE_WAIT_TIME_DEFAULT = 5
|
|
|
|
|
2018-05-23 01:40:45 -04:00
|
|
|
func _ready():
|
2018-05-24 04:19:59 -04:00
|
|
|
var mainmenu = preload("res://MainMenu.tscn").instance()
|
|
|
|
add_child(mainmenu)
|
|
|
|
get_tree().paused = true
|
2018-05-23 21:35:16 -04:00
|
|
|
$BaddieTimer.wait_time = BADDIE_WAIT_TIME_DEFAULT
|
2018-05-23 01:40:45 -04:00
|
|
|
$BaddieTimer.start()
|
|
|
|
randomize()
|
2018-05-23 03:57:15 -04:00
|
|
|
updatePoints()
|
2018-05-23 01:40:45 -04:00
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
if (Input.is_action_pressed("ctlr_l")):
|
|
|
|
if (Input.is_action_pressed("ctlr_r")):
|
|
|
|
if (Input.is_action_pressed("ctlr_a")):
|
|
|
|
if (Input.is_action_pressed("ctlr_start")):
|
|
|
|
get_tree().quit()
|
|
|
|
if (Input.is_action_pressed("ui_quit")):
|
|
|
|
get_tree().quit()
|
2018-05-23 03:57:15 -04:00
|
|
|
updatePoints()
|
2018-05-23 01:40:45 -04:00
|
|
|
|
2018-05-23 03:57:15 -04:00
|
|
|
func _on_bad_death(kill_money):
|
2018-05-23 01:40:45 -04:00
|
|
|
$Player.money += kill_money
|
2018-05-23 03:57:15 -04:00
|
|
|
updatePoints()
|
2018-05-23 01:40:45 -04:00
|
|
|
|
|
|
|
var sendblob = 0
|
|
|
|
func BaddieTimer():
|
|
|
|
if total_bads_spawned < 11:
|
|
|
|
var bad
|
2018-05-23 03:57:15 -04:00
|
|
|
|
2018-05-23 01:40:45 -04:00
|
|
|
if sendblob == 5:
|
|
|
|
sendblob = 0
|
2018-05-23 03:57:15 -04:00
|
|
|
bad = BlobBad.instance()
|
2018-05-23 01:40:45 -04:00
|
|
|
else:
|
|
|
|
bad = FirstBad.instance()
|
|
|
|
sendblob += 1
|
2018-05-23 03:57:15 -04:00
|
|
|
|
|
|
|
add_child(bad)
|
|
|
|
bad.connect("dead", self, "_on_bad_death")
|
2018-05-23 01:40:45 -04:00
|
|
|
total_bads_spawned += 1
|
2018-05-23 03:57:15 -04:00
|
|
|
$BaddieTimer.wait_time = $BaddieTimer.wait_time * 0.97
|
2018-05-23 01:40:45 -04:00
|
|
|
|
2018-05-23 03:57:15 -04:00
|
|
|
updatePoints()
|
2018-05-23 01:40:45 -04:00
|
|
|
|
|
|
|
bad.position.x = 1200
|
2018-05-23 04:34:13 -04:00
|
|
|
bad.position.y = (randi()%470) + 40
|
2018-05-23 01:40:45 -04:00
|
|
|
else:
|
|
|
|
total_bads_spawned = 0
|
|
|
|
|
|
|
|
func _on_PauseButton_pressed():
|
2018-05-23 11:02:52 -04:00
|
|
|
$Player.upgradeMenu()
|
2018-05-23 03:57:15 -04:00
|
|
|
|
|
|
|
func updatePoints():
|
|
|
|
$MoneyDisplay.text = str($Player.money, " points")
|
|
|
|
|
2018-05-23 11:02:52 -04:00
|
|
|
func _on_Player_update_display():
|
2018-05-23 21:35:16 -04:00
|
|
|
updatePoints()
|
|
|
|
|
|
|
|
func _on_Mothership_game_over():
|
|
|
|
$Player.gameOver()
|
|
|
|
|
|
|
|
|
|
|
|
func _on_Player_restart_game():
|
|
|
|
for child in self.get_children():
|
|
|
|
if (child.has_method("_on_Visibility_screen_exited")):
|
|
|
|
child.queue_free()
|
|
|
|
total_bads_spawned = 0
|
|
|
|
$BaddieTimer.wait_time = BADDIE_WAIT_TIME_DEFAULT
|