Improved crabs a lot

This commit is contained in:
Laurent Tourte
2023-02-22 16:43:55 +01:00
parent 86d2d7ecd0
commit b059b4b722
12 changed files with 173 additions and 92 deletions
+40 -8
View File
@@ -2,10 +2,13 @@ extends Node2D
class_name Minigame
@export var minigame_name: = "Minigame"
@export var max_number_of_lives: = 5 :
@export var max_number_of_lives: = 0 :
set(value): _set_max_lives(value)
get: return _max_number_of_lives
@export var start_kalulu_speech: AudioStream
@export var max_progression: = 0 :
set(value): _set_max_progression(value)
get: return _max_progression
@export var help_kalulu_speech: AudioStream
@export var win_kalulu_speech: AudioStream
@export var lose_kalulu_speech: AudioStream = preload("res://resources/minigames/kalulu/kalulu_lose_minigame_all.mp3")
@@ -36,9 +39,6 @@ var current_lives: = 0 :
var _current_lives: = 0
# Progression
var max_progression: = 0 :
set(value): _set_max_progression(value)
get: return _max_progression
var _max_progression: = 0
var current_progression: = 0 :
set(value): _set_current_progression(value)
@@ -63,6 +63,8 @@ func _initialize() -> void:
# Find and set the parameters of the minigame, like the number of lives or the victory conditions.
func _setup_minigame() -> void:
max_progression = max_progression
max_number_of_lives = max_number_of_lives
current_lives = max_number_of_lives
@@ -76,20 +78,34 @@ func _find_stimuli_and_distractions() -> void:
func _start() -> void:
opening_curtain.play("open")
await opening_curtain.animation_finished
minigame_ui.play_kalulu_speech(help_kalulu_speech)
await minigame_ui.kalulu_speech_end
# ------------ End ------------
func _reset() -> void:
_initialize()
opening_curtain.play("close")
await opening_curtain.animation_finished
get_tree().paused = false
get_tree().reload_current_scene()
func _win() -> void:
minigame_ui.play_kalulu_speech(win_kalulu_speech)
await minigame_ui.kalulu_speech_end
_reset()
func _lose() -> void:
minigame_ui.play_kalulu_speech(lose_kalulu_speech)
await minigame_ui.kalulu_speech_end
_reset()
# ------------ Logs ------------
@@ -108,6 +124,7 @@ func _reset_logs() -> void:
# Callbacks
func _go_back_to_the_garden() -> void:
return
@@ -117,14 +134,21 @@ func _play_stimulus() -> void:
func _pause_game() -> void:
get_tree().paused = not get_tree().paused
var pause: = not get_tree().paused
get_tree().paused = pause
minigame_ui.show_center_menu(pause)
func _play_kalulu() -> void:
return
get_tree().paused = true
minigame_ui.play_kalulu_speech(help_kalulu_speech)
await minigame_ui.kalulu_speech_end
get_tree().paused = false
# Connections
func _on_minigame_ui_garden_button_pressed() -> void:
_go_back_to_the_garden()
@@ -141,6 +165,10 @@ func _on_minigame_ui_kalulu_button_pressed() -> void:
_play_kalulu()
func _on_minigame_ui_restart_button_pressed() -> void:
_reset()
# ------------ setters/getters ------------
@@ -154,6 +182,8 @@ func _set_current_lives(value: int) -> void:
_current_lives = value
if minigame_ui:
minigame_ui.set_number_of_lives(value)
if current_lives == 0:
_lose()
func _set_max_progression(value: int) -> void:
@@ -166,3 +196,5 @@ func _set_current_progression(value: int) -> void:
_current_progression = value
if minigame_ui:
minigame_ui.set_current_progression(value)
if current_progression == max_progression:
_win()
@@ -22,4 +22,5 @@ process_mode = 1
[connection signal="kalulu_button_pressed" from="MinigameUI" to="." method="_on_minigame_ui_kalulu_button_pressed"]
[connection signal="kalulu_speech_end" from="MinigameUI" to="." method="_on_minigame_ui_kalulu_speech_end"]
[connection signal="pause_button_pressed" from="MinigameUI" to="." method="_on_minigame_ui_pause_button_pressed"]
[connection signal="restart_button_pressed" from="MinigameUI" to="." method="_on_minigame_ui_restart_button_pressed"]
[connection signal="stimulus_button_pressed" from="MinigameUI" to="." method="_on_minigame_ui_stimulus_button_pressed"]
+7 -1
View File
@@ -3,7 +3,7 @@ extends Control
signal kalulu_speech_end
@onready var kalulu_sprite: = $KaluluSprite
@onready var audio_player: = $AudioStreamPlayer2D
@onready var audio_player: = $AudioStreamPlayer
func _ready() -> void:
@@ -44,3 +44,9 @@ func _on_kalulu_sprite_animation_finished() -> void:
kalulu_sprite.play("Talk2")
else:
kalulu_sprite.play("Talk3")
func _on_pass_button_pressed() -> void:
if audio_player.playing:
audio_player.stop()
audio_player.finished.emit()
+47 -20
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=90 format=3 uid="uid://c4t2cq5vyj4ai"]
[gd_scene load_steps=95 format=3 uid="uid://c4t2cq5vyj4ai"]
[ext_resource type="Script" path="res://sources/minigames/base/kalulu.gd" id="1_iin3v"]
[ext_resource type="Texture2D" uid="uid://berypn513y7ts" path="res://resources/minigames/minigame_ui/graphic/kalulu/kalulu_hide_0000.png" id="2_v1p5p"]
@@ -128,9 +128,9 @@ animations = [{
"duration": 1.0,
"texture": ExtResource("13_ortja")
}],
"loop": true,
"loop": false,
"name": &"Hide",
"speed": 5.0
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
@@ -166,7 +166,7 @@ animations = [{
"duration": 1.0,
"texture": ExtResource("24_ashsp")
}],
"loop": true,
"loop": false,
"name": &"Idle1",
"speed": 12.0
}, {
@@ -207,9 +207,9 @@ animations = [{
"duration": 1.0,
"texture": ExtResource("36_3of4g")
}],
"loop": true,
"loop": false,
"name": &"Idle2",
"speed": 5.0
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
@@ -260,9 +260,9 @@ animations = [{
"duration": 1.0,
"texture": ExtResource("52_l5vw5")
}],
"loop": true,
"loop": false,
"name": &"Show",
"speed": 5.0
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
@@ -301,9 +301,9 @@ animations = [{
"duration": 1.0,
"texture": ExtResource("64_40vt6")
}],
"loop": true,
"loop": false,
"name": &"Talk1",
"speed": 5.0
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
@@ -342,9 +342,9 @@ animations = [{
"duration": 1.0,
"texture": ExtResource("76_70p70")
}],
"loop": true,
"loop": false,
"name": &"Talk2",
"speed": 5.0
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
@@ -383,11 +383,21 @@ animations = [{
"duration": 1.0,
"texture": ExtResource("88_gllhj")
}],
"loop": true,
"loop": false,
"name": &"Talk3",
"speed": 5.0
"speed": 12.0
}]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_y6gsq"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_1hd4y"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_dvlyl"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_cd4qd"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_iqd4x"]
[node name="Kalulu" type="Control"]
layout_mode = 3
anchors_preset = 15
@@ -407,13 +417,30 @@ grow_vertical = 2
color = Color(0.164706, 0.164706, 0.164706, 0.67451)
[node name="KaluluSprite" type="AnimatedSprite2D" parent="."]
position = Vector2(653, 1350)
position = Vector2(565, 1407)
scale = Vector2(1.5, 1.5)
frames = SubResource("SpriteFrames_igr4d")
animation = &"Talk3"
sprite_frames = SubResource("SpriteFrames_igr4d")
animation = &"Hide"
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
position = Vector2(653, 1421)
scale = Vector2(1.5, 1.5)
[node name="PassButton" type="Button" parent="KaluluSprite"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -135.0
offset_top = -146.0
offset_right = -165.0
offset_bottom = -381.0
grow_horizontal = 2
grow_vertical = 2
theme_override_styles/normal = SubResource("StyleBoxEmpty_y6gsq")
theme_override_styles/hover = SubResource("StyleBoxEmpty_1hd4y")
theme_override_styles/pressed = SubResource("StyleBoxEmpty_dvlyl")
theme_override_styles/disabled = SubResource("StyleBoxEmpty_cd4qd")
theme_override_styles/focus = SubResource("StyleBoxEmpty_iqd4x")
flat = true
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
bus = &"Voice"
[connection signal="animation_finished" from="KaluluSprite" to="." method="_on_kalulu_sprite_animation_finished"]
[connection signal="pressed" from="KaluluSprite/PassButton" to="." method="_on_pass_button_pressed"]
+34 -17
View File
@@ -6,6 +6,7 @@ signal stimulus_button_pressed
signal pause_button_pressed
signal kalulu_button_pressed
signal kalulu_speech_end
signal restart_button_pressed
@export var empty_progression_icon: Texture
@export var full_progression_icon: Texture
@@ -14,12 +15,14 @@ signal kalulu_speech_end
@onready var garden_button: TextureButton = get_node("%GardenButton")
@onready var stimulus_button: TextureButton = get_node("%StimulusButton")
@onready var pause_button: TextureButton = get_node("%PauseButton")
@onready var Kalulu_button: TextureButton = get_node("%KaluluButton")
@onready var kalulu_button: TextureButton = get_node("%KaluluButton")
@onready var empty_lives_rect: TextureRect = get_node("%EmptyLivesRect")
@onready var lives_rect: TextureRect = get_node("%LivesRect")
@onready var progression_gauge: NinePatchRect = get_node("%ProgressionGauge")
@onready var progression_empty_icons_rect: TextureRect = get_node("%ProgressionEmptyIconsRect")
@onready var progression_full_icons_rect: TextureRect = get_node("%ProgressionFullIconsRect")
@onready var center_menu: MarginContainer = get_node("%CenterMenu")
@onready var restart_button: TextureButton = get_node("%RestartButton")
# Kalulu
@onready var kalulu: = $MainControl/Kalulu
@@ -55,14 +58,14 @@ func lock() -> void:
garden_button.disabled = true
stimulus_button.disabled = true
pause_button.disabled = true
Kalulu_button.disabled = true
kalulu_button.disabled = true
func unlock() -> void:
garden_button.disabled = false
stimulus_button.disabled = false
pause_button.disabled = false
Kalulu_button.disabled = false
kalulu_button.disabled = false
# ------------ Lives ------------
@@ -70,18 +73,18 @@ func unlock() -> void:
func set_maximum_number_of_lives(new_max_number_of_lives: int) -> void:
empty_lives_rect.custom_minimum_size.x = new_max_number_of_lives * empty_life_size
if new_max_number_of_lives == 0:
empty_lives_rect.scale.x = 0
if new_max_number_of_lives <= 0:
empty_lives_rect.visible = false
else:
empty_lives_rect.scale.x = 1
empty_lives_rect.visible = true
func set_number_of_lives(new_number_of_lives: int) -> void:
lives_rect.custom_minimum_size.x = new_number_of_lives * life_size
if new_number_of_lives == 0:
lives_rect.scale.x = 0
if new_number_of_lives <= 0:
lives_rect.visible = false
else:
lives_rect.scale.x = 1
lives_rect.visible = true
# ------------ Progression ------------
@@ -90,21 +93,21 @@ func set_number_of_lives(new_number_of_lives: int) -> void:
func set_max_progression(new_max_progression: int) -> void:
progression_gauge.custom_minimum_size.y = new_max_progression * progression_gauge_unit_size
progression_empty_icons_rect.custom_minimum_size.y = new_max_progression * progression_gauge_unit_size
if new_max_progression == 0:
progression_empty_icons_rect.scale.y = 0
if new_max_progression <= 0:
progression_empty_icons_rect.visible = false
else:
progression_empty_icons_rect.scale.y = 1
progression_empty_icons_rect.visible = true
func set_current_progression(new_current_progression: int) -> void:
progression_full_icons_rect.custom_minimum_size.y = new_current_progression * progression_full_icon_size
if new_current_progression == 0:
progression_full_icons_rect.scale.y = 0
if new_current_progression <= 0:
progression_full_icons_rect.visible = false
else:
progression_full_icons_rect.scale.y = 1
progression_full_icons_rect.visible = true
# ------------ Actions ------------
# ------------ Left Panel ------------
func _on_garden_button_pressed() -> void:
@@ -123,6 +126,20 @@ func _on_kalulu_button_pressed() -> void:
kalulu_button_pressed.emit()
# ------------ Center Menu ------------
func show_center_menu(show_menu: bool) -> void:
center_menu.visible = show_menu
garden_button.disabled = show_menu
stimulus_button.disabled = show_menu
kalulu_button.disabled = show_menu
func _on_restart_button_pressed() -> void:
restart_button_pressed.emit()
# ------------ Kalulu ------------
@@ -131,4 +148,4 @@ func play_kalulu_speech(speech: AudioStream) -> void:
func _on_kalulu_kalulu_speech_end() -> void:
emit_signal("kalulu_speech_end")
kalulu_speech_end.emit()
+25 -6
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=25 format=3 uid="uid://weree6bnlt6f"]
[gd_scene load_steps=26 format=3 uid="uid://weree6bnlt6f"]
[ext_resource type="Script" path="res://sources/minigames/base/minigame_ui.gd" id="1_g5fl4"]
[ext_resource type="Texture2D" uid="uid://dj0ygi5q6kbdw" path="res://resources/minigames/minigame_ui/graphic/button_back_to_menu_up.png" id="2_0d0qn"]
@@ -18,6 +18,7 @@
[ext_resource type="Texture2D" uid="uid://3om2awlftpxd" path="res://resources/minigames/minigame_ui/graphic/life.png" id="15_rxfiu"]
[ext_resource type="Texture2D" uid="uid://f2ys2fy1il2k" path="res://resources/minigames/minigame_ui/graphic/popin_frontground.png" id="15_w2rjo"]
[ext_resource type="Texture2D" uid="uid://dqtmyedk1ylbw" path="res://resources/minigames/minigame_ui/graphic/button_replay_up.png" id="16_eao58"]
[ext_resource type="Texture2D" uid="uid://b6b8kb5l3yh04" path="res://resources/minigames/minigame_ui/graphic/large_flower_body.png" id="16_kd3me"]
[ext_resource type="Texture2D" uid="uid://dxqnvbr4tffn7" path="res://resources/minigames/minigame_ui/graphic/gauge.png" id="16_m3nil"]
[ext_resource type="Texture2D" uid="uid://cfxpnn3uivakv" path="res://resources/minigames/minigame_ui/graphic/gauge_icon_ant_empty.png" id="17_bqwcj"]
[ext_resource type="Texture2D" uid="uid://bvu8ud6hkwusb" path="res://resources/minigames/minigame_ui/graphic/button_replay_down.png" id="17_emg5g"]
@@ -122,6 +123,7 @@ theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 20
[node name="CenterMenu" type="MarginContainer" parent="MainControl/Interface/CentralPadMargin"]
unique_name_in_owner = true
visible = false
layout_mode = 2
theme_override_constants/margin_left = 450
@@ -146,19 +148,35 @@ texture = ExtResource("15_w2rjo")
[node name="MarginContainer2" type="MarginContainer" parent="MainControl/Interface/CentralPadMargin/CenterMenu"]
layout_mode = 2
theme_override_constants/margin_left = 42
theme_override_constants/margin_top = 42
theme_override_constants/margin_right = 42
theme_override_constants/margin_bottom = 42
theme_override_constants/margin_left = 92
theme_override_constants/margin_top = 92
theme_override_constants/margin_right = 92
theme_override_constants/margin_bottom = 92
[node name="Background" type="Control" parent="MainControl/Interface/CentralPadMargin/CenterMenu/MarginContainer2"]
modulate = Color(1, 1, 1, 0.396078)
layout_mode = 2
[node name="TextureRect" type="TextureRect" parent="MainControl/Interface/CentralPadMargin/CenterMenu/MarginContainer2/Background"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("16_kd3me")
stretch_mode = 5
[node name="VBoxContainer" type="VBoxContainer" parent="MainControl/Interface/CentralPadMargin/CenterMenu/MarginContainer2"]
layout_mode = 2
alignment = 2
[node name="MarginContainer" type="MarginContainer" parent="MainControl/Interface/CentralPadMargin/CenterMenu/MarginContainer2/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 8
[node name="TextureButton" type="TextureButton" parent="MainControl/Interface/CentralPadMargin/CenterMenu/MarginContainer2/VBoxContainer/MarginContainer"]
[node name="RestartButton" type="TextureButton" parent="MainControl/Interface/CentralPadMargin/CenterMenu/MarginContainer2/VBoxContainer/MarginContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 8
@@ -254,4 +272,5 @@ layout_mode = 1
[connection signal="pressed" from="MainControl/Interface/LeftMargin/LeftContainer/StimulusMargin/StimulusButton" to="." method="_on_stimulus_button_pressed"]
[connection signal="pressed" from="MainControl/Interface/LeftMargin/LeftContainer/PauseMargin/PauseButton" to="." method="_on_pause_button_pressed"]
[connection signal="pressed" from="MainControl/Interface/LeftMargin/LeftContainer/KaluluButton" to="." method="_on_kalulu_button_pressed"]
[connection signal="pressed" from="MainControl/Interface/CentralPadMargin/CenterMenu/MarginContainer2/VBoxContainer/MarginContainer/RestartButton" to="." method="_on_restart_button_pressed"]
[connection signal="kalulu_speech_end" from="MainControl/Kalulu" to="." method="_on_kalulu_kalulu_speech_end"]
+6 -8
View File
@@ -56,7 +56,6 @@ tracks/3/keys = {
[sub_resource type="Animation" id="Animation_qqx6p"]
resource_name = "close"
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
@@ -64,7 +63,7 @@ tracks/0/path = NodePath("LeftCurtain:visible")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.5),
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [true, true]
@@ -88,7 +87,7 @@ tracks/2/path = NodePath("RightCurtain:visible")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 0.5),
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [true, true]
@@ -108,7 +107,6 @@ tracks/3/keys = {
[sub_resource type="Animation" id="Animation_24r35"]
resource_name = "open"
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
@@ -116,7 +114,7 @@ tracks/0/path = NodePath("LeftCurtain:visible")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.5),
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [true, false]
@@ -128,7 +126,7 @@ tracks/1/path = NodePath("LeftCurtain:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.5),
"times": PackedFloat32Array(0.5, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [2.35619, 4.71239]
@@ -140,7 +138,7 @@ tracks/2/path = NodePath("RightCurtain:visible")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 0.5),
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [true, false]
@@ -152,7 +150,7 @@ tracks/3/path = NodePath("RightCurtain:rotation")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0, 0.5),
"times": PackedFloat32Array(0.5, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [-2.35619, -4.71239]
+1 -22
View File
@@ -24,7 +24,6 @@ func _setup_minigame() -> void:
super._setup_minigame()
# Progression management
max_progression = 10
current_progression = 0
var max_difficulty: = 0
@@ -67,7 +66,7 @@ func _find_stimuli_and_distractions() -> void:
# Launch the minigame
func _start() -> void:
super._start()
await super._start()
_on_hole_timer_timeout(stimuli[0])
@@ -121,23 +120,3 @@ func _save_logs() -> void:
func _reset_logs() -> void:
logs = {}
# ------------ UI ------------
# Callbacks
func _go_back_to_the_garden() -> void:
return
func _play_stimulus() -> void:
return
func _pause_game() -> void:
get_tree().paused = not get_tree().paused
func _play_kalulu() -> void:
return
+3 -1
View File
@@ -12,7 +12,9 @@
script = ExtResource("2_gierf")
difficulty = 4
minigame_name = "Crabs"
start_kalulu_speech = ExtResource("3_vtu3m")
max_number_of_lives = 5
max_progression = 10
help_kalulu_speech = ExtResource("3_vtu3m")
win_kalulu_speech = ExtResource("4_eh4op")
[node name="MinigameUI" parent="." index="0"]