diff --git a/Scenes/MainMenu.tscn b/Scenes/MainMenu.tscn index 139f3f3..1c335d0 100644 --- a/Scenes/MainMenu.tscn +++ b/Scenes/MainMenu.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=9 format=3 uid="uid://bg4fa11htun38"] +[gd_scene load_steps=10 format=3 uid="uid://bg4fa11htun38"] +[ext_resource type="Script" uid="uid://crsloi4abxhqh" path="res://Scripts/LoadSaveFIle.cs" id="1_df05h"] [ext_resource type="FontFile" uid="uid://dq7nkk7n7wrq4" path="res://Fonts/Lexend.ttf" id="1_tt5f1"] [ext_resource type="Script" uid="uid://bc4miccifwrk0" path="res://Scripts/SceneSwitcher.cs" id="2_8saeu"] [ext_resource type="AudioStream" uid="uid://6v4630hrkeg6" path="res://Audio/Music/Menu.mp3" id="2_853f1"] @@ -9,12 +10,6 @@ font = ExtResource("1_tt5f1") font_size = 486 -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_853f1"] -bg_color = Color(0.95158, 0.95158, 0.95158, 1) - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8saeu"] -bg_color = Color(0.830335, 0.830335, 0.830335, 1) - [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_tt5f1"] bg_color = Color(1, 1, 1, 1) corner_radius_top_left = 5 @@ -22,6 +17,12 @@ corner_radius_top_right = 5 corner_radius_bottom_right = 5 corner_radius_bottom_left = 5 +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8saeu"] +bg_color = Color(0.830335, 0.830335, 0.830335, 1) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_853f1"] +bg_color = Color(0.95158, 0.95158, 0.95158, 1) + [node name="MainMenu" type="Control"] layout_mode = 3 anchors_preset = 15 @@ -29,6 +30,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +script = ExtResource("1_df05h") [node name="Center" type="Control" parent="."] layout_mode = 1 @@ -127,17 +129,17 @@ offset_right = 250.0 offset_bottom = 118.0 grow_horizontal = 2 grow_vertical = 2 -theme_override_colors/font_disabled_color = Color(0, 0, 0, 1) -theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 1) -theme_override_colors/font_hover_color = Color(0, 0, 0, 1) theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_colors/font_focus_color = Color(0, 0, 0, 1) theme_override_colors/font_pressed_color = Color(0, 0, 0, 1) +theme_override_colors/font_hover_color = Color(0, 0, 0, 1) +theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 1) +theme_override_colors/font_disabled_color = Color(0, 0, 0, 1) theme_override_fonts/font = ExtResource("1_tt5f1") theme_override_font_sizes/font_size = 56 -theme_override_styles/hover = SubResource("StyleBoxFlat_853f1") -theme_override_styles/pressed = SubResource("StyleBoxFlat_8saeu") theme_override_styles/normal = SubResource("StyleBoxFlat_tt5f1") +theme_override_styles/pressed = SubResource("StyleBoxFlat_8saeu") +theme_override_styles/hover = SubResource("StyleBoxFlat_853f1") text = "Play" script = ExtResource("2_8saeu") ScenePath = "res://Scenes/Game.tscn" diff --git a/Scripts/BazookaManager.cs b/Scripts/BazookaManager.cs new file mode 100644 index 0000000..9ea9669 --- /dev/null +++ b/Scripts/BazookaManager.cs @@ -0,0 +1,24 @@ +using Godot; + +public partial class BazookaManager : Node { + public static string HighScore = "0"; + + public static string Read(string saveKey, string defaultValue) { + string path = "user://" + saveKey + ".txt"; + if (!FileAccess.FileExists(path)) { + using var file = FileAccess.Open(path, FileAccess.ModeFlags.Write); + file.StoreString(defaultValue); + return defaultValue; + } else { + using var file = FileAccess.Open(path, FileAccess.ModeFlags.Read); + return file.GetAsText(); + } + } + + public static void Write(string saveKey, string value) { + string path = "user://" + saveKey + ".txt"; + using var file = FileAccess.Open(path, FileAccess.ModeFlags.Write); + file.StoreString(value); + file.Flush(); + } +} diff --git a/Scripts/BazookaManager.cs.uid b/Scripts/BazookaManager.cs.uid new file mode 100644 index 0000000..ce28a3a --- /dev/null +++ b/Scripts/BazookaManager.cs.uid @@ -0,0 +1 @@ +uid://q3n4b6d6e7x0 diff --git a/Scripts/BerryLogic.cs b/Scripts/BerryLogic.cs index f4f712e..e4b2239 100644 --- a/Scripts/BerryLogic.cs +++ b/Scripts/BerryLogic.cs @@ -29,6 +29,8 @@ public partial class BerryLogic : Node2D { if (BerryType == "poison") { Globals.EffectTimer = 0f; Globals.Score = 0; + + BazookaManager.Write(BazookaManager.HighScore, Globals.HighScore.ToString()); } else if (BerryType == "slow") { if (Globals.ActiveEffect == "slow") { Globals.EffectTimer += 10f; diff --git a/Scripts/LoadSaveFIle.cs b/Scripts/LoadSaveFIle.cs new file mode 100644 index 0000000..b07fea4 --- /dev/null +++ b/Scripts/LoadSaveFIle.cs @@ -0,0 +1,8 @@ +using Godot; +using System; + +public partial class LoadSaveFIle : Control { + public override void _Ready() { + Globals.HighScore = int.Parse(BazookaManager.Read(BazookaManager.HighScore, "0")); + } +} diff --git a/Scripts/LoadSaveFIle.cs.uid b/Scripts/LoadSaveFIle.cs.uid new file mode 100644 index 0000000..9b4c2dc --- /dev/null +++ b/Scripts/LoadSaveFIle.cs.uid @@ -0,0 +1 @@ +uid://crsloi4abxhqh