Show the current state of the badge in a level, instead of the future one

This commit is contained in:
blinry 2021-02-18 16:44:04 +01:00
parent 21f55fd705
commit 94462e9123
3 changed files with 23 additions and 6 deletions

View file

@ -2,6 +2,7 @@ extends TextureRect
export var active = true setget _set_active export var active = true setget _set_active
export var sparkling = true setget _set_sparkling export var sparkling = true setget _set_sparkling
export var impossible = false setget _set_impossible
func _ready(): func _ready():
@ -10,12 +11,16 @@ func _ready():
func _set_active(new_active): func _set_active(new_active):
active = new_active active = new_active
if active: if active:
self.modulate = Color(1, 1, 1) self.self_modulate = Color(1, 1, 1)
else: else:
self.modulate = Color(0.2, 0.2, 0.2) self.self_modulate = Color(0.2, 0.2, 0.2)
sparkling = false sparkling = false
func _set_sparkling(new_sparkling): func _set_sparkling(new_sparkling):
sparkling = new_sparkling sparkling = new_sparkling
if $Particles2D: if $Particles2D:
$Particles2D.emitting = sparkling $Particles2D.emitting = sparkling
func _set_impossible(new_impossible):
impossible = new_impossible
$Nope.visible = impossible

View file

@ -43,3 +43,11 @@ z_index = 1
amount = 3 amount = 3
randomness = 0.34 randomness = 0.34
process_material = SubResource( 3 ) process_material = SubResource( 3 )
[node name="Nope" type="Line2D" parent="."]
visible = false
position = Vector2( 22.4111, 18.7121 )
scale = Vector2( 1.32773, 1.32773 )
points = PoolVector2Array( -16.448, 11.5553, 16.0161, -12.8519 )
width = 5.0
default_color = Color( 0.0705882, 0.0705882, 0.0705882, 1 )

View file

@ -50,8 +50,8 @@ func _process(delta):
var length = _hint_client_connection.get_u32() var length = _hint_client_connection.get_u32()
var message = _hint_client_connection.get_string(length) var message = _hint_client_connection.get_string(length)
game.notify(message) game.notify(message)
if game.used_cards: # if game.used_cards:
$Menu/CLIBadge.active = false # $Menu/CLIBadge.impossible = true
# Magic height number to fix a weird rescaling bug that affected # Magic height number to fix a weird rescaling bug that affected
# the Rows height. # the Rows height.
@ -67,8 +67,6 @@ func load_level(level_id):
level_description.show() level_description.show()
game.current_level = level_id game.current_level = level_id
game.used_cards = false game.used_cards = false
$Menu/CLIBadge.active = true
$Menu/CLIBadge.sparkling = false
AudioServer.set_bus_mute(AudioServer.get_bus_index("SFX"), true) AudioServer.set_bus_mute(AudioServer.get_bus_index("SFX"), true)
@ -78,6 +76,11 @@ func load_level(level_id):
level_description.bbcode_text = level.description[0] level_description.bbcode_text = level.description[0]
level_congrats.bbcode_text = level.congrats level_congrats.bbcode_text = level.congrats
level_name.text = level.title level_name.text = level.title
var slug = levels.chapters[game.current_chapter].slug + "/" + level.slug
$Menu/CLIBadge.active = slug in game.state["cli_badge"]
$Menu/CLIBadge.sparkling = false
#if levels.chapters[game.current_chapter].levels[game.current_level].cards.size() == 0: #if levels.chapters[game.current_chapter].levels[game.current_level].cards.size() == 0:
# cards.redraw_all_cards() # cards.redraw_all_cards()
#else: #else:
@ -184,6 +187,7 @@ func show_win_status(win_states):
if not game.used_cards and not slug in game.state["cli_badge"]: if not game.used_cards and not slug in game.state["cli_badge"]:
game.state["cli_badge"].push_back(slug) game.state["cli_badge"].push_back(slug)
game.save_state() game.save_state()
$Menu/CLIBadge.active = true
$Menu/CLIBadge.sparkling = true $Menu/CLIBadge.sparkling = true
#func repopulate_levels(): #func repopulate_levels():