Exemplo n.º 1
0
    /// <summary>
    /// Convert the grid on the screen to a map object
    /// </summary>
    /// <returns></returns>
    private SavedMap ConvertGridToMap()
    {
        SavedMap map = new SavedMap(col, row);

        for (int j = 0; j < row; j++)
        {
            for (int i = 0; i < col; i++)
            {
                map.SetTile(i, j, GetTileType(i, j));
            }
        }
        return(map);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Load a map from file
    /// </summary>
    /// <param name="fileName"></param>
    /// <param name="coustomMap"></param>
    /// <returns> false if the file dont exist otherwise true</returns>
    public bool LoadMap(string fileName, bool coustomMap = false)
    {
        if (!IsFileExist(fileName, coustomMap))
        {
            return(false);
        }
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.OpenRead(GetFilePath(coustomMap) + fileName);

        map = (SavedMap)bf.Deserialize(file);
        file.Close();
        return(true);
    }
Exemplo n.º 3
0
    /// <summary>
    /// Convert Map to the grid the mapeditor
    /// </summary>
    /// <param name="map"></param>
    private void ConvertMapToGrid(SavedMap map)
    {
        col = map.GetCol();
        row = map.GetRow();
        initGridLayout();

        for (int j = 0; j < row; j++)
        {
            for (int i = 0; i < col; i++)
            {
                GameObject newTile = GameObjectUtil.Instantiate(genricMapEditorButton, Vector2.zero, transform);
                newTile.transform.localScale = Vector3.one;
                newTile.GetComponent <TileMapEditorButton>().ChangeTile(map.GetTile(i, j));
            }
        }
    }
Exemplo n.º 4
0
 public void SetupSceneMap(SavedMap newMap)
 {
     initMap();
     map.LoadMapFromSavedMap(newMap);
     InitBoard();
 }
Exemplo n.º 5
0
 public MapSaver(TextAsset asset)
 {
     map = DeserializeFromText(asset);
     CheckAndCreateFolders();
 }
Exemplo n.º 6
0
 public MapSaver(SavedMap map)
 {
     this.map = map;
     CheckAndCreateFolders();
 }
Exemplo n.º 7
0
 public MapSaver(int col, int row)
 {
     map = new SavedMap(col, row);
     CheckAndCreateFolders();
 }
Exemplo n.º 8
0
 public void LoadMapFromSavedMap(SavedMap map)
 {
     initMapFormArray(map.GetMap());
     mirroMapViaY();
 }