Пример #1
0
    //Generates food on a random free spot
    public static void generateFood(headController head)
    {
        int counter   = 0;
        int rightSpot = Random.Range(0, freeSpaceLeft);

        for (int y = 1; y <= 10; ++y)
        {
            for (int x = 1; x <= 18; ++x)
            {
                if (grid[y][x] == FREE)
                {
                    if (counter == rightSpot)
                    {
                        grid[y][x] = FOOD;
                        freeSpaceLeft--;
                        head.makeFood(x, y);
                        return;
                    }
                    counter++;
                }
            }
        }
    }
Пример #2
0
 void Start()
 {
     tr_left  = go_left.GetComponent <Transform>();
     tr_right = go_right.GetComponent <Transform>();
     c_head   = FindObjectOfType <headController>();
 }
Пример #3
0
 void Start()
 {
     rb     = GetComponent <Rigidbody>();
     c_head = FindObjectOfType <headController>();
 }