//Returns the used status of a specified station public bool CheckStation(int station, MenuScript.IngredientType type) { //Temp station for checking status Station stationToCheck = new Station(); stationToCheck.locked = false; //Sets temp station as one of the four stations switch (station) { case 0: stationToCheck = oven; break; case 1: stationToCheck = chopping; break; case 2: stationToCheck = blender; break; case 3: stationToCheck = windowS; break; } //Returns false if station is locked if (stationToCheck.locked) { return(false); } //Otherwise checks if the provided ingredient type matches any of the temp stations target ingredients else { foreach (MenuScript.IngredientType i in stationToCheck.targetIngredients) { if (type == i) { return(true); } } } return(false); }
//Disabled a specific station public void StationUsed(int station, MenuScript.IngredientType type) { //Sets the default scene to load as the kitchen string sceneToLoad = "Scene2"; //Loads specified minigame scene and increments completed games switch (station) { case 0: oven.useCount++; oven.targetIngredients.Remove(type); if (oven.targetIngredients.Count <= 0) { //Locks station if it does not require anymore ingredients oven.locked = true; } //Gets the position of the current in use station to spawn mess in the right place currentStationPos = oven.stationObj.transform.position; messOffset = new Vector3(0.0f, -3.0f, 0.0f); minigamesComplete++; sceneToLoad = "MinigameScene"; break; case 1: chopping.useCount++; chopping.targetIngredients.Remove(type); if (chopping.targetIngredients.Count <= 0) { //Locks station if it does not require anymore ingredients chopping.locked = true; } //Gets the position of the current in use station to spawn mess in the right place currentStationPos = chopping.stationObj.transform.position; messOffset = new Vector3(-3.5f, 1.0f, 0.0f); minigamesComplete++; sceneToLoad = "SlicingGame"; break; case 2: blender.useCount++; blender.targetIngredients.Remove(type); if (blender.targetIngredients.Count <= 0) { //Locks station if it does not require anymore ingredients blender.locked = true; } //Gets the position of the current in use station to spawn mess in the right place currentStationPos = blender.stationObj.transform.position; messOffset = new Vector3(2.5f, 1.0f, 0.0f); minigamesComplete++; sceneToLoad = "WheelMinigame"; break; case 3: windowS.useCount++; windowS.locked = true; //Gets the position of the current in use station to spawn mess in the right place currentStationPos = windowS.stationObj.transform.position; messOffset = new Vector3(0.0f, -6.0f, 0.0f); minigamesComplete++; sceneToLoad = "ServingMinigameScene"; break; } //Locks all minigames and activates the dish if 3 games have been complete if (minigamesComplete >= 3) { oven.locked = true; chopping.locked = true; blender.locked = true; completeDish.SetActive(true); } //Pauses game state = stateEnum.paused; SceneSwitcher.LoadSceneAdd(sceneToLoad); //ingredients glow again after each game SetIngredientsGlow(true); }
//Spawns ingredients void SpawnIngredients() { //Creates a temporary object to instantiate GameObject tempObj; tempObj = new GameObject(); MenuScript.IngredientType tempType = MenuScript.IngredientType.bat; //Loops through all ingredients from the current dish and sets tempobj to it and instantiats it foreach (MenuScript.IngredientType i in currentDish.ingredients) { switch (i) { case MenuScript.IngredientType.bat: tempObj = ingredient0; tempType = MenuScript.IngredientType.bat; break; case MenuScript.IngredientType.blood: tempObj = ingredient1; tempType = MenuScript.IngredientType.blood; break; case MenuScript.IngredientType.brain: tempObj = ingredient2; tempType = MenuScript.IngredientType.brain; break; case MenuScript.IngredientType.carrot: tempObj = ingredient3; tempType = MenuScript.IngredientType.carrot; break; case MenuScript.IngredientType.eye: tempObj = ingredient4; tempType = MenuScript.IngredientType.eye; break; case MenuScript.IngredientType.goblin: tempObj = ingredient5; tempType = MenuScript.IngredientType.goblin; break; case MenuScript.IngredientType.lice: tempObj = ingredient6; tempType = MenuScript.IngredientType.lice; break; case MenuScript.IngredientType.ingredient: tempObj = ingredient7; tempType = MenuScript.IngredientType.ingredient; break; case MenuScript.IngredientType.key: tempObj = ingredient8; tempType = MenuScript.IngredientType.key; break; case MenuScript.IngredientType.mystery: tempObj = ingredient9; tempType = MenuScript.IngredientType.mystery; break; case MenuScript.IngredientType.rat: tempObj = ingredient10; tempType = MenuScript.IngredientType.rat; break; case MenuScript.IngredientType.skull: tempObj = ingredient11; tempType = MenuScript.IngredientType.skull; break; } GameObject tempInstance = Instantiate <GameObject>(tempObj, spawnPositions[currentPos], Quaternion.identity); tempInstance.GetComponent <Item>().Type = tempType; currentPos++; } currentPos = 0; }