Exemplo n.º 1
0
    /*
     * Generates the soldier grid with the following values
     *
     * Dir					Which direction the grid is travelling in (left / right)
     * diff_low				lowest number of arrows before the split
     * diff_high			highest number of arrows before the split
     * branch_width_low		lowest number of arrows after the split
     * branch_width_high	highest number of arrows after the split
     */
    private void NormalGrid(Constants.Direction dir, int diff_low, int diff_high, int branch_width_low, int branch_width_high)
    {
        int a, b, c, diff;

        pos    = 0;
        branch = 2;

        diff = Random.Range(diff_low, diff_high + 1);
        a    = 1 + diff + Random.Range(branch_width_low, branch_width_high);
        b    = 1 + diff + Random.Range(branch_width_low, branch_width_high + 1);
        c    = 1 + diff + Random.Range(branch_width_low, branch_width_high);

        GridIndex arrow = GridIndex.RIGHT;

        if (dir == Constants.Direction.LEFT)
        {
            arrow = GridIndex.LEFT;
        }

        for (int i = 0; i < Constants.GRID_WIDTH; i++)
        {
            if (i < diff)
            {
                grid[2, i] = arrow;
            }
            else if (i == diff)
            {
                grid[1, i] = GridIndex.UP;
                grid[2, i] = arrow;
                grid[3, i] = GridIndex.DOWN;
            }
            else
            {
                if (i == b)
                {
                    endPoints[2] = balance.GetEndpoint();
                    grid[2, i]   = GridIndex.END;
                }
                else if (i < b)
                {
                    grid[2, i] = arrow;
                }

                if (i == a)
                {
                    endPoints[1] = balance.GetEndpoint();
                    grid[1, i]   = GridIndex.END;
                }
                else if (i < a)
                {
                    grid[1, i] = arrow;
                }

                if (i == c)
                {
                    endPoints[3] = balance.GetEndpoint();
                    grid[3, i]   = GridIndex.END;
                }
                else if (i < c)
                {
                    grid[3, i] = arrow;
                }
            }
        }
        grid[2, 0] = (arrow == GridIndex.LEFT) ? GridIndex.S_LEFT : GridIndex.S_RIGHT;
    }