Exemplo n.º 1
0
    public void loadLevel(string levelName)
    {
        //Destroy the world!!
        destroyCurrentWorld();

        //Create the new one from WorldJsonUtility
        WorldJsonUtility.WorldJSONWrapper newMapWrapper = WorldJsonUtility.loadLevelData(worldMap, levelName);

        //Properly initialize it into the game
        worldMap.updateMapFromJsonWrapper(newMapWrapper);

        loadSelect.SetActive(false);
        currentAction = action.None;
    }
Exemplo n.º 2
0
    public void updateMapFromJsonWrapper(WorldJsonUtility.WorldJSONWrapper jsonWrapper)
    {
        //Manually walk through json, reating the grid and each tile
        this.height = jsonWrapper.height;
        this.width  = jsonWrapper.width;

        this.grid = new GameObject[(int)this.width, (int)this.height];
        List <WorldJsonUtility.TileJSONWrapper> tileWrapperList = jsonWrapper.tileList;

        foreach (WorldJsonUtility.TileJSONWrapper tileWrapper in tileWrapperList)
        {
            var x = tileWrapper.xCoor;
            var y = tileWrapper.yCoor;

            GameObject newGridTile = this.createNewGridTile(tileWrapper.tileType, x, y);
            this.grid[x, y] = newGridTile;
        }
    }