show objectives
This commit is contained in:
parent
75eb918bfa
commit
fac981d078
3 changed files with 46 additions and 16 deletions
|
@ -35,7 +35,7 @@ func setup(mode: String, goal: int, difficulty: String, next_lose: String, next_
|
|||
game_version = version
|
||||
print("setup minigame: " + mode + " " + next_lose + " " + next_win)
|
||||
set_mode(mode)
|
||||
scoreUI.init(mode)
|
||||
scoreUI.init(mode, goal)
|
||||
next_timeline_lose = next_lose
|
||||
next_timeline_win = next_win
|
||||
|
||||
|
@ -102,18 +102,17 @@ func _on_player_die() -> void:
|
|||
func _on_player_hit() -> void:
|
||||
pass
|
||||
|
||||
func update_score():
|
||||
current_goal += 1
|
||||
scoreUI.update_score(current_goal)
|
||||
if current_goal >= game_goal:
|
||||
on_win()
|
||||
|
||||
|
||||
func _on_player_score() -> void:
|
||||
if game_mode == "score":
|
||||
current_goal += 1
|
||||
scoreUI.update_score(current_goal)
|
||||
if current_goal >= game_goal:
|
||||
on_win()
|
||||
|
||||
update_score()
|
||||
|
||||
func _on_Timer_timeout() -> void:
|
||||
if game_mode == "time":
|
||||
current_goal += 1
|
||||
scoreUI.update_score(game_goal - current_goal)
|
||||
if current_goal >= game_goal:
|
||||
on_win()
|
||||
update_score()
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
extends Control
|
||||
|
||||
onready var label := $MarginContainer/Label
|
||||
onready var objective_label := $MarginContainer/VBoxContainer/ObjectiveLabel
|
||||
onready var score_label := $MarginContainer/VBoxContainer/ScoreLabel
|
||||
|
||||
var game_mode
|
||||
|
||||
var game_objective : int
|
||||
|
||||
func update_score(score: int):
|
||||
label.text = String(score)
|
||||
score_label.text = String(score) + "/" + String(game_objective)
|
||||
|
||||
|
||||
func start(initial_score: int):
|
||||
|
@ -13,6 +16,13 @@ func start(initial_score: int):
|
|||
show()
|
||||
|
||||
|
||||
func init(mode: String):
|
||||
func init(mode: String, objective: int):
|
||||
game_objective = objective
|
||||
game_mode = mode
|
||||
if game_mode == "score":
|
||||
objective_label.text = "Obtenez le score indiqué"
|
||||
elif game_mode == "time":
|
||||
objective_label.text = "Survivez le temps indiqué"
|
||||
else:
|
||||
objective_label.text = "Erreur"
|
||||
hide()
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://mini-game/ressources/font/joystix/ot/joystix monospace.otf" type="DynamicFontData" id=1]
|
||||
[ext_resource path="res://mini-game/scenes/decor/scoreUI.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="DynamicFont" id=2]
|
||||
size = 70
|
||||
outline_size = 2
|
||||
outline_color = Color( 0, 0, 0, 1 )
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 50
|
||||
outline_size = 2
|
||||
|
@ -28,11 +34,26 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer"]
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||
margin_left = 10.0
|
||||
margin_top = 10.0
|
||||
margin_right = 1910.0
|
||||
margin_bottom = 71.0
|
||||
margin_bottom = 160.0
|
||||
|
||||
[node name="ObjectiveLabel" type="Label" parent="MarginContainer/VBoxContainer"]
|
||||
margin_right = 1900.0
|
||||
margin_bottom = 85.0
|
||||
custom_fonts/font = SubResource( 2 )
|
||||
text = "Objective"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ScoreLabel" type="Label" parent="MarginContainer/VBoxContainer"]
|
||||
margin_top = 89.0
|
||||
margin_right = 1900.0
|
||||
margin_bottom = 150.0
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
text = "99999"
|
||||
align = 1
|
||||
|
|
Loading…
Reference in a new issue