Added a way from the upgrades to game scene
This commit is contained in:
@@ -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<FruitBehaviour> ActiveFruits;
|
||||
@@ -38,7 +47,30 @@ namespace Fruitomation.Game
|
||||
|
||||
private void SpawnFruit()
|
||||
{
|
||||
GameObject prefab = FruitPrefabs[Random.Range(0, FruitPrefabs.Length)];
|
||||
List<GameObject> 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<FruitBehaviour>();
|
||||
|
||||
17
Assets/Scripts/Game/ReturnToGameButton.cs
Normal file
17
Assets/Scripts/Game/ReturnToGameButton.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Fruitomation.Game
|
||||
{
|
||||
public class ReturnToGameButton : MonoBehaviour
|
||||
{
|
||||
private void Awake()
|
||||
{
|
||||
Button b = GetComponent<Button>();
|
||||
b.onClick.AddListener(() =>
|
||||
{
|
||||
SceneController.StartLoadOf("GameScene");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Game/ReturnToGameButton.cs.meta
Normal file
2
Assets/Scripts/Game/ReturnToGameButton.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f06b202749249b44a91b5047cb79cd9b
|
||||
@@ -4,6 +4,10 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif // UNITY_EDITOR
|
||||
|
||||
namespace Fruitomation.Game
|
||||
{
|
||||
[Serializable] public enum BasicUpgrade
|
||||
@@ -86,6 +90,11 @@ namespace Fruitomation.Game
|
||||
{
|
||||
Unlocks.Add(upgrade);
|
||||
}
|
||||
|
||||
public bool IsUnlocked(BasicUpgrade upgrade)
|
||||
{
|
||||
return Unlocks.Contains(upgrade);
|
||||
}
|
||||
}
|
||||
|
||||
public static class UpgradeManager
|
||||
@@ -120,5 +129,12 @@ namespace Fruitomation.Game
|
||||
}
|
||||
|
||||
public static void Unlock(BasicUpgrade upgrade) => CurrentUpgrades.Unlock(upgrade);
|
||||
|
||||
public static bool Unlocked(BasicUpgrade upgrade) => CurrentUpgrades.IsUnlocked(upgrade);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[MenuItem("Fruitomation/Reset Upgrades")]
|
||||
#endif // UNITY_EDITOR
|
||||
public static void ResetUpgrades() => CurrentUpgrades = new UnlockedUpgrades();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user