Ejemplo n.º 1
0
        //Instantiation logic and reference assignment
        private void SpawnStackSlice(IngredientSo data)
        {
            var stackPosition = new Vector3(
                transform.position.x,
                transform.position.y + _stackedIngredients.Count * sliceHeightOffset,
                transform.position.z);
            IngredientSlice spawnedSlice = Instantiate(stackSlicePrefab, stackPosition, Quaternion.Euler(0, 270, 0))
                                           .GetComponent <IngredientSlice>();

            spawnedSlice.Initialize(data);
            Instantiate(particlePrefab, spawnedSlice.transform.position, Quaternion.identity);
            _stackedIngredients.Push(spawnedSlice);
        }
Ejemplo n.º 2
0
        //Returns a bool based on if the bread can and was placed successfully
        public bool TryPlaceSlice(IngredientSo data, Vector3 position)
        {
            if (HasWon)
            {
                _logManager.Log("Finish what you started! :D");
                return(true); // returns true to trigger the object to go back.
            }
            // Distance check to see if slice can be stacked
            if (Vector3.Distance(transform.position, position) > stackDistanceThreshold)
            {
                return(false);
            }

            if (_stackedIngredients.Count >= 0 && _stackedIngredients.Count < maxStackSize) //Error handling and limiting stack height
            {
                SpawnStackSlice(data);
                _audioManager.PlayPopSound();
                return(true);
            }
            _logManager.Log("Error : Sandwich Overflow \n Remove the top slice and seal the deal \n with another piece of bread!");
            return(false);
        }