您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
75 行
1.6 KiB
75 行
1.6 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class GameManager : MonoBehaviour
|
|
{
|
|
|
|
[SerializeField]
|
|
private QuestManagerSO _questManager = default;
|
|
|
|
[SerializeField]
|
|
private GameStateSO _gameState = default;
|
|
|
|
[SerializeField]
|
|
private VoidEventChannelSO _addRockCandyRecipeEvent = default;
|
|
[SerializeField]
|
|
private VoidEventChannelSO _cerisesMemoryEvent = default;
|
|
[SerializeField]
|
|
private VoidEventChannelSO _decideOnDishesEvent = default;
|
|
|
|
[SerializeField]
|
|
private ItemSO _rockCandyRecipe = default;
|
|
[SerializeField]
|
|
private ItemSO _sweetDoughRecipe = default;
|
|
[SerializeField]
|
|
private ItemSO[] _finalRecipes = default;
|
|
|
|
[SerializeField]
|
|
private InventorySO _inventory = default;
|
|
|
|
private void Start()
|
|
{
|
|
StartGame();
|
|
|
|
}
|
|
private void OnEnable()
|
|
{
|
|
_addRockCandyRecipeEvent.OnEventRaised += AddRockCandyRecipe;
|
|
_cerisesMemoryEvent.OnEventRaised += AddSweetDoughRecipe;
|
|
_decideOnDishesEvent.OnEventRaised += AddFinalRecipes;
|
|
}
|
|
private void OnDisable()
|
|
{
|
|
_addRockCandyRecipeEvent.OnEventRaised -= AddRockCandyRecipe;
|
|
_cerisesMemoryEvent.OnEventRaised -= AddSweetDoughRecipe;
|
|
_decideOnDishesEvent.OnEventRaised -= AddFinalRecipes;
|
|
|
|
}
|
|
void AddRockCandyRecipe()
|
|
{
|
|
_inventory.Add(_rockCandyRecipe);
|
|
|
|
}
|
|
void AddSweetDoughRecipe()
|
|
{
|
|
_inventory.Add(_sweetDoughRecipe);
|
|
|
|
}
|
|
void AddFinalRecipes()
|
|
{
|
|
foreach (ItemSO item in _finalRecipes)
|
|
{
|
|
_inventory.Add(item);
|
|
}
|
|
|
|
}
|
|
// Start is called before the first frame update
|
|
void StartGame()
|
|
{
|
|
_gameState.UpdateGameState(GameState.Gameplay);
|
|
_questManager.StartGame();
|
|
}
|
|
|
|
|
|
}
|