// Update is called once per frame void Update() { if (playerEntered == true) { if (InputControls.APressed) { CharacterController2D character = player.GetComponent <CharacterController2D>(); if (character.info.holdingFood && this.currentState == OvenState.Idle && character.info.heldFood.currentState != Food.CookedState.Cooked) { timer = new TimedCooldown(100, character.info.heldFood.timeToCook, 0.1); timer.start(); this.heldFood = Instantiate(character.info.heldFood); //REPLACE WITH SOME FOOD RECIPE FUNCTION LATER; this.heldFood.gameObject.SetActive(false); Destroy(character.info.heldFood.gameObject); character.info.heldFood = null; this.currentState = OvenState.Cooking; } else if (character.info.holdingFood == false && this.currentState == OvenState.DoneCooking) { this.heldFood.gameObject.SetActive(true); Food nom = Instantiate(this.heldFood); nom.attatchToPlayer(); Destroy(this.heldFood.gameObject); this.currentState = OvenState.Idle; } } } if (timer != null) { if (timer.isReady() && this.heldFood != null) { Debug.Log("COOKING IS DONE!!! Cooked: " + this.heldFood.name); this.currentState = OvenState.DoneCooking; this.heldFood.cook(); } else { Debug.Log(timer.timeRemaining); } } }
/// <summary> /// The create. /// </summary> /// <param name="currentTemperature"> /// The current temperature. /// </param> /// <param name="state"> /// The state. /// </param> /// <param name="isWorkingTemperature"> /// The is working temperature. /// </param> /// <returns> /// The <see cref="Oven"/>. /// </returns> public static Oven Create(int currentTemperature = 0, OvenState state = OvenState.Off, bool isWorkingTemperature = false) { return(new Oven(currentTemperature, state, isWorkingTemperature)); }
/// <summary> /// Initializes a new instance of the <see cref="Oven"/> class. /// </summary> /// <param name="currentTemperature"> /// The current temperature. /// </param> /// <param name="state"> /// The state. /// </param> /// <param name="isWorkingTemperature"> /// The is working temperature. /// </param> private Oven(int currentTemperature, OvenState state, bool isWorkingTemperature) { this.CurrentTemperature = currentTemperature; this.State = state; this.IsWorkingTemperature = isWorkingTemperature; }
private void SetState(OvenState newState) { CurrentState = newState; }
// Use this for initialization void Start() { currentState = OvenState.Idle; }
/// <summary> /// The set state. /// </summary> /// <param name="maker"> /// The maker. /// </param> /// <param name="currentTemperature"> /// The current temperature. /// </param> /// <param name="state"> /// The state. /// </param> public static void SetState(BiscuitMakerObject maker, int currentTemperature, OvenState state) { var isWorkingTemperature = currentTemperature <= maker.Settings.OvenMaxTemp && currentTemperature >= maker.Settings.OvenMinTemp; var newOven = Oven.Create(currentTemperature, state, isWorkingTemperature); maker.Components.Remove(maker.FirstOven); maker.Components.Add(newOven); }