Example #1
0
        public async Task <BurgerPatty> CookOrUseExistingPatty(BurgerPatty patty) //T>(T patty)//decimal weight, bool cheese)
        {
            //var existing = _patties.FirstOrDefault(x => x.Cheese == cheese && x.Weight == weight);
            var existing = _patties.Contains(patty); // .FirstOrDefault(x => x == patty);

            //if (existing != null)
            if (existing)
            {
                _logger.LogDebug($"Using existing patty {patty}"); //{Weight} {Cheese}", existing.Weight, existing.Cheese);

                _patties.Remove(patty);
                return(patty);
            }

            //_logger.LogDebug("Grilling patty {Weight} {Cheese}", weight, cheese);
            _logger.LogDebug("Grilling patty {patty}", patty);

            await Task.Delay((int)patty.CookTime()); //5000 + (int)(1000.0m * weight));

            // We should probably be making a new object and passing in properties from this method
            // var newPatty = new BurgerPatty
            // {
            //     Weight = weight,
            //     Cheese = cheese
            // };

            //return newPatty;
            return(patty);
        }
Example #2
0
    /// <summary>
    /// Starts the colour/smoke changing on the new side after a flip
    /// </summary>
    public IEnumerator StartNewSide()
    {
        _rigidBody.isKinematic = false;

        // flip the side index
        _sideIndex = (_sideIndex == 0) ? 1 : 0;

        yield return(new WaitForSeconds(1));

        var threshold = BurgerPatty.MaxCookedLevel(_type);

        // check if a burger exists
        if (gameObject.activeInHierarchy)
        {
            // carry on with the smoke
            if (r[_sideIndex] < threshold)
            {
                _smokeCoroutine = StartCoroutine(Smoke_());

                _smokeRate = 0.1f * 2.5f;
            }
            else
            {
                // if not smoking, we return to invisible smoke
                var main = _particles.main;
                main.startColor = _smokeColours[_sideIndex];

                _smokeRate = 0.1f;
            }

            StartCooking_();
        }
    }
Example #3
0
        public async Task <BurgerPatty> CookOrUseExistingPatty(decimal weight, bool cheese)
        {
            var existing = _patties.FirstOrDefault(x => x.Cheese == cheese && x.Weight == weight);

            if (existing != null)
            {
                _logger.LogDebug("Using existing patty {Weight} {Cheese}", existing.Weight, existing.Cheese);

                _patties.Remove(existing);
                return(existing);
            }

            _logger.LogDebug("Grilling patty {Weight} {Cheese}", weight, cheese);

            var patty = new BurgerPatty
            {
                Weight = weight,
                Cheese = cheese
            };

            return(patty);
        }
    /// <summary>
    /// Spawn a patty
    /// </summary>
    void SpawnBurger_()
    {
        var activeBurger = Chef.Burgers[_selectedPattyIndex];

        // temperature gets done at the end
        BurgerPatty patty   = new BurgerPatty(activeBurger.GetBurgerType(), new float[] { activeBurger.GetBurgerColour().r, activeBurger.GetBurgerColourBack().r }, 0, activeBurger.GetBurgerColour());
        var         spawned = SpawnSomething_(LicenseToGrillController.Instance.FoodPlateBurgerPrefab, LicenseToGrillController.Instance.Burgers[0], patty, false);

        // check the index is valid
        if (_selectedPattyIndex > -1)
        {
            // set colour of the burger
            var renderers = spawned.GetComponentsInChildren <SpriteRenderer>();
            renderers[0].color = activeBurger.GetBurgerColour();
            renderers[1].color = activeBurger.GetBurgerColourBack();
            renderers[2].color = activeBurger.GetBurgerColourGrill();

            // set sprite of the burger
            renderers[0].sprite = activeBurger.Renderer.sprite;
            renderers[1].sprite = activeBurger.RendererUnder.sprite;
        }
    }
Example #5
0
    /// <summary>
    /// Looks for a patty matching the specified patty
    /// </summary>
    /// <param name="item">The item to search for</param>
    /// <param name="itemsServed">List of items that were included in the burger</param>
    /// <param name="complaints">Reference to the list of complaints/differences between the created and requested burgers</param>
    /// <returns>Whether a match was found</returns>
    static bool ComparePattys_(BurgerPatty item, ref List <object> itemsServed, ref List <BurgerComplaint> complaints)
    {
        bool   matchFound = false;
        bool   oneExists  = false;
        Sprite sprite     = null;
        Color  colour     = new Color(0, 0, 0);

        // loop through list of created items
        for (var i = 0; i < itemsServed.Count; i++)
        {
            // find a patty
            if (itemsServed[i] is BurgerPatty)
            {
                // we've found one, so we can complain if it does not match
                oneExists = true;

                var patty = (itemsServed[i] as BurgerPatty);

                // compare types
                if (patty.GetBurgerType() == ((item as BurgerPatty).GetBurgerType()))
                {
                    // we have found a match
                    matchFound = true;
                    sprite     = LicenseToGrillController.Instance.Burgers[(int)(itemsServed[i] as BurgerPatty).GetBurgerType()];
                    colour     = patty.Colour();
                    itemsServed.RemoveAt(i);
                    break;
                }
            }
        }

        // if there is no match, and one was found of the wrong type, add a complaint
        if (!matchFound && oneExists)
        {
            complaints.Add(new BurgerComplaint(DEDUCTION_WRONG_PATTY, REASON_WRONG_PATTY, sprite, colour));
        }

        return(oneExists);
    }
