//shuffle gems when no move available void Shuffle()//call from Check_ALL_possible_moves() { if (!shuffle_ongoing) { if (!ShuffleSafetuCheck())//not safe { return; } shuffle_ongoing = true; //Debug.Log("shuffle"); for (int y = 0; y < _Y_tiles; y++) { for (int x = 0; x < _X_tiles; x++) { if ((board_array_master[x, y, 1] >= 0) && (board_array_master[x, y, 1] < 9) && //there is a gem (board_array_master[x, y, 3] == 0)) //and without padlock { number_of_gems_to_mix++; board_array_master[x, y, 1] = UnityEngine.Random.Range(0, gem_length); board_array_master[x, y, 4] = 0; //reset bonus Avoid_triple_color_gem(x, y); //update gem tile_C tile_script = (tile_C)tiles_array[x, y]; tile_script.SetShuffleUpdate(); } } } } }
void Gems_teleport() { if ((board.board_array_master[_x, _y, 1] >= 0) && (board.board_array_master[_x, _y, 1] < 9)) //is a gem { if (board.board_array_master[_x, _y, 3] == 0) //no padlock { if (board.main_gem_selected_x == -10) //select first gem { board.main_gem_selected_x = _x; board.main_gem_selected_y = _y; board.main_gem_color = board.board_array_master[_x, _y, 1]; //Debug.Log("teleport select first gem: " + _x + "," + _y); } else //select second gem { if ((board.main_gem_selected_x == _x) && (board.main_gem_selected_y == _y)) { //you have click on the same gem, so deselect it board.main_gem_selected_x = -10; board.main_gem_selected_y = -10; board.main_gem_color = -10; } else { //board.minor_gem_destination_to_x = _x; //board.minor_gem_destination_to_y = _y; board.minor_gem_color = board.board_array_master[_x, _y, 1]; //Debug.Log("teleport select second gem: " + _x + "," + _y); //activate teleport board.number_of_gems_to_mix = 2; board.player_can_move = false; //change gems board.board_array_master[_x, _y, 1] = board.main_gem_color; board.board_array_master[board.main_gem_selected_x, board.main_gem_selected_y, 1] = board.minor_gem_color; board.Play_bonus_sfx(2); //update gem SetShuffleUpdate(); tile_C tile_script = (tile_C)board.tiles_array[board.main_gem_selected_x, board.main_gem_selected_y]; tile_script.SetShuffleUpdate(); } } } } }