Skip to content

Commit

Permalink
Add achievment
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonCat4012 committed Sep 17, 2024
1 parent 9e233db commit 9322187
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 27 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Play together to solve numbers
| Plattform | Status | Supported | Tested |
|--------------|:-----:| :----: | :----: |
| iOS | Testflight | :heavy_check_mark: | :heavy_check_mark:
| MacOS | Testflight | :heavy_check_mark:| :x:
| MacOS | Testflight | ???| :x:
| Android | WIP | :heavy_check_mark: | :heavy_check_mark:
| Windows | WIP | :heavy_check_mark:| :heavy_check_mark:

Expand All @@ -56,10 +56,10 @@ Each lamp becomes a random switch assigned, one random lamps becomes a second ra

```mermaid
graph TD;
A[Lamp 1] --- B[Switch 1];
A[Lamp 1] --- C[Switch 2];
D[Lamp 2] --- F[Switch 3];
E[Lamp 3] --- G[Switch 4];
A[Lamp 1] --- B[Switch 1];
A[Lamp 1] --- C[Switch 2];
D[Lamp 2] --- F[Switch 3];
E[Lamp 3] --- G[Switch 4];
```

#### Drawing Wires
Expand All @@ -86,11 +86,11 @@ block-beta
space space P3'
P0("P0") --- P0'("P0'")
P0'("P0'") --- P1("P1")
P1("P1") --- P2("P2")
P2("P2") ---P3("P3")
P3("P3") ---P3'("P3'")
P0("P0") --- P0'("P0'")
P0'("P0'") --- P1("P1")
P1("P1") --- P2("P2")
P2("P2") ---P3("P3")
P3("P3") ---P3'("P3'")
```

<img src="https://kiarar.moe/images/Switch/map1.png" height= 300>
Expand Down
33 changes: 19 additions & 14 deletions Scenes/Achievments.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ const AchievementsHandler = preload("res://Util/AchievementHandler.gd")
@onready var a8 := $MarginContainer/ScrollContainer/VBoxContainer/Loose10Times/Label
@onready var a9 := $MarginContainer/ScrollContainer/VBoxContainer/Loose100Times/Label
@onready var a10 := $MarginContainer/ScrollContainer/VBoxContainer/WinKoop/Label
@onready var a11 = $MarginContainer/ScrollContainer/VBoxContainer/PlayKoop/Label

var white = Color(1.0,1.0,1.0,1.0)
var gray = Color(1.0,1.0,1.0,0.3)

func _ready():
_setLabels()

Expand All @@ -22,11 +26,11 @@ func _process(_delta):
get_tree().change_scene_to_file("res://Scenes/menu.tscn")

func _setLabels():
var labels = [a1,a2,a3,a4,a5,a6,a7,a8,a9,a10]
var white = Color(1.0,1.0,1.0,1.0)
var gray = Color(1.0,1.0,1.0,0.3)
var labels = [a1,a2,a3,a4,a5,a6,a7,a8,a9,a10, a11]

for l in labels:
l.set("theme_override_colors/font_color", gray)
if l is Label:
_update_label(l, "?", gray)

if achievementHandler.found128:
a1.text = "Find the hidden number - 128"
Expand All @@ -45,17 +49,18 @@ func _setLabels():
a5.set("theme_override_colors/font_color", white)

if achievementHandler.won10:
a6.text = "Solve 10 Maps"
a6.set("theme_override_colors/font_color", white)
_update_label(a6, "Solve 10 Maps", white)
if achievementHandler.won100:
a7.text = "Solve 100 Maps"
a7.set("theme_override_colors/font_color", white)
_update_label(a7, "Solve 100 Map", white)
if achievementHandler.lost10:
a8.text = "Loose 10 Times"
a8.set("theme_override_colors/font_color", white)
_update_label(a8, "Loose 10 Times", white)
if achievementHandler.lost100:
a9.text = "Skill Issue - Loose 100 Times"
a9.set("theme_override_colors/font_color", white)
_update_label(a9, "Skill Issue - Loose 100 Times", white)
if achievementHandler.winKoop:
a10.text = "Team Player - Win a multiplayer map"
a10.set("theme_override_colors/font_color", white)
_update_label(a10, "Team Player - Win a multiplayer map", white)
if achievementHandler.playKoop:
_update_label(a11, "Play a coop game", white)

func _update_label(label: Label, text: String, color: Color):
label.text = text
label.set("theme_override_colors/font_color", color)
3 changes: 2 additions & 1 deletion Scenes/Achievments.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[ext_resource type="Script" path="res://Scenes/Achievments.gd" id="1_0xukb"]
[ext_resource type="FontFile" uid="uid://b2cswqm32sj5f" path="res://Ressources/Lex.ttf" id="1_d44rw"]
[ext_resource type="PackedScene" uid="uid://67ks36ginjia" path="res://Sprites/BackButtonScene.tscn" id="4_k05nl"]
[ext_resource type="PackedScene" path="res://Sprites/BackButtonScene.tscn" id="4_k05nl"]

[node name="Achievments" type="Node2D"]
script = ExtResource("1_0xukb")
Expand Down Expand Up @@ -129,6 +129,7 @@ theme_override_font_sizes/font_size = 50
text = "?"

[node name="PlayKoop" type="CenterContainer" parent="MarginContainer/ScrollContainer/VBoxContainer"]
visible = false
layout_mode = 2
size_flags_horizontal = 3

Expand Down
2 changes: 2 additions & 0 deletions Scenes/Multiplayer/KoopMultiplayerScene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ func _ready():
add_child(timer)
timer.connect("timeout", _on_timer_timeout)

GameManager.jsonHandler.savePlayedMultiplayerMap()

_init_game()

func _process(delta):
Expand Down
12 changes: 10 additions & 2 deletions Util/AchievementHandler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class AchievementsHandler:
"won100": false,
"lost10": false,
"lost100": false,
"winKoop": false
"winKoop": false,
"playKoop": false
}

func _init():
Expand Down Expand Up @@ -78,7 +79,11 @@ class AchievementsHandler:
var winKoop: bool:
get:
return stats["winKoop"]


var playKoop: bool:
get:
return stats["playKoop"]

# Update properties
func add_found128():
_updateKey("found128")
Expand Down Expand Up @@ -109,6 +114,9 @@ class AchievementsHandler:

func add_winKoop():
_updateKey("winKoop")

func add_playKoop():
_updateKey("playKoop")

func _updateKey(key: String, value: bool = true):
if stats[key] == true:
Expand Down
3 changes: 3 additions & 0 deletions Util/JSON.gd
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ class JSONHandler:
func saveWonMultiplayerMap():
achievementHandler.add_winKoop()

func savePlayedMultiplayerMap():
achievementHandler.add_playKoop()

func add128achievement():
achievementHandler.add_found128()

Expand Down

0 comments on commit 9322187

Please sign in to comment.