Browse Source

show objectives

Arnaud Vergnet 2 years ago
parent
commit
fac981d078
3 changed files with 46 additions and 16 deletions
  1. 9
    10
      mini-game/MiniGame.gd
  2. 13
    3
      mini-game/scenes/decor/scoreUI.gd
  3. 24
    3
      mini-game/scenes/decor/scoreUI.tscn

+ 9
- 10
mini-game/MiniGame.gd View File

@@ -35,7 +35,7 @@ func setup(mode: String, goal: int, difficulty: String, next_lose: String, next_
35 35
 	game_version = version
36 36
 	print("setup minigame: " + mode + " " + next_lose + " " + next_win)
37 37
 	set_mode(mode)
38
-	scoreUI.init(mode)
38
+	scoreUI.init(mode, goal)
39 39
 	next_timeline_lose = next_lose
40 40
 	next_timeline_win = next_win
41 41
 
@@ -102,18 +102,17 @@ func _on_player_die() -> void:
102 102
 func _on_player_hit() -> void:
103 103
 	pass
104 104
 
105
+func update_score():
106
+	current_goal += 1
107
+	scoreUI.update_score(current_goal)
108
+	if current_goal >= game_goal:
109
+		on_win()
110
+
105 111
 
106 112
 func _on_player_score() -> void:
107 113
 	if game_mode == "score":
108
-		current_goal += 1
109
-		scoreUI.update_score(current_goal)
110
-		if current_goal >= game_goal:
111
-			on_win()
112
-
114
+		update_score()
113 115
 
114 116
 func _on_Timer_timeout() -> void:
115 117
 	if game_mode == "time":
116
-		current_goal += 1
117
-		scoreUI.update_score(game_goal - current_goal)
118
-		if current_goal >= game_goal:
119
-			on_win()
118
+		update_score()

+ 13
- 3
mini-game/scenes/decor/scoreUI.gd View File

@@ -1,11 +1,14 @@
1 1
 extends Control
2 2
 
3
-onready var label := $MarginContainer/Label
3
+onready var objective_label := $MarginContainer/VBoxContainer/ObjectiveLabel
4
+onready var score_label := $MarginContainer/VBoxContainer/ScoreLabel
4 5
 
5 6
 var game_mode
6 7
 
8
+var game_objective : int
9
+
7 10
 func update_score(score: int):
8
-	label.text = String(score)
11
+	score_label.text = String(score) + "/" + String(game_objective)
9 12
 
10 13
 
11 14
 func start(initial_score: int):
@@ -13,6 +16,13 @@ func start(initial_score: int):
13 16
 	show()
14 17
 
15 18
 
16
-func init(mode: String):
19
+func init(mode: String, objective: int):
20
+	game_objective = objective
17 21
 	game_mode = mode
22
+	if game_mode == "score":
23
+		objective_label.text = "Obtenez le score indiqué"
24
+	elif game_mode == "time":
25
+		objective_label.text = "Survivez le temps indiqué"
26
+	else:
27
+		objective_label.text = "Erreur"
18 28
 	hide()

+ 24
- 3
mini-game/scenes/decor/scoreUI.tscn View File

@@ -1,8 +1,14 @@
1
-[gd_scene load_steps=4 format=2]
1
+[gd_scene load_steps=5 format=2]
2 2
 
3 3
 [ext_resource path="res://mini-game/ressources/font/joystix/ot/joystix monospace.otf" type="DynamicFontData" id=1]
4 4
 [ext_resource path="res://mini-game/scenes/decor/scoreUI.gd" type="Script" id=2]
5 5
 
6
+[sub_resource type="DynamicFont" id=2]
7
+size = 70
8
+outline_size = 2
9
+outline_color = Color( 0, 0, 0, 1 )
10
+font_data = ExtResource( 1 )
11
+
6 12
 [sub_resource type="DynamicFont" id=1]
7 13
 size = 50
8 14
 outline_size = 2
@@ -28,11 +34,26 @@ __meta__ = {
28 34
 "_edit_use_anchors_": false
29 35
 }
30 36
 
31
-[node name="Label" type="Label" parent="MarginContainer"]
37
+[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
32 38
 margin_left = 10.0
33 39
 margin_top = 10.0
34 40
 margin_right = 1910.0
35
-margin_bottom = 71.0
41
+margin_bottom = 160.0
42
+
43
+[node name="ObjectiveLabel" type="Label" parent="MarginContainer/VBoxContainer"]
44
+margin_right = 1900.0
45
+margin_bottom = 85.0
46
+custom_fonts/font = SubResource( 2 )
47
+text = "Objective"
48
+align = 1
49
+__meta__ = {
50
+"_edit_use_anchors_": false
51
+}
52
+
53
+[node name="ScoreLabel" type="Label" parent="MarginContainer/VBoxContainer"]
54
+margin_top = 89.0
55
+margin_right = 1900.0
56
+margin_bottom = 150.0
36 57
 custom_fonts/font = SubResource( 1 )
37 58
 text = "99999"
38 59
 align = 1

Loading…
Cancel
Save