53 lines
1.0 KiB
GDScript
53 lines
1.0 KiB
GDScript
extends Control
|
|
|
|
export(NodePath) var label_nodepath
|
|
export(NodePath) var popup_nodepath
|
|
|
|
const SCORE = 100
|
|
|
|
var _labelScore: Label
|
|
var _popup: Popup
|
|
var _score: int = 0
|
|
|
|
|
|
func _ready():
|
|
_labelScore = get_node(label_nodepath) as Label
|
|
assert(null != _labelScore)
|
|
|
|
_popup = get_node(popup_nodepath) as Popup
|
|
assert(null != _popup)
|
|
|
|
|
|
func increaseScore():
|
|
_score += SCORE
|
|
_labelScore.text = "Score: " + String(_score)
|
|
Logger.info(String(_score) + " of " + String(Collector.getCount() * SCORE) + " possible points")
|
|
if (_score >= (Collector.getCount() * SCORE)):
|
|
Logger.info("YOU WON!")
|
|
success()
|
|
|
|
|
|
func gameOver():
|
|
_endGame(false)
|
|
|
|
|
|
func success():
|
|
_endGame(true)
|
|
|
|
|
|
func _endGame (value):
|
|
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
|
|
|
Collector.Clear()
|
|
|
|
_popup.get_node("LabelWon").visible = value
|
|
_popup.get_node("LabelFail").visible = !value
|
|
|
|
_popup.get_node("PanelWon").visible = value
|
|
_popup.get_node("PanelFail").visible = !value
|
|
_popup.show()
|
|
|
|
|
|
func _on_Button_pressed():
|
|
get_tree().reload_current_scene()
|