예제 #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);
    }
예제 #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);
    }
예제 #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));
            }
        }
    }
예제 #4
0
 public void SetupSceneMap(SavedMap newMap)
 {
     initMap();
     map.LoadMapFromSavedMap(newMap);
     InitBoard();
 }
예제 #5
0
 public MapSaver(TextAsset asset)
 {
     map = DeserializeFromText(asset);
     CheckAndCreateFolders();
 }
예제 #6
0
 public MapSaver(SavedMap map)
 {
     this.map = map;
     CheckAndCreateFolders();
 }
예제 #7
0
 public MapSaver(int col, int row)
 {
     map = new SavedMap(col, row);
     CheckAndCreateFolders();
 }
예제 #8
0
 public void LoadMapFromSavedMap(SavedMap map)
 {
     initMapFormArray(map.GetMap());
     mirroMapViaY();
 }