Fixes crabs labels. Fixes a bug that made the game crash when there were no current lesson stimuli for words and syllables minigames.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -29,11 +29,13 @@ func _start() -> void:
|
||||
# Find the stimuli and distractions of the minigame.
|
||||
# For this type of minigame, only vowels and syllables are allowed
|
||||
func _find_stimuli_and_distractions() -> void:
|
||||
var all_syllables: = Database.get_syllables_for_lesson(lesson_nb, false)
|
||||
if not all_syllables:
|
||||
return
|
||||
|
||||
var current_lesson_stimuli: Array[Dictionary] = []
|
||||
var previous_lesson_stimuli: Array[Dictionary] = []
|
||||
|
||||
var all_syllables: = Database.get_syllables_for_lesson(lesson_nb, false)
|
||||
|
||||
# Find the syllables for current lesson
|
||||
for syllable: Dictionary in all_syllables:
|
||||
if syllable.LessonNb == lesson_nb:
|
||||
@@ -41,8 +43,6 @@ func _find_stimuli_and_distractions() -> void:
|
||||
else:
|
||||
previous_lesson_stimuli.append(syllable)
|
||||
|
||||
if not current_lesson_stimuli and not previous_lesson_stimuli:
|
||||
return
|
||||
|
||||
# Shuffle everything
|
||||
current_lesson_stimuli.shuffle()
|
||||
@@ -57,20 +57,20 @@ func _find_stimuli_and_distractions() -> void:
|
||||
while stimuli.size() < max_progression:
|
||||
stimuli.append(current_lesson_stimuli.pick_random())
|
||||
else:
|
||||
|
||||
# If there are more stimuli in current lesson than needed
|
||||
if current_lesson_stimuli.size() >= current_lesson_stimuli_number:
|
||||
for i in current_lesson_stimuli_number:
|
||||
stimuli.append(current_lesson_stimuli[i])
|
||||
else:
|
||||
stimuli.append_array(current_lesson_stimuli)
|
||||
|
||||
# We if there are not enough stimuli from current lesson, we want at least half the target number of stimuli
|
||||
@warning_ignore("integer_division")
|
||||
var minimal_stimuli : int = current_lesson_stimuli_number/2
|
||||
if stimuli.size() < minimal_stimuli:
|
||||
while stimuli.size() < minimal_stimuli:
|
||||
stimuli.append(current_lesson_stimuli.pick_random())
|
||||
if current_lesson_stimuli:
|
||||
# If there are more stimuli in current lesson than needed
|
||||
if current_lesson_stimuli.size() >= current_lesson_stimuli_number:
|
||||
for i in current_lesson_stimuli_number:
|
||||
stimuli.append(current_lesson_stimuli[i])
|
||||
else:
|
||||
stimuli.append_array(current_lesson_stimuli)
|
||||
|
||||
# We if there are not enough stimuli from current lesson, we want at least half the target number of stimuli
|
||||
@warning_ignore("integer_division")
|
||||
var minimal_stimuli : int = current_lesson_stimuli_number/2
|
||||
if stimuli.size() < minimal_stimuli:
|
||||
while stimuli.size() < minimal_stimuli:
|
||||
stimuli.append(current_lesson_stimuli.pick_random())
|
||||
|
||||
# Gets other stimuli from previous errors or lessons
|
||||
var spaces_left : int = max_progression - stimuli.size()
|
||||
@@ -80,9 +80,12 @@ func _find_stimuli_and_distractions() -> void:
|
||||
else:
|
||||
stimuli.append_array(previous_lesson_stimuli)
|
||||
|
||||
# If there are not enough stimuli, fill the rest with current lesson
|
||||
# If there are not enough stimuli, fill the rest with current lesson or previous lesson
|
||||
while stimuli.size() < max_progression:
|
||||
stimuli.append(current_lesson_stimuli.pick_random())
|
||||
if current_lesson_stimuli:
|
||||
stimuli.append(current_lesson_stimuli.pick_random())
|
||||
else:
|
||||
stimuli.append(previous_lesson_stimuli.pick_random())
|
||||
|
||||
# Shuffle the stimuli
|
||||
stimuli.shuffle()
|
||||
|
||||
@@ -16,10 +16,10 @@ var current_gp_distractors_queue: Array[Dictionary] = []
|
||||
# Find the stimuli and distractions of the minigame.
|
||||
func _find_stimuli_and_distractions() -> void:
|
||||
# Get the currently known words list
|
||||
var words_list: = Database.get_words_for_lesson(lesson_nb, false, 2, max_number_of_GPs)
|
||||
|
||||
var words_list: = Database.get_words_for_lesson(lesson_nb, false, max_number_of_GPs)
|
||||
if words_list.is_empty():
|
||||
return
|
||||
|
||||
var current_lesson_words: = []
|
||||
var previous_lesson_words: = []
|
||||
|
||||
@@ -64,10 +64,13 @@ func _find_stimuli_and_distractions() -> void:
|
||||
else:
|
||||
stimuli.append_array(previous_lesson_words)
|
||||
|
||||
# If there are not enough stimuli, fill the rest with current lesson
|
||||
# If there are not enough stimuli, fill the rest with current lesson or previous lesson
|
||||
if current_lesson_words:
|
||||
while stimuli.size() < max_progression:
|
||||
stimuli.append(current_lesson_words.pick_random())
|
||||
if current_lesson_words:
|
||||
stimuli.append(current_lesson_words.pick_random())
|
||||
else:
|
||||
stimuli.append(previous_lesson_words.pick_random())
|
||||
|
||||
# Shuffle the stimuli
|
||||
stimuli.shuffle()
|
||||
|
||||
@@ -47,6 +47,16 @@ func is_button_pressed() -> bool:
|
||||
return true
|
||||
|
||||
|
||||
func show_label() -> void:
|
||||
var tween: = create_tween()
|
||||
tween.tween_property(label, "modulate:a", 1, .5)
|
||||
|
||||
|
||||
func hide_label() -> void:
|
||||
var tween: = create_tween()
|
||||
tween.tween_property(label, "modulate:a", 0, .5)
|
||||
|
||||
|
||||
func highlight() -> void:
|
||||
highlight_fx.play()
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=37 format=3 uid="uid://bwe3fp0vkpufb"]
|
||||
|
||||
[ext_resource type="Script" path="res://sources/minigames/crabs/crab/crab.gd" id="1_5hgg8"]
|
||||
[ext_resource type="AudioStream" uid="uid://bm8mtyr34o1ac" path="res://assets/minigames/crabs/audio/sfx/crab_random_11.mp3" id="2_cdi6k"]
|
||||
[ext_resource type="AudioStream" uid="uid://ckylhqy1pwifv" path="res://assets/minigames/crabs/audio/sfx/crab_random_5.mp3" id="2_xwmhe"]
|
||||
[ext_resource type="Texture2D" uid="uid://c36217nu30yh3" path="res://assets/minigames/crabs/graphic/crab_spritesheet.png" id="2_yu4q0"]
|
||||
[ext_resource type="Script" path="res://sources/utils/sprite_control.gd" id="3_e1twq"]
|
||||
[ext_resource type="PackedScene" uid="uid://cge0uyn30tcpv" path="res://sources/utils/fx/highlight.tscn" id="3_is4em"]
|
||||
@@ -205,7 +205,11 @@ offset_bottom = 320.0
|
||||
script = ExtResource("1_5hgg8")
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
<<<<<<< HEAD
|
||||
stream = ExtResource("2_cdi6k")
|
||||
=======
|
||||
stream = ExtResource("2_xwmhe")
|
||||
>>>>>>> 04d47596 (Fixes crabs labels. Fixes a bug that made the game crash when there were no current lesson stimuli for words and syllables minigames.)
|
||||
volume_db = -3.0
|
||||
stream_paused = true
|
||||
bus = &"Effects"
|
||||
@@ -267,7 +271,11 @@ scale = Vector2(1.79512, 1.78771)
|
||||
sprite_frames = SubResource("SpriteFrames_g5q5i")
|
||||
animation = &"idle1"
|
||||
autoplay = "idle1"
|
||||
<<<<<<< HEAD
|
||||
frame_progress = 0.0391599
|
||||
=======
|
||||
frame_progress = 0.791477
|
||||
>>>>>>> 04d47596 (Fixes crabs labels. Fixes a bug that made the game crash when there were no current lesson stimuli for words and syllables minigames.)
|
||||
centered = false
|
||||
offset = Vector2(-5, 0)
|
||||
|
||||
@@ -275,7 +283,7 @@ offset = Vector2(-5, 0)
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.23913
|
||||
anchor_top = 0.4
|
||||
anchor_top = 0.265625
|
||||
anchor_right = 0.76087
|
||||
anchor_bottom = 0.859375
|
||||
grow_horizontal = 2
|
||||
|
||||
@@ -66,6 +66,9 @@ func spawn_crab(stimulus: Dictionary) -> void:
|
||||
# Instantiate a new crab
|
||||
crab = crab_scene.instantiate()
|
||||
mask.add_child(crab)
|
||||
|
||||
crab.hide_label()
|
||||
|
||||
crab_x = -crab.size.x / 2
|
||||
crab.position = Vector2(crab_x, crab.size.y)
|
||||
crab.stimulus = stimulus
|
||||
@@ -82,6 +85,7 @@ func spawn_crab(stimulus: Dictionary) -> void:
|
||||
return
|
||||
|
||||
# The crab gets completely out
|
||||
crab.show_label()
|
||||
crab_out.emit()
|
||||
tween = create_tween()
|
||||
tween.tween_property(crab, "position", Vector2(crab_x, -crab.size.y), 0.5)
|
||||
|
||||
Reference in New Issue
Block a user