Added functionality to main menu
This commit is contained in:
@@ -53,7 +53,7 @@ namespace Fruitomation.Game
|
||||
Buildings = buildings.ToArray();
|
||||
}
|
||||
|
||||
private static string Filepath => Path.Combine(Application.persistentDataPath, "buildings.json");
|
||||
public static string Filepath => Path.Combine(Application.persistentDataPath, "buildings.json");
|
||||
|
||||
private bool[,] InhabitedCells { get; } = new bool[96, 49];
|
||||
private List<Building> Buildings { get; } = new();
|
||||
@@ -84,6 +84,11 @@ namespace Fruitomation.Game
|
||||
}
|
||||
|
||||
string json = File.ReadAllText(Filepath);
|
||||
if (json == "")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SerializedBuilding[] buildings = JsonUtility.FromJson<SerializedBuildings>(json).Get();
|
||||
|
||||
foreach (SerializedBuilding building in buildings)
|
||||
@@ -129,7 +134,7 @@ namespace Fruitomation.Game
|
||||
string json = JsonUtility.ToJson(new SerializedBuildings(serialized), true);
|
||||
File.WriteAllText(Filepath, json);
|
||||
}
|
||||
|
||||
|
||||
public void RemoveBuilding(Building building)
|
||||
{
|
||||
Buildings.Remove(building);
|
||||
|
||||
@@ -190,12 +190,14 @@ namespace Fruitomation.Game
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[MenuItem("Fruitomation/Reset Upgrades")]
|
||||
#endif // UNITY_EDITOR
|
||||
public static void ResetUpgrades()
|
||||
{
|
||||
CurrentUpgrades = new UnlockedUpgrades();
|
||||
CurrentUpgrades.Unlock(BasicUpgrade.Apple); // Always unlocked
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[MenuItem("Fruitomation/Unlock All Upgrades")]
|
||||
public static void UnlockAll()
|
||||
{
|
||||
|
||||
28
Assets/Scripts/UI/MainMenuController.cs
Normal file
28
Assets/Scripts/UI/MainMenuController.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.IO;
|
||||
using Fruitomation.Game;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Fruitomation.UI
|
||||
{
|
||||
public class MainMenuController : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private Button ResetButton;
|
||||
[SerializeField] private Button PlayButton;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
PlayButton.onClick.AddListener(() =>
|
||||
{
|
||||
SceneController.StartLoadOf("GameScene");
|
||||
});
|
||||
|
||||
ResetButton.onClick.AddListener(() =>
|
||||
{
|
||||
File.WriteAllText(BuildingManager.Filepath, "");
|
||||
UpgradeManager.ResetUpgrades();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/MainMenuController.cs.meta
Normal file
2
Assets/Scripts/UI/MainMenuController.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56dd683265dd7fc48b92d102c435e3da
|
||||
Reference in New Issue
Block a user