diff --git a/Game/Bullets/rock.tscn b/Game/Bullets/rock.tscn index 0620ad9..f22578a 100644 --- a/Game/Bullets/rock.tscn +++ b/Game/Bullets/rock.tscn @@ -44,6 +44,7 @@ animations = [{ }] [sub_resource type="CircleShape2D" id="CircleShape2D_tjven"] +radius = 4.66667 [node name="Rock" type="Node2D"] script = ExtResource("1_yml18") diff --git a/Game/Maps/map_1.gd b/Game/Maps/map_1.gd index 84fada3..82a9608 100644 --- a/Game/Maps/map_1.gd +++ b/Game/Maps/map_1.gd @@ -10,7 +10,7 @@ const enemies = [FORKMAN, COBOLD, ORK] func _ready() -> void: - get_node("CanvasLayer/SidePanel").Update_Lifes(20) + get_node("CanvasLayer/SidePanel").set_Lifes(20) get_node("CanvasLayer/SidePanel").Update_Coins(2000) #the meaning of the columns inside my wave generation matris: @@ -31,7 +31,7 @@ func _on_timer_timeout() -> void: if not get_node("Path2D").get_children(): endwave = false get_node("CanvasLayer/SidePanel").Update_waves(currentwave + 1) #updating waves - if currentwave >= 5: + if currentwave >= 4: #!!!!! CHECKS FOR THE LAST WAVE IF NEW WAVES ARE ADDED CHANGE ACCORDINGLY!!! get_node("CanvasLayer/SidePanel").GameWon() else: spawnMonster() diff --git a/Game/Maps/map_1.tscn b/Game/Maps/map_1.tscn index cea521a..c003362 100644 --- a/Game/Maps/map_1.tscn +++ b/Game/Maps/map_1.tscn @@ -1549,7 +1549,7 @@ texture = ExtResource("65_ef8wx") curve = SubResource("Curve2D_6abe5") [node name="Timer" type="Timer" parent="."] -wait_time = 0.2 +wait_time = 0.4 autostart = true [node name="TrapArea" type="Area2D" parent="."] diff --git a/Game/Menu/mapselector.gd b/Game/Menu/mapselector.gd index 9c15dca..f804f79 100644 --- a/Game/Menu/mapselector.gd +++ b/Game/Menu/mapselector.gd @@ -1,5 +1,7 @@ extends Control +var save_path = "user://map_scores.save" +var map_scores = {} func _on_button_pressed() -> void: @@ -10,3 +12,30 @@ func _on_button_pressed() -> void: func _on_button_map1_pressed() -> void: get_tree().change_scene_to_file("res://Game/Maps/map_1.tscn") pass # Replace with function body. + + +func _ready() -> void: + loadData() + + +func loadData() -> void: + if FileAccess.file_exists(save_path): + var file = FileAccess.open(save_path, FileAccess.READ) + if file: + map_scores = file.get_var() + file.close() + get_node("VBoxContainer/HBoxContainer/first/Label2").text = "Haven't played yet" if map_scores["Map1"] == 0 else "Scored: " + str(map_scores["Map1"]) + " out of 10" + print(map_scores) + + else: + map_scores["Map1"] = 0 + + save_scores() + loadData() + + +func save_scores(): + var file = FileAccess.open(save_path, FileAccess.WRITE) + if file: + file.store_var(map_scores) + file.close() diff --git a/Game/sidepanel.gd b/Game/sidepanel.gd index 3827695..612e027 100644 --- a/Game/sidepanel.gd +++ b/Game/sidepanel.gd @@ -26,7 +26,11 @@ const MORTAR_TOWER = preload("res://Game/Towers/mortar_tower.tscn") const DELETER = preload("res://Game/Accesories/deleter.tscn") var lives = 0 +var originallives = 0 var coins = 0 +var save_path = "user://map_scores.save" +var map_scores = {} + func _ready() -> void: get_node("pausemenu").hide() @@ -60,6 +64,11 @@ func _ready() -> void: delete_tower_button.connect("button_up", Spawn_Deleter) + var file = FileAccess.open(save_path, FileAccess.READ) + if file: + map_scores = file.get_var() + file.close() + func _process(delta : float)-> void: coinlabel.text = "Coins: " + str(coins) livelabel.text = "Lives: " + str(lives) @@ -68,6 +77,7 @@ func _process(delta : float)-> void: func set_Lifes(amount) -> void: lives = amount + originallives = amount func get_Lifes(): return lives @@ -163,6 +173,12 @@ func GameOver() -> void: func GameWon() -> void: get_node("Panel").hide() get_node("GameWon").show() + + map_scores[get_parent().get_parent().name] = int((lives / originallives) *10) + var file = FileAccess.open(save_path, FileAccess.WRITE) + if file: + file.store_var(map_scores) + file.close() func _on_button_3_pressed() -> void: get_node("pausemenu").hide()