Ejemplo n.º 1
0
    /// <summary>
    /// Called by the animator when we are ready to spawn food
    /// </summary>
    public void AnimatorSpawnFood()
    {
        if (_foodSpawnQueue.Count == 0 || !isOpen || !_isFiring)
        {
            return;
        }



        UpdateAnimatorSpeed();

        FoodSpawnDefinition food = _foodSpawnQueue.Dequeue();

        FoodObject newFood = Instantiate(foodPrefab.gameObject).GetComponent <FoodObject>();

        newFood.transform.position = spawnPoint.position;
        newFood.GetComponent <Rigidbody>().AddForce(spawnPoint.forward * spawnForce * (Random.value + 1f), ForceMode.Impulse);
        newFood.spawner = this;

        newFood.SetColor(food.color);

        foodInScene.Add(newFood);
    }