Example #1
0
 void assign_cells(cell[,] cells, Grid g)
 {
     int cell_count = 1;  // To keep a count of the no. of cells and assign them their indices accordingly
     for (int i=0; i<S; i++) {
         for (int j=0; j<S; j++, cell_count++) {
             cells [i, j].a_bline = g.blineH [i, j];
             cells [i, j].b_bline = g.blineH [i + 1, j];
             cells [i, j].l_bline = g.blineV [i, j];
             cells [i, j].r_bline = g.blineV [i, j + 1];
             cells [i, j].set = new set_i(cell_count);
             cells [i, j].cell_count = cell_count;
             cells [i, j].break_wall = true;
             is_down[cell_count-1] = new wentdown();
             is_down[cell_count-1].reply = false;
         }
     }
 }
Example #2
0
    void Start()
    {
        Y = new wentdown ();
        Y.reply = yes;
        N = new wentdown ();
        N.reply = no;
        timer = 0.0f;
        transform.localScale = new Vector3 (500, 1, 500);// Size and Location of Base Plate
        transform.localPosition = new Vector3 (50, 10, -50);

        au = GetComponents<AudioSource> ();

        grid =  ConstructGrid ();// Wireframe and Wall creation

        cells = new cell [S, S];// Matrix of empty cells
        assign_cells (cells, grid);// Filling of cells

        MazeGeneration(cells);// Generation of Maze

        Switches = new switch_[4];
        put_all_switches (cells, Switches);// Placing 'turned off' Switches

        exit = false;
    }
Example #3
0
    // Function to randomly merge a cell from a given row with the one just below it
    void go_down(int row, cell[,] cells)
    {
        if (Y.reply == no) {
            temp = Y;
            N.reply = yes;
            Y = N;
            N = temp;
            temp = null;
        } else {
            Y.reply = true;
            N.reply = false;
        }

        int i;
        for (i=0; i<S; i++) {
            //if (is_down [cells [row, i].set.index - 1] == N) {
            if (Random.Range (0, Random.Range (3, 5)) == 0) {
                merge_cells (cells [row, i], cells [row + 1, i], cells [row, i].b_bline, cells);
                is_down [cells [row, i].set.index - 1] = Y;
            }
            //}
        }

        //Checking if any set is left without being given a downward path
        for (i=0; i<S; i++) {
            if (!is_down[cells [row, i].set.index - 1].reply) {
                merge_cells (cells [row, i], cells [row + 1, i], cells [row, i].b_bline, cells);
                is_down[cells [row, i].set.index - 1] = Y;
            }
        }

        Y.reply = no;
    }