示例#1
0
    void Search_last_empty_tile_under_me()
    {
        for (int yy = 1; (_y + yy) <= board._Y_tiles - 1; yy++)//scan tiles under me
        {
            if ((board.board_array_master[_x, (_y + yy), 0] == -1) || //if I find no tile
                (board.board_array_master[_x, _y + yy, 1] >= 0))    //or a tile with something
            {
                //move the gem on the tile next up the last tile scanned
                board.board_array_master[_x, _y + yy - 1, 1] = board.board_array_master[_x, _y, 1];
                //color from old tile position
                board.board_array_master[_x, _y, 1] = -99;

                //special
                board.board_array_master[_x, _y + yy - 1, 4] = board.board_array_master[_x, _y, 4];
                board.board_array_master[_x, _y, 4]          = 0;

                //the gem go in the new tile position
                board.board_array_master[_x, _y + yy - 1, 10] = 1;
                //empty the old tile position
                board.board_array_master[_x, _y, 10] = 0;

                //show the falling animation
                tile_C tile_script = (tile_C)board.tiles_array[_x, (_y + yy - 1)];
                tile_script.my_gem          = my_gem;
                tile_script.my_gem_renderer = tile_script.my_gem.GetComponent <SpriteRenderer>();
                tile_script.Update_gem_position();
                my_gem = null;

                break;
            }
            else if ((_y + yy) == board._Y_tiles - 1) //if I'm on the last row
            {
                //move gem color on last tile
                board.board_array_master[_x, _y + yy, 1] = board.board_array_master[_x, _y, 1];
                //remove color from old tile
                board.board_array_master[_x, _y, 1] = -99;

                //special
                board.board_array_master[_x, _y + yy - 1, 4] = board.board_array_master[_x, _y, 4];
                board.board_array_master[_x, _y, 4]          = 0;

                //gem go in the new position
                board.board_array_master[_x, _y + yy, 10] = 1;
                //empty the old tile
                board.board_array_master[_x, _y, 10] = 0;


                //show falling animation
                tile_C tile_script = (tile_C)board.tiles_array[_x, (_y + yy)];
                tile_script.my_gem          = my_gem;
                tile_script.my_gem_renderer = tile_script.my_gem.GetComponent <SpriteRenderer>();
                my_gem = null;
                tile_script.my_gem.transform.parent = tile_script.transform;
                tile_script.Update_gem_position();


                break;
            }
        }
    }
示例#2
0
    public void Fall_by_one_step(int fall_direction)//0 down, 1 down R, 2 down L
    {
        //Debug.Log("Fall_by_one_step");
        if (fall_direction == 0)
        {
            //move the gem on the tile next up the last tile scanned
            board.board_array_master[_x, _y + 1, 1] = board.board_array_master[_x, _y, 1];
            //color from old tile position
            board.board_array_master[_x, _y, 1] = -99;

            //special
            board.board_array_master[_x, _y + 1, 4] = board.board_array_master[_x, _y, 4];
            board.board_array_master[_x, _y, 4]     = 0;

            //the gem go in the new tile position
            board.board_array_master[_x, _y + 1, 10] = 1;
            //empty the old tile position
            board.board_array_master[_x, _y, 10] = 0;

            //show the falling animation
            tile_C tile_script = (tile_C)board.tiles_array[_x, _y + 1];
            tile_script.my_gem          = my_gem;
            tile_script.my_gem_renderer = tile_script.my_gem.GetComponent <SpriteRenderer>();
            my_gem = null;

            board.board_array_master[_x, _y + 1, 11] = board.board_array_master[_x, _y, 11];
            board.board_array_master[_x, _y, 11]     = 0;

            tile_script.Update_gem_position();
        }
        else if (fall_direction == 1)
        {
            //move the gem on the tile next up the last tile scanned
            board.board_array_master[_x + 1, _y + 1, 1] = board.board_array_master[_x, _y, 1];
            //color from old tile position
            board.board_array_master[_x, _y, 1] = -99;

            //special
            board.board_array_master[_x + 1, _y + 1, 4] = board.board_array_master[_x, _y, 4];
            board.board_array_master[_x, _y, 4]         = 0;

            //the gem go in the new tile position
            board.board_array_master[_x + 1, _y + 1, 10] = 1;
            //empty the old tile position
            board.board_array_master[_x, _y, 10] = 0;

            //show the falling animation
            tile_C tile_script = (tile_C)board.tiles_array[_x + 1, _y + 1];
            tile_script.my_gem          = my_gem;
            tile_script.my_gem_renderer = tile_script.my_gem.GetComponent <SpriteRenderer>();
            my_gem = null;

            board.board_array_master[_x + 1, _y + 1, 11] = board.board_array_master[_x, _y, 11];
            board.board_array_master[_x, _y, 11]         = 0;

            tile_script.Update_gem_position();
        }
        else if (fall_direction == 2)
        {
            //move the gem on the tile next up the last tile scanned
            board.board_array_master[_x - 1, _y + 1, 1] = board.board_array_master[_x, _y, 1];
            //color from old tile position
            board.board_array_master[_x, _y, 1] = -99;

            //special
            board.board_array_master[_x - 1, _y + 1, 4] = board.board_array_master[_x, _y, 4];
            board.board_array_master[_x, _y, 4]         = 0;

            //the gem go in the new tile position
            board.board_array_master[_x - 1, _y + 1, 10] = 1;
            //empty the old tile position
            board.board_array_master[_x, _y, 10] = 0;

            //show the falling animation
            tile_C tile_script = (tile_C)board.tiles_array[_x - 1, _y + 1];
            tile_script.my_gem          = my_gem;
            tile_script.my_gem_renderer = tile_script.my_gem.GetComponent <SpriteRenderer>();
            my_gem = null;

            board.board_array_master[_x - 1, _y + 1, 11] = board.board_array_master[_x, _y, 11];
            board.board_array_master[_x, _y, 11]         = 0;

            tile_script.Update_gem_position();
        }

        //board.number_of_gems_to_move--;
    }
