Example #1
0
        // 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);
                }
            }
        }
Example #2
0
 /// <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));
 }
Example #3
0
 /// <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;
 }
Example #4
0
 private void SetState(OvenState newState)
 {
     CurrentState = newState;
 }
Example #5
0
 // Use this for initialization
 void Start()
 {
     currentState = OvenState.Idle;
 }
Example #6
0
        /// <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);
        }