Ejemplo n.º 1
0
    public void Save()
    {
        print("Saving");
        ArrayList current_positions_array = new ArrayList();
        ArrayList final_positions_array   = new ArrayList();

        if (current_positions.Count < final_positions.Count)
        {
            print("Finales: " + final_positions.Count);
            print("Fichas: " + current_positions.Count);
            print("Bad Map, not saving");
            return;
        }
        else if (current_positions.Count > final_positions.Count)
        {
            print("Finales: " + final_positions.Count);
            print("Fichas: " + current_positions.Count);
            print("Bad Map, not saving");
            return;
        }
        foreach (string item in current_positions)
        {
            current_positions_array.Add(new Vector2(int.Parse(item.Substring(0, 2)), int.Parse(item.Substring(2, 2))));
        }

        foreach (string item in final_positions)
        {
            final_positions_array.Add(new Vector2(int.Parse(item.Substring(0, 2)), int.Parse(item.Substring(2, 2))));
        }
        LevelMap m = new LevelMap(level_width, level_height, current_positions_array, final_positions_array);

        if (setup_canvas_controller.current_maps_hash.Contains(m.map_id))
        {
            print("Map exists already, will not be saved");
        }
        else
        {
            m.Save("map_" + (setup_canvas_controller.current_maps_hash.Count + 1) + ".map");
            setup_canvas_controller.current_maps_hash.Add(m.map_id);
            SetupCanvasController.CreateMapSet();
            print("Map saved");
        }
    }
Ejemplo n.º 2
0
    public void Create()
    {
        int random_level_width, maps_to_create = number_of_maps.text == "" ? 20 : int.Parse(number_of_maps.text);
        int level_width  = int.Parse(width.text);
        int level_height = int.Parse(height.text);

        while (maps_to_create > 0)
        {
            random_level_width = UnityEngine.Random.Range(2, 4);

            LevelMap m =
                LevelMap.GetRandomMap(level_width, level_height);
            if (!current_maps_hash.Contains(m.map_id))
            {
                m.Save("map_" + (current_maps_hash.Count + 1) + ".map");
                print("MAP CREATED: " + m.map_id);
                current_maps_hash.Add(m.map_id);
                maps_to_create--;
            }
        }
        SetupCanvasController.CreateMapSet();
    }