示例#3
0
    public void Make_fall_all_free_gems_over_this_empty_tile()
    {
        bool leader_tile_become_empty  = false;
        bool leader_tile_become_active = false;
        int  number_of_gems_that_fall_in_this_column = 0;

        for (int yy = _y; yy >= 0; yy--)//look all tiles over me
        {
            //interrupt the count if
            if ((board.board_array_master[_x, yy, 0] == -1) ||// no tile
                (board.board_array_master[_x, yy, 1] >= 0) && (board.board_array_master[_x, yy, 10] == 0))    //or this thing can't fall
            {
                break;
            }
            else //vertical falling
            {
                board.board_array_master[_x, yy, 13] = 1; //annotate this tile as checked

                if (board.board_array_master[_x, yy, 10] == 1) //if there is something that can fall
                {
                    //update gem position
                    //gem color go in this tile
                    board.board_array_master[_x, _y - number_of_gems_that_fall_in_this_column, 1] = board.board_array_master[_x, yy, 1];
                    //cancell gem color from old starting tile
                    board.board_array_master[_x, yy, 1] = -99;
                    //pass special
                    board.board_array_master[_x, _y - number_of_gems_that_fall_in_this_column, 4] = board.board_array_master[_x, yy, 4];
                    //cancel special
                    board.board_array_master[_x, yy, 4] = 0;
                    //new gem position
                    board.board_array_master[_x, _y - number_of_gems_that_fall_in_this_column, 10] = 1;
                    //cancell gem from old starting tile
                    board.board_array_master[_x, yy, 10] = 0;
                    //update falling block hp
                    board.board_array_master[_x, _y - number_of_gems_that_fall_in_this_column, 14] = board.board_array_master[_x, yy, 14];
                    board.board_array_master[_x, yy, 14] = 0;


                    //now show the gem avatar fall
                    tile_C script_destination_tile = (tile_C)board.tiles_array[_x, (_y - number_of_gems_that_fall_in_this_column)];
                    tile_C script_origin_tile      = (tile_C)board.tiles_array[_x, yy];
                    //link the avatar to new tile
                    script_destination_tile.my_gem          = script_origin_tile.my_gem;
                    script_destination_tile.my_gem_renderer = script_destination_tile.my_gem.GetComponent <SpriteRenderer>();
                    //unlik the avater from the old tile
                    script_origin_tile.my_gem = null;
                    //Debug.Log("Make_fall_all_free_gems_over_this_empty_tile");
                    //Debug.Log("Origin tile x = " + _x + ", y = " + yy);
                    //start the animation
                    script_destination_tile.Update_gem_position();


                    //update gem moved count
                    number_of_gems_that_fall_in_this_column++;

                    //if a leader tile become empty, create a new gem
                    if (board.board_array_master[_x, yy, 12] == 1)//if this i a leader tile
                    {
                        leader_tile_become_empty = true;
                        if (board.gem_emitter_rule != Board_C.gem_emitter.off)
                        {
                            script_origin_tile.SetCreateFallingGem();
                        }
                        else
                        {
                            board.number_of_new_gems_to_create = 0;
                        }
                    }
                }

                else if (!leader_tile_become_empty && !leader_tile_become_active)
                {
                    if ((board.board_array_master[_x, yy, 1] == -99) &&   //this tile is empty
                        (board.board_array_master[_x, yy, 12] == 1))   //and is a leader tile
                    {
                        if (board.gem_emitter_rule != Board_C.gem_emitter.off)
                        {
                            tile_C script_native_tile = (tile_C)board.tiles_array[_x, yy];
                            script_native_tile.SetCreateFallingGem();
                            leader_tile_become_active = true;
                        }
                        else
                        {
                            board.number_of_new_gems_to_create = 0;
                            If_all_explosion_are_completed();
                        }
                    }
                }
            }
        }
    }