Example #6
0
    /// <summary>
    /// Changes the r aspect of the colour
    /// </summary>
    IEnumerator ColourRed_()
    {
        // wait briefly
        yield return(new WaitForSeconds(1));

        var threshold = BurgerPatty.MaxCookedLevel(_type);

        // loop until zero
        while (r[_sideIndex] > 0)
        {
            r[_sideIndex] -= 0.0075f;

            CookedSliders[_sideIndex].localPosition = new Vector3(CookedSliders[_sideIndex].localPosition.x, 0.5f + (0 - r[_sideIndex]), CookedSliders[_sideIndex].localPosition.z);

            yield return(new WaitForSeconds(_smokeRate * 2f));

            // when reaches a certain point, start smoking
            if (r[_sideIndex] < threshold && !_smoking)
            {
                _smokeRate     *= 2.5f;
                _smokeCoroutine = StartCoroutine(Smoke_());
            }
        }
    }
Example #7
0
 public void Add(BurgerPatty patty)
 {
     _patties.Add(patty);
 }
Example #8
0
    /// <summary>
    /// Assesses if a burger is cooked correctly
    /// </summary>
    /// <param name="created">The burger that was created</param>
    /// <param name="complaints">Reference to the list of complaints/differences between the created and requested burgers</param>
    private static void AssessBurgerCooked_(BurgerConstruction created, ref List <BurgerComplaint> complaints)
    {
        // loop through all items in the created burger
        foreach (var item in created.GetItems())
        {
            // find all pattys
            if (item is BurgerPatty)
            {
                var patty = item as BurgerPatty;

                // if colder than allowed, add a complaint
                if (patty.Heat() < MIN_HEAT_THRESHOLD)
                {
                    // lose points based on how cold it is
                    var percentage = (MIN_HEAT_THRESHOLD - patty.Heat()) / MIN_HEAT_THRESHOLD;
                    complaints.Add(new BurgerComplaint((int)(DEDUCTION_COLD * percentage), REASON_COLD, LicenseToGrillController.Instance.Burgers[(int)patty.GetBurgerType()], patty.Colour()));
                }

                // find the range of perfectly cooked
                var min = BurgerPatty.MinCookedLevel(patty.GetBurgerType());
                var max = BurgerPatty.MaxCookedLevel(patty.GetBurgerType());

                int uncooked   = 0;
                int overcooked = 0;
                int burnt      = 0;

                // check each side of the patty and look for sides that are under/over cooked, or completely burnt
                foreach (var side in patty.CookedLevel())
                {
                    if (side < min && side > burnt)
                    {
                        uncooked++;
                    }
                    else if (side < burnt)
                    {
                        burnt++;
                    }
                    else if (side > max)
                    {
                        uncooked++;
                    }
                    // otherwise, good.
                }

                // if any sides uncooked, add complaint
                if (uncooked > 0)
                {
                    var msg    = uncooked == 2 ? "Both sides" : "One side";
                    var sprite = LicenseToGrillController.Instance.Burgers[(int)patty.GetBurgerType()];
                    complaints.Add(new BurgerComplaint(DEDUCTION_UNCOOKED * uncooked, REASON_UNCOOKED_PREFIX + msg, sprite, patty.Colour()));
                }
                // if any sides burnt, add complaint
                if (burnt > 0)
                {
                    var msg    = burnt == 2 ? "Both sides" : "One side";
                    var sprite = LicenseToGrillController.Instance.Burgers[(int)patty.GetBurgerType()];
                    complaints.Add(new BurgerComplaint(DEDUCTION_BURNED * burnt, REASON_BURNED_PREFIX + msg, sprite, patty.Colour()));
                }
                // if any sides overcooked, add complaint
                if (overcooked > 0)
                {
                    var msg    = overcooked == 2 ? "Both sides" : "One side";
                    var sprite = LicenseToGrillController.Instance.Burgers[(int)patty.GetBurgerType()];
                    complaints.Add(new BurgerComplaint(DEDUCTION_OVERCOOKED * overcooked, REASON_OVERCOOKED_PREFIX + msg, sprite, patty.Colour()));
                }
            }
        }
    }