mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2025-04-29 16:53:55 +02:00
Badges when you don't use cards
This commit is contained in:
parent
e87e29a3ed
commit
aed852122b
10 changed files with 278 additions and 12 deletions
|
@ -136,6 +136,7 @@ func try_play(full_command):
|
|||
var terminal = $"../../../..".terminal
|
||||
terminal.send_command(full_command)
|
||||
#yield(terminal, "command_done")
|
||||
game.used_cards = true
|
||||
$PlaySound.play()
|
||||
var particles = preload("res://scenes/card_particles.tscn").instance()
|
||||
particles.position = position
|
||||
|
|
21
scenes/cli_badge.gd
Normal file
21
scenes/cli_badge.gd
Normal file
|
@ -0,0 +1,21 @@
|
|||
extends TextureRect
|
||||
|
||||
export var active = true setget _set_active
|
||||
export var sparkling = true setget _set_sparkling
|
||||
|
||||
|
||||
func _ready():
|
||||
_set_sparkling(sparkling)
|
||||
|
||||
func _set_active(new_active):
|
||||
active = new_active
|
||||
if active:
|
||||
self.modulate = Color(1, 1, 1)
|
||||
else:
|
||||
self.modulate = Color(0.2, 0.2, 0.2)
|
||||
sparkling = false
|
||||
|
||||
func _set_sparkling(new_sparkling):
|
||||
sparkling = new_sparkling
|
||||
if $Particles2D:
|
||||
$Particles2D.emitting = sparkling
|
45
scenes/cli_badge.tscn
Normal file
45
scenes/cli_badge.tscn
Normal file
|
@ -0,0 +1,45 @@
|
|||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://images/cli-badge.svg" type="Texture" id=1]
|
||||
[ext_resource path="res://scenes/cli_badge.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="Curve" id=2]
|
||||
_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ]
|
||||
|
||||
[sub_resource type="CurveTexture" id=3]
|
||||
curve = SubResource( 2 )
|
||||
|
||||
[sub_resource type="ParticlesMaterial" id=1]
|
||||
emission_shape = 2
|
||||
emission_box_extents = Vector3( 20, 20, 1 )
|
||||
flag_disable_z = true
|
||||
spread = 180.0
|
||||
gravity = Vector3( 0, 0, 0 )
|
||||
initial_velocity = 75.0
|
||||
initial_velocity_random = 0.47
|
||||
orbit_velocity = 0.0
|
||||
orbit_velocity_random = 0.0
|
||||
scale = 7.25
|
||||
scale_curve = SubResource( 3 )
|
||||
color = Color( 0.913725, 0.913725, 0.447059, 1 )
|
||||
|
||||
[node name="CLIBadge" type="TextureRect"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_min_size = Vector2( 45, 0 )
|
||||
size_flags_stretch_ratio = 0.0
|
||||
texture = ExtResource( 1 )
|
||||
expand = true
|
||||
stretch_mode = 6
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Particles2D" type="Particles2D" parent="."]
|
||||
show_behind_parent = true
|
||||
position = Vector2( 21.7701, 14.5133 )
|
||||
z_index = 1
|
||||
amount = 3
|
||||
randomness = 0.34
|
||||
process_material = SubResource( 1 )
|
|
@ -6,6 +6,7 @@ var fake_editor
|
|||
|
||||
var dragged_object
|
||||
var energy = 2
|
||||
var used_cards = false
|
||||
|
||||
var current_chapter = 0
|
||||
var current_level = 0
|
||||
|
@ -28,7 +29,7 @@ func copy_script_to_game_env(name):
|
|||
global_shell.run("chmod u+x '%s'" % (tmp_prefix + name))
|
||||
|
||||
func _initial_state():
|
||||
return {"history": [], "solved_levels": [], "received_hints": []}
|
||||
return {"history": [], "solved_levels": [], "received_hints": [], "cli_badge": []}
|
||||
|
||||
func save_state():
|
||||
var savegame = File.new()
|
||||
|
|
|
@ -32,16 +32,28 @@ func reload():
|
|||
level_list.add_child(l)
|
||||
|
||||
for level in chapter.levels:
|
||||
var hb = HBoxContainer.new()
|
||||
|
||||
var b = Button.new()
|
||||
b.text = level.title
|
||||
b.align = HALIGN_LEFT
|
||||
b.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
|
||||
b.connect("pressed", self, "load", [chapter_id, level_id])
|
||||
var slug = chapter.slug + "/" + level.slug
|
||||
if slug in game.state["solved_levels"]:
|
||||
b.set("custom_colors/font_color", Color(0.1, 0.8, 0.1, 1))
|
||||
b.set("custom_colors/font_color_hover", Color(0.1, 0.8, 0.1, 1))
|
||||
b.set("custom_colors/font_color_pressed", Color(0.1, 0.8, 0.1, 1))
|
||||
level_list.add_child(b)
|
||||
|
||||
hb.add_child(b)
|
||||
#
|
||||
var badge = preload("res://scenes/cli_badge.tscn").instance()
|
||||
hb.add_child(badge)
|
||||
badge.active = slug in game.state["cli_badge"]
|
||||
badge.sparkling = false
|
||||
|
||||
level_list.add_child(hb)
|
||||
level_id += 1
|
||||
|
||||
chapter_id += 1
|
||||
|
|
|
@ -52,5 +52,9 @@ text = "Reload"
|
|||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Button2"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
[connection signal="pressed" from="Button" to="." method="back"]
|
||||
[connection signal="pressed" from="Button2" to="." method="reload"]
|
||||
|
|
|
@ -50,7 +50,8 @@ func _process(delta):
|
|||
var length = _hint_client_connection.get_u32()
|
||||
var message = _hint_client_connection.get_string(length)
|
||||
game.notify(message)
|
||||
|
||||
if game.used_cards:
|
||||
$Menu/CLIBadge.active = false
|
||||
|
||||
func load_chapter(id):
|
||||
game.current_chapter = id
|
||||
|
@ -61,6 +62,9 @@ func load_level(level_id):
|
|||
level_congrats.hide()
|
||||
level_description.show()
|
||||
game.current_level = level_id
|
||||
game.used_cards = false
|
||||
$Menu/CLIBadge.active = true
|
||||
$Menu/CLIBadge.sparkling = false
|
||||
|
||||
AudioServer.set_bus_mute(AudioServer.get_bus_index("Master"), true)
|
||||
|
||||
|
@ -169,12 +173,14 @@ func show_win_status(win_states):
|
|||
level_description.hide()
|
||||
level_congrats.show()
|
||||
$SuccessSound.play()
|
||||
if not game.state.has("solved_levels"):
|
||||
game.state["solved_levels"] = []
|
||||
var slug = levels.chapters[game.current_chapter].slug + "/" + level.slug
|
||||
if not slug in game.state["solved_levels"]:
|
||||
game.state["solved_levels"].push_back(slug)
|
||||
game.save_state()
|
||||
if not game.used_cards and not slug in game.state["cli_badge"]:
|
||||
game.state["cli_badge"].push_back(slug)
|
||||
game.save_state()
|
||||
$Menu/CLIBadge.sparkling = true
|
||||
|
||||
#func repopulate_levels():
|
||||
# levels.reload()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=12 format=2]
|
||||
[gd_scene load_steps=13 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/terminal.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://scenes/main.gd" type="Script" id=2]
|
||||
|
@ -9,11 +9,12 @@
|
|||
[ext_resource path="res://fonts/big.tres" type="DynamicFont" id=7]
|
||||
[ext_resource path="res://sounds/success.wav" type="AudioStream" id=8]
|
||||
[ext_resource path="res://scenes/cursor.gd" type="Script" id=9]
|
||||
[ext_resource path="res://scenes/cli_badge.tscn" type="PackedScene" id=10]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=2]
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
radius = 1.0
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
[sub_resource type="StyleBoxFlat" id=2]
|
||||
content_margin_left = 10.0
|
||||
content_margin_right = 10.0
|
||||
content_margin_top = 5.0
|
||||
|
@ -189,7 +190,7 @@ collision_layer = 524288
|
|||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Cursor/Area2D"]
|
||||
shape = SubResource( 2 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Menu" type="HBoxContainer" parent="."]
|
||||
margin_left = 3.86392
|
||||
|
@ -246,12 +247,19 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="NextLevelButton" type="Button" parent="Menu"]
|
||||
[node name="CLIBadge" parent="Menu" instance=ExtResource( 10 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 169.0
|
||||
margin_right = 286.0
|
||||
margin_right = 214.0
|
||||
margin_bottom = 39.0
|
||||
|
||||
[node name="NextLevelButton" type="Button" parent="Menu"]
|
||||
margin_left = 222.0
|
||||
margin_right = 339.0
|
||||
margin_bottom = 39.0
|
||||
focus_mode = 0
|
||||
custom_styles/hover = SubResource( 1 )
|
||||
custom_styles/hover = SubResource( 2 )
|
||||
custom_styles/normal = ExtResource( 4 )
|
||||
enabled_focus_mode = 0
|
||||
text = "Next level"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue