From c1160280169045ed3cf4efe0361438357557939d Mon Sep 17 00:00:00 2001 From: Pasha Bibko <156938226+PashaBibko@users.noreply.github.com> Date: Tue, 28 Apr 2026 11:43:13 +0100 Subject: [PATCH] Added requirements to mixer recipes --- Assets/Scenes/UpgradesScene.unity | 2 +- .../Buildings/Automation/MixerBuilding.cs | 50 +++++++++++-------- Assets/Scripts/Game/UpgradeManager.cs | 31 +++++++----- 3 files changed, 49 insertions(+), 34 deletions(-) diff --git a/Assets/Scenes/UpgradesScene.unity b/Assets/Scenes/UpgradesScene.unity index b8f9dc3..c680237 100644 --- a/Assets/Scenes/UpgradesScene.unity +++ b/Assets/Scenes/UpgradesScene.unity @@ -6395,7 +6395,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f9c5dbc6e19942c19f4dc93fc3777677, type: 3} m_Name: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton - Upgrade: 0 + Upgrade: 35 DrawDefaultLines: 1 Cost: Magnitude: 0 diff --git a/Assets/Scripts/Game/Buildings/Automation/MixerBuilding.cs b/Assets/Scripts/Game/Buildings/Automation/MixerBuilding.cs index e77f4e1..7ae856c 100644 --- a/Assets/Scripts/Game/Buildings/Automation/MixerBuilding.cs +++ b/Assets/Scripts/Game/Buildings/Automation/MixerBuilding.cs @@ -11,11 +11,13 @@ namespace Fruitomation.Game { private struct Recipe { + public BasicUpgrade Requirement; public ItemType[] Ingredients; public ItemType Product; - public Recipe(ItemType[] ingredients, ItemType product) + public Recipe(BasicUpgrade requirement, ItemType[] ingredients, ItemType product) { + Requirement = requirement; Ingredients = ingredients; Product = product; } @@ -25,6 +27,7 @@ namespace Fruitomation.Game { new ( + BasicUpgrade.DriedFruitSelection, new[] { ItemType.DriedAppleSlices, @@ -36,6 +39,7 @@ namespace Fruitomation.Game new ( + BasicUpgrade.AppleMangoJuice, new[] { ItemType.AppleJuice, @@ -46,6 +50,7 @@ namespace Fruitomation.Game new ( + BasicUpgrade.SpicedBananaIceCream, new[] { ItemType.BananaIceCream, @@ -56,6 +61,7 @@ namespace Fruitomation.Game new ( + BasicUpgrade.ExoticFruitSelection, new[] { ItemType.SlicedKiwi, @@ -68,6 +74,7 @@ namespace Fruitomation.Game new ( + BasicUpgrade.SpicedPitayaIceCream, new[] { ItemType.PitayaIceCream, @@ -134,27 +141,30 @@ namespace Fruitomation.Game foreach (Recipe recipe in Recipes) { - bool hasAllIngredients = recipe.Ingredients.Aggregate(true, - (current, ingredient) - => current && StoredItems.ContainsKey(ingredient) - ); - - if (hasAllIngredients) + if (UpgradeManager.Is(recipe.Requirement)) { - foreach (ItemType ingredient in recipe.Ingredients) - { - int count = StoredItems[ingredient] - 1; - if (count <= 0) - { - StoredItems.Remove(ingredient); - } - else - { - StoredItems[ingredient] = count; - } - } + bool hasAllIngredients = recipe.Ingredients.Aggregate(true, + (current, ingredient) + => current && StoredItems.ContainsKey(ingredient) + ); - FruitSpawner.SpawnItem(recipe.Product, OutputLocation.position); + if (hasAllIngredients) + { + foreach (ItemType ingredient in recipe.Ingredients) + { + int count = StoredItems[ingredient] - 1; + if (count <= 0) + { + StoredItems.Remove(ingredient); + } + else + { + StoredItems[ingredient] = count; + } + } + + FruitSpawner.SpawnItem(recipe.Product, OutputLocation.position); + } } } } diff --git a/Assets/Scripts/Game/UpgradeManager.cs b/Assets/Scripts/Game/UpgradeManager.cs index 9052cbe..c69f0e8 100644 --- a/Assets/Scripts/Game/UpgradeManager.cs +++ b/Assets/Scripts/Game/UpgradeManager.cs @@ -1,9 +1,10 @@ -using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Collections.Generic; +using UnityEngine.Scripting; using UnityEngine; -using System.IO; using System.Linq; +using System.IO; using System; -using System.Runtime.CompilerServices; #if UNITY_EDITOR using UnityEditor; @@ -13,7 +14,6 @@ namespace Fruitomation.Game { [Serializable] public enum BasicUpgrade { - //Apple, - Unlocked by default Grapes, Bananas, Kiwi, @@ -50,6 +50,8 @@ namespace Fruitomation.Game PitayaFoodDye, PitayaIceCream, SpicedPitayaIceCream, + + Apple } [Serializable] public enum BuildingUnlock @@ -57,20 +59,20 @@ namespace Fruitomation.Game None, //Wall, - Unlocked by default - //Slope, - Floor, + //Slope, - Unlocked by default + [Preserve] Floor, //Spring, - Unlocked by default - Fan, - Alternator, + [Preserve] Fan, + [Preserve] Alternator, //Slicer, - Unlocked by default //Presser, - Unlocked by default - HeatExchanger, - Grinder, - Mixer, - Fermenter, - Peeler, + [Preserve] HeatExchanger, + [Preserve] Grinder, + [Preserve] Mixer, + [Preserve] Fermenter, + [Preserve] Peeler, } public class UnlockedUpgrades @@ -149,6 +151,8 @@ namespace Fruitomation.Game { CurrentUpgrades = JsonUtility.FromJson(json).Unserialize(); } + + CurrentUpgrades.Unlock(BasicUpgrade.Apple); // Unlocked by default } CurrentUpgrades ??= new UnlockedUpgrades(); @@ -189,6 +193,7 @@ namespace Fruitomation.Game public static void ResetUpgrades() { CurrentUpgrades = new UnlockedUpgrades(); + CurrentUpgrades.Unlock(BasicUpgrade.Apple); // Always unlocked } [MenuItem("Fruitomation/Unlock All Upgrades")]