Improved look of main scene
This commit is contained in:
@@ -77,19 +77,28 @@ namespace Fruitomation.Game
|
||||
{
|
||||
[Serializable] public class Serialized
|
||||
{
|
||||
[SerializeField] private BuildingUnlock[] BuildingUnlocks;
|
||||
[SerializeField] private BasicUpgrade[] BasicUpgrades;
|
||||
|
||||
private Serialized()
|
||||
{
|
||||
// All logic done in Serialize
|
||||
// All logic done in Serialize() function
|
||||
}
|
||||
|
||||
|
||||
public UnlockedUpgrades Unserialize()
|
||||
{
|
||||
UnlockedUpgrades upgrades = new();
|
||||
foreach (BasicUpgrade upgrade in BasicUpgrades)
|
||||
|
||||
if (BuildingUnlocks is not null)
|
||||
{
|
||||
upgrades.Unlocks.Add(upgrade);
|
||||
foreach (BuildingUnlock unlock in BuildingUnlocks)
|
||||
upgrades.Buildings.Add(unlock);
|
||||
}
|
||||
|
||||
if (BasicUpgrades is not null)
|
||||
{
|
||||
foreach (BasicUpgrade upgrade in BasicUpgrades)
|
||||
upgrades.Unlocks.Add(upgrade);
|
||||
}
|
||||
|
||||
return upgrades;
|
||||
@@ -99,15 +108,16 @@ namespace Fruitomation.Game
|
||||
{
|
||||
Serialized serialized = new()
|
||||
{
|
||||
BasicUpgrades = upgrades.Unlocks.ToArray()
|
||||
BuildingUnlocks = upgrades.Buildings.ToArray(),
|
||||
BasicUpgrades = upgrades.Unlocks.ToArray(),
|
||||
};
|
||||
|
||||
return serialized;
|
||||
}
|
||||
}
|
||||
|
||||
private HashSet<BuildingUnlock> Buildings = new();
|
||||
private HashSet<BasicUpgrade> Unlocks = new();
|
||||
private readonly HashSet<BuildingUnlock> Buildings = new();
|
||||
private readonly HashSet<BasicUpgrade> Unlocks = new();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Unlock(BuildingUnlock unlock) => Buildings.Add(unlock);
|
||||
@@ -168,12 +178,8 @@ namespace Fruitomation.Game
|
||||
public static void Unlock(BasicUpgrade upgrade) => CurrentUpgrades.Unlock(upgrade);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool Is(BuildingUnlock unlock)
|
||||
{
|
||||
return unlock == BuildingUnlock.None
|
||||
? throw new ArgumentOutOfRangeException(nameof(unlock))
|
||||
: CurrentUpgrades.IsUnlocked(unlock);
|
||||
}
|
||||
public static bool Is(BuildingUnlock unlock) =>
|
||||
unlock == BuildingUnlock.None || CurrentUpgrades.IsUnlocked(unlock);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool Is(BasicUpgrade upgrade) => CurrentUpgrades.IsUnlocked(upgrade);
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace Fruitomation.UI
|
||||
UpgradeState.Viewable => $"{formatted}",
|
||||
UpgradeState.Unlockable => $"{formatted}\n{Cost.AsString()}",
|
||||
UpgradeState.Unlocked => $"{formatted}\nUnlocked",
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
var _ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
16
Assets/Scripts/UI/BuildiingUnlockButton.cs
Normal file
16
Assets/Scripts/UI/BuildiingUnlockButton.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class BuildiingUnlockButton : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/BuildiingUnlockButton.cs.meta
Normal file
2
Assets/Scripts/UI/BuildiingUnlockButton.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 062558955cb2e0447a23f174dd90d495
|
||||
@@ -1,4 +1,5 @@
|
||||
using Fruitomation.Global;
|
||||
using System;
|
||||
using Fruitomation.Global;
|
||||
using Fruitomation.Game;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
@@ -13,16 +14,19 @@ namespace Fruitomation.UI
|
||||
[SerializeField] private GameObject MenuGrid;
|
||||
[SerializeField] private GameObject MenuItemPrefab;
|
||||
[SerializeField] private BuildingRegistry BuildingPrefabs;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
private void Update() =>
|
||||
Menu.SetActive(GameStateController.Is(GameState.BuildingMenu));
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
foreach (BuildingRegistry.BuildingInfo info in BuildingPrefabs.GetBuildings())
|
||||
{
|
||||
if (!UpgradeManager.Is(info.Requirement))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
GameObject go = Instantiate(MenuItemPrefab, MenuGrid.transform);
|
||||
Text text = go.GetComponentInChildren<Text>();
|
||||
|
||||
|
||||
@@ -49,7 +49,11 @@ namespace Fruitomation.UI
|
||||
return result;
|
||||
}
|
||||
|
||||
private void Update() =>
|
||||
Image.enabled = GameStateController.Is(GameState.Building);
|
||||
private void Update()
|
||||
{
|
||||
Image.enabled =
|
||||
GameStateController.Is(GameState.Building) ||
|
||||
GameStateController.Is(GameState.Editing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user