From 6868788af7b7838beb6b63db58cb7658bbec22ff Mon Sep 17 00:00:00 2001 From: Pasha Bibko <156938226+PashaBibko@users.noreply.github.com> Date: Tue, 14 Apr 2026 15:57:10 +0100 Subject: [PATCH] Added a way from the upgrades to game scene --- Assets/Scenes/UpgradesScene.unity | 328 +++++++++++++++--- Assets/Scripts/Game/FruitSpawner.cs | 36 +- Assets/Scripts/Game/ReturnToGameButton.cs | 17 + .../Scripts/Game/ReturnToGameButton.cs.meta | 2 + Assets/Scripts/Game/UpgradeManager.cs | 16 + 5 files changed, 347 insertions(+), 52 deletions(-) create mode 100644 Assets/Scripts/Game/ReturnToGameButton.cs create mode 100644 Assets/Scripts/Game/ReturnToGameButton.cs.meta diff --git a/Assets/Scenes/UpgradesScene.unity b/Assets/Scenes/UpgradesScene.unity index 3e7b328..685a90e 100644 --- a/Assets/Scenes/UpgradesScene.unity +++ b/Assets/Scenes/UpgradesScene.unity @@ -146,13 +146,13 @@ RectTransform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1077660} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + 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: - {fileID: 129767514} - m_Father: {fileID: 1601651585} + m_Father: {fileID: 2119665806} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -602,13 +602,13 @@ RectTransform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 216535971} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + 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: - {fileID: 1454648454} - m_Father: {fileID: 1601651585} + m_Father: {fileID: 2119665806} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -817,13 +817,13 @@ RectTransform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 306312742} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + 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: - {fileID: 291432705} - m_Father: {fileID: 1601651585} + m_Father: {fileID: 2119665806} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -873,19 +873,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 306312745} m_OnClick: m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 0} - m_TargetAssemblyTypeName: Fruitomation.Game.UpgradeManager, Fruitomation - m_MethodName: UnlockBasicUpgrade - m_Mode: 5 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: Grapes - m_BoolArgument: 0 - m_CallState: 2 + m_Calls: [] --- !u!114 &306312745 MonoBehaviour: m_ObjectHideFlags: 0 @@ -965,13 +953,13 @@ RectTransform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 406517114} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + 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: - {fileID: 2129197833} - m_Father: {fileID: 1601651585} + m_Father: {fileID: 2119665806} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -1238,13 +1226,13 @@ RectTransform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 683605710} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + 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: - {fileID: 1686089426} - m_Father: {fileID: 1601651585} + m_Father: {fileID: 2119665806} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -1523,13 +1511,13 @@ RectTransform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 946556762} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + 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: - {fileID: 1309090468} - m_Father: {fileID: 1601651585} + m_Father: {fileID: 2119665806} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -1579,19 +1567,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 946556765} m_OnClick: m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 0} - m_TargetAssemblyTypeName: - m_MethodName: - m_Mode: 1 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 + m_Calls: [] --- !u!114 &946556765 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1709,6 +1685,87 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 958003757} m_CullTransparentMesh: 1 +--- !u!1 &1228767730 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1228767731} + - component: {fileID: 1228767733} + - component: {fileID: 1228767732} + m_Layer: 5 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1228767731 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1228767730} + 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: 1512838242} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1228767732 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1228767730} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Text + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 50 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 5 + m_MaxSize: 50 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: 'Back + +' +--- !u!222 &1228767733 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1228767730} + m_CullTransparentMesh: 1 --- !u!1 &1309090467 GameObject: m_ObjectHideFlags: 0 @@ -1894,13 +1951,13 @@ RectTransform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1394817801} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + 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: - {fileID: 1322128433} - m_Father: {fileID: 1601651585} + m_Father: {fileID: 2119665806} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -2082,6 +2139,140 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1454648453} m_CullTransparentMesh: 1 +--- !u!1 &1512838241 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1512838242} + - component: {fileID: 1512838245} + - component: {fileID: 1512838244} + - component: {fileID: 1512838243} + - component: {fileID: 1512838246} + m_Layer: 5 + m_Name: ReturnToGame + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1512838242 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1512838241} + 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: + - {fileID: 1228767731} + m_Father: {fileID: 1601651585} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 1600, y: -950} + m_SizeDelta: {x: 350, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1512838243 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1512838241} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Button + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1512838244} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &1512838244 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1512838241} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1512838245 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1512838241} + m_CullTransparentMesh: 1 +--- !u!114 &1512838246 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1512838241} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f06b202749249b44a91b5047cb79cd9b, type: 3} + m_Name: + m_EditorClassIdentifier: Fruitomation::ReturnToGameButton --- !u!1 &1601651581 GameObject: m_ObjectHideFlags: 0 @@ -2177,14 +2368,8 @@ RectTransform: m_ConstrainProportionsScale: 1 m_Children: - {fileID: 120641731} - - {fileID: 946556763} - - {fileID: 306312743} - - {fileID: 216535972} - - {fileID: 1992771922} - - {fileID: 1077661} - - {fileID: 683605711} - - {fileID: 1394817802} - - {fileID: 406517115} + - {fileID: 2119665806} + - {fileID: 1512838242} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -2441,13 +2626,13 @@ RectTransform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1992771921} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + 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: - {fileID: 958003758} - m_Father: {fileID: 1601651585} + m_Father: {fileID: 2119665806} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -2550,6 +2735,49 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.Game.BasicUpgradeButton Upgrade: 2 UpgradeCost: 0 +--- !u!1 &2119665805 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2119665806} + m_Layer: 5 + m_Name: Upgrades + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2119665806 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2119665805} + 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: + - {fileID: 946556763} + - {fileID: 306312743} + - {fileID: 216535972} + - {fileID: 1992771922} + - {fileID: 1077661} + - {fileID: 683605711} + - {fileID: 1394817802} + - {fileID: 406517115} + m_Father: {fileID: 1601651585} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &2129197832 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Game/FruitSpawner.cs b/Assets/Scripts/Game/FruitSpawner.cs index d60fc5c..154871e 100644 --- a/Assets/Scripts/Game/FruitSpawner.cs +++ b/Assets/Scripts/Game/FruitSpawner.cs @@ -14,8 +14,17 @@ namespace Fruitomation.Game [Header("References")] [SerializeField] private Transform FruitSpawnParent; - [SerializeField] private GameObject[] FruitPrefabs; [SerializeField] private Canvas GameCanvas; + + [Header("Prefabs")] + [SerializeField] private GameObject ApplePrefab; + [SerializeField] private GameObject GrapePrefab; + [SerializeField] private GameObject BananaPrefab; + [SerializeField] private GameObject MangoPrefab; + [SerializeField] private GameObject DurianPrefab; + [SerializeField] private GameObject PitayaPrefab; + [SerializeField] private GameObject KiwiPrefab; + [SerializeField] private GameObject BuddhasHandPrefab; [Header("Read only")] [SerializeField, InspectorReadOnly] private List ActiveFruits; @@ -38,7 +47,30 @@ namespace Fruitomation.Game private void SpawnFruit() { - GameObject prefab = FruitPrefabs[Random.Range(0, FruitPrefabs.Length)]; + List unlocked = new() { ApplePrefab }; + + if (UpgradeManager.Unlocked(BasicUpgrade.Grapes)) + unlocked.Add(GrapePrefab); + + if (UpgradeManager.Unlocked(BasicUpgrade.Bananas)) + unlocked.Add(BananaPrefab); + + if (UpgradeManager.Unlocked(BasicUpgrade.Kiwi)) + unlocked.Add(KiwiPrefab); + + if (UpgradeManager.Unlocked(BasicUpgrade.Mangoes)) + unlocked.Add(MangoPrefab); + + if (UpgradeManager.Unlocked(BasicUpgrade.Durian)) + unlocked.Add(DurianPrefab); + + if (UpgradeManager.Unlocked(BasicUpgrade.BuddhasHand)) + unlocked.Add(BuddhasHandPrefab); + + if (UpgradeManager.Unlocked(BasicUpgrade.Pitayas)) + unlocked.Add(PitayaPrefab); + + GameObject prefab = unlocked[Random.Range(0, unlocked.Count)]; GameObject go = Instantiate(prefab, FruitSpawnParent); FruitBehaviour behaviour = go.GetComponent(); diff --git a/Assets/Scripts/Game/ReturnToGameButton.cs b/Assets/Scripts/Game/ReturnToGameButton.cs new file mode 100644 index 0000000..60e43a2 --- /dev/null +++ b/Assets/Scripts/Game/ReturnToGameButton.cs @@ -0,0 +1,17 @@ +using UnityEngine.UI; +using UnityEngine; + +namespace Fruitomation.Game +{ + public class ReturnToGameButton : MonoBehaviour + { + private void Awake() + { + Button b = GetComponent