Esempio n. 1
0
    private void SpawnFood(bool specialMode)
    {
        do
        {
            foodPosition = new Vector2Int(2 * Random.Range(1, width / 2), 2 * Random.Range(1, height / 2));
        } while (snake.GetListSnakePosition().IndexOf(foodPosition) != -1);

        foodImg = new GameObject("Food", typeof(SpriteRenderer));
        if (specialMode)
        {
            foodImg.GetComponent <SpriteRenderer>().sprite = GameAssets.instance.snakeFoodSpriteSpecial;
        }
        else
        {
            foodImg.GetComponent <SpriteRenderer>().sprite = GameAssets.instance.snakeFoodSprite;
        }
        foodImg.transform.position = new Vector3(foodPosition.x, foodPosition.y, 0);
    }