Added the unlock menu thing

This commit is contained in:
Pasha Bibko
2026-05-05 11:21:44 +01:00
parent 4b08904de9
commit 066b3bc958
6 changed files with 934 additions and 69 deletions

View File

@@ -0,0 +1,47 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4528292146240613971
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3666462050572962762}
- component: {fileID: 2973243437333469226}
m_Layer: 0
m_Name: ItemRegistry
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3666462050572962762
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4528292146240613971}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2973243437333469226
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4528292146240613971}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dcb8b502e5b94a72b37a6e77e4770d05, type: 3}
m_Name:
m_EditorClassIdentifier: Fruitomation::Fruitomation.Game.Items.ItemInfoRegistry
SerializedRegistry: {fileID: 11400000, guid: b518751a8b5ee0942af68ec87eeba0c5, type: 2}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ab033116269e1b04a803e8de46580851
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1815,6 +1815,7 @@ MonoBehaviour:
SelectedBuildingToBuild:
Name:
Requirement: 0
Type: 0
Prefab: {fileID: 0}
FlipCurrentBuilding: 0
--- !u!58 &1330313879
@@ -2157,51 +2158,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1511006084}
m_CullTransparentMesh: 1
--- !u!1 &1618062727
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1618062728}
- component: {fileID: 1618062729}
m_Layer: 0
m_Name: ItemRegistry
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1618062728
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1618062727}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1618062729
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1618062727}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dcb8b502e5b94a72b37a6e77e4770d05, type: 3}
m_Name:
m_EditorClassIdentifier: Fruitomation::Fruitomation.Game.Items.ItemInfoRegistry
SerializedRegistry: {fileID: 11400000, guid: b518751a8b5ee0942af68ec87eeba0c5, type: 2}
--- !u!1 &1740340057
GameObject:
m_ObjectHideFlags: 0
@@ -2932,6 +2888,74 @@ MonoBehaviour:
MenuItemPrefab: {fileID: 1541142508120997748, guid: 74aff4063df1fab4c954bebfad022ff5,
type: 3}
BuildingPrefabs: {fileID: 11400000, guid: e6ae3d283005f994da00a3d8835a3cb5, type: 2}
--- !u!1001 &2856219408887410068
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3666462050572962762, guid: ab033116269e1b04a803e8de46580851,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3666462050572962762, guid: ab033116269e1b04a803e8de46580851,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3666462050572962762, guid: ab033116269e1b04a803e8de46580851,
type: 3}
propertyPath: m_LocalPosition.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3666462050572962762, guid: ab033116269e1b04a803e8de46580851,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3666462050572962762, guid: ab033116269e1b04a803e8de46580851,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3666462050572962762, guid: ab033116269e1b04a803e8de46580851,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3666462050572962762, guid: ab033116269e1b04a803e8de46580851,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3666462050572962762, guid: ab033116269e1b04a803e8de46580851,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3666462050572962762, guid: ab033116269e1b04a803e8de46580851,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3666462050572962762, guid: ab033116269e1b04a803e8de46580851,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4528292146240613971, guid: ab033116269e1b04a803e8de46580851,
type: 3}
propertyPath: m_Name
value: ItemRegistry
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: ab033116269e1b04a803e8de46580851, type: 3}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
@@ -2942,4 +2966,4 @@ SceneRoots:
- {fileID: 1165634414}
- {fileID: 525386540}
- {fileID: 1935863238}
- {fileID: 1618062728}
- {fileID: 2856219408887410068}

File diff suppressed because it is too large Load Diff

View File

@@ -106,19 +106,14 @@ namespace Fruitomation.UI
UpgradeLines = lines.ToArray();
}
private void OnButtonClicked()
{
if (Cost == 0f)
{
Debug.LogWarning("Upgrade Cost has not been set");
return;
}
if (MoneyController.CanBuy(Cost))
{
UpgradeManager.Unlock(Upgrade);
}
}
private void OnButtonClicked() => UpgradeBoard.Enable
(
Upgrade,
Inputs,
Outputs,
Building,
Cost
);
private bool IsUnlockable =>
RequiredUpgrades.Length == 0 ||
@@ -170,7 +165,8 @@ namespace Fruitomation.UI
State = UpgradeState.Hidden;
}
AttachedButton.interactable = State == UpgradeState.Unlockable;
AttachedButton.interactable =
State is UpgradeState.Unlockable or UpgradeState.Unlocked;
string cost = Cost == 0f ? "UNAVAILABLE" : $"{Cost:F1}";

View File

@@ -1,22 +1,105 @@
using UnityEngine;
using System.Collections.Generic;
using Fruitomation.Game.Items;
using Fruitomation.Game;
using UnityEngine.UI;
using UnityEngine;
namespace Fruitomation.UI
{
public class UpgradeInfoBoard : MonoBehaviour
{
[SerializeField] private GameObject BoardGO;
[SerializeField] private Button[] ExitButtons;
[SerializeField] private BuildingRegistry Registry;
[SerializeField] private GameObject InputParent;
[SerializeField] private GameObject OutputParent;
[SerializeField] private GameObject BuildingDisplay;
[SerializeField] private GameObject LeftArrow;
[SerializeField] private GameObject SpawnerText;
private readonly Dictionary<AutomationBuildingType, GameObject> BuildingRegistry = new();
private readonly List<GameObject> ChildrenToKill = new();
private void Start()
{
BoardGO.SetActive(false);
foreach (Button b in ExitButtons)
{
b.onClick.AddListener(Disable);
}
public void Enable()
foreach (BuildingRegistry.BuildingInfo info in Registry.GetBuildings())
{
if (info.Type != AutomationBuildingType.None)
{
BuildingRegistry.Add(info.Type, info.Prefab);
}
}
}
public void Disable()
public void Enable
(
BasicUpgrade upgrade,
ItemType[] inputs,
ItemType[] outputs,
AutomationBuildingType building,
double cost
)
// Wow, those function params are horrible
{
BoardGO.SetActive(true);
foreach (ItemType input in inputs)
{
ItemInfo info = ItemInfoRegistry.Get(input);
GameObject go = Instantiate(info.Prefab, InputParent.transform);
ChildrenToKill.Add(go);
}
foreach (ItemType output in outputs)
{
ItemInfo info = ItemInfoRegistry.Get(output);
GameObject go = Instantiate(info.Prefab, OutputParent.transform);
ChildrenToKill.Add(go);
}
if (building != AutomationBuildingType.Spawner)
{
BuildingDisplay.SetActive(true);
LeftArrow.SetActive(true);
SpawnerText.SetActive(false);
Sprite sprite = BuildingRegistry[building].GetComponent<Building>().Sprite;
BuildingDisplay.GetComponent<Image>().sprite = sprite;
if (building == AutomationBuildingType.HeatExchanger)
{
RectTransform rt = BuildingDisplay.GetComponent<RectTransform>();
rt.sizeDelta = new Vector2(125f, 250f);
}
else
{
RectTransform rt = BuildingDisplay.GetComponent<RectTransform>();
rt.sizeDelta = new Vector2(250f, 250f);
}
}
else
{
BuildingDisplay.SetActive(false);
LeftArrow.SetActive(false);
SpawnerText.SetActive(true);
}
}
private void Disable()
{
BoardGO.SetActive(false);
foreach (GameObject child in ChildrenToKill)
{
Destroy(child);
}
ChildrenToKill.Clear();
}
}
}