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
|
|
|
export (PackedScene) var UpgradeMenu
|
2018-05-23 03:57:15 -04:00
|
|
|
|
2018-05-23 01:40:45 -04:00
|
|
|
var position = Vector2(200, 200)
|
|
|
|
var total_bads_spawned = 0
|
|
|
|
var upgrade_cost = 50
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
$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
|
|
|
|
bad.position.y = randi()%500 + 25
|
|
|
|
else:
|
|
|
|
total_bads_spawned = 0
|
|
|
|
|
|
|
|
func _on_Player_shooting_speed_upgrade():
|
2018-05-23 03:57:15 -04:00
|
|
|
updatePoints()
|
2018-05-23 01:40:45 -04:00
|
|
|
pass
|
|
|
|
|
|
|
|
func _on_PauseButton_pressed():
|
|
|
|
var upgmenu
|
|
|
|
upgmenu = UpgradeMenu.instance()
|
|
|
|
add_child(upgmenu)
|
2018-05-23 03:57:15 -04:00
|
|
|
upgmenu.connect("refund", self, "_refund_button")
|
|
|
|
get_tree().paused = true
|
|
|
|
|
|
|
|
func updatePoints():
|
|
|
|
$MoneyDisplay.text = str($Player.money, " points")
|
|
|
|
|
|
|
|
#When refund signal from upgrade menu comes in,
|
|
|
|
# tell Player to refund upgrades
|
|
|
|
func _refund_button():
|
|
|
|
$Player.refund()
|
|
|
|
|
|
|
|
#When refund comes back successfully from Player,
|
|
|
|
# pause game again
|
|
|
|
func _on_Player_refund(ship_value):
|
|
|
|
prints("Refunded for ", ship_value)
|
|
|
|
updatePoints()
|
|
|
|
get_tree().paused = true
|
|
|
|
pass # replace with function body
|