예제 #1
0
    public void LoadMap(int map_index)
    {
        // Si se carga el primer mapa se muestra la ayuda asociada
        if (map_index == 0)
        {
            ShowHelp();
        }
        else
        {
            HideHelp();
        }


        canvas.SetActive(false);
        generalCanvas.SetActive(false);
        //Se destruye el mapa anterior
        Destroy(levelBuilder.board);

        current_map = map_index;
        menu_controller.SetLevelNumber(map_index + 1);

        //MAP
        LevelMap m = new LevelMap().Load(GameManager.level_maps_factory.maps[map_index]);

        //int random_level_width = UnityEngine.Random.Range(2, 4);
        //LevelMap m =
        //    LevelMap.GetRandomMap(random_level_width,
        //        UnityEngine.Random.Range(random_level_width, random_level_width * UnityEngine.Random.Range(1, 3)));
        //m.Save("map_" + (level_maps_factory.maps.Length + ++created_map_index) + ".map");
        //SetupCanvasController.CreateMapSet();

        levelBuilder.BuildMap(m);
        int min = Math.Min(levelBuilder.board_resolution.width, levelBuilder.board_resolution.height);
        int max = Math.Max(levelBuilder.board_resolution.width, levelBuilder.board_resolution.height);

        Camera.main.orthographicSize =
            min + min * max / min;

        selection = new GameObject("Selection");
        selection.transform.parent = levelBuilder.board.transform;

        piece_size   = levelBuilder.half_piece_size * 2;
        piece_margin = levelBuilder.half_margin * 2;

        piece_started_index = 0;
        screen_fader.MakeTransition();
        current_state = level_start_state;
    }