Пример #1
0
 public SerialisableTile(string id,
                         SerialisableTileMainMaterial mainMaterial,
                         List <SerialisableTileAttribute> tileAttributes,
                         List <SerialisableTileBackground> tileBackgrounds,
                         List <SerialisableTileCornerFiller> tileCornerFillers,
                         int gridLocationX, int gridLocationY)
 {
     Id                = id;
     MainMaterial      = mainMaterial;
     TileAttributes    = tileAttributes;
     TileBackgrounds   = tileBackgrounds;
     TileCornerFillers = tileCornerFillers;
     GridLocation      = new SerialisableGridLocation(gridLocationX, gridLocationY);
 }
Пример #2
0
    public SerialisableTile(Tile tile)
    {
        Id                = tile.TileId;
        MainMaterial      = SerialiseMainMaterial(tile);
        TileAttributes    = SerialiseTileAttributes(tile);
        TileBackgrounds   = SerialiseTileBackgrounds(tile);
        TileCornerFillers = SerialiseTileCornerFillers(tile);
        TileAreaIds       = SerialiseTileAreaIds(tile);

        GridLocation = new SerialisableGridLocation(tile.GridLocation.X, tile.GridLocation.Y);

        if (tile is IMazeLevel)
        {
            List <EditorMazeTile> tilesToTransform = MazeLevelGameplayManager.Instance.EditorLevel.FindTilesToTransform(tile as EditorMazeTile);
            TilesToTransform = SerialiseTilesToTransform(tilesToTransform);
        }
    }
Пример #3
0
    private ITileMainMaterial AddMainMaterial(SerialisableTile serialisableTile)
    {
        SerialisableTileMainMaterial serialisableMainMaterial = serialisableTile.MainMaterial;

        if (serialisableMainMaterial.MainMaterialType == "GroundMainMaterial")
        {
            return(new GroundMainMaterial());
        }
        else if (serialisableMainMaterial.MainMaterialType == "WaterMainMaterial")
        {
            return(new WaterMainMaterial());
        }
        else
        {
            Logger.Error($"Unknown SerialisableTileMainMaterial {serialisableMainMaterial.MainMaterialType}");
            return(null);
        }
    }
    public void GenerateTiles()
    {
        if (_gridWidth < 3)
        {
            Logger.Warning(Logger.Level, "Cannot generate a tile grid with a width of {0}. The minimum generatable grid width is 3", _gridWidth);
            return;
        }

        if (_gridWidth > 25)
        {
            Logger.Warning(Logger.Level, "Cannot generate a tile grid with a width of {0}. The maximum generatable grid width is 20", _gridWidth);
            return;
        }

        if (_gridHeight < 3)
        {
            Logger.Warning(Logger.Level, "Cannot generate a tile grid with a height of {0}. The minimum generatable grid height is 3", _gridHeight);
            return;
        }

        if (_gridHeight > 25)
        {
            Logger.Warning(Logger.Level, "Cannot generate a tile grid with a height of {0}. The maximum generatable grid height is 20", _gridHeight);
            return;
        }

        Logger.Log("Generate tile grid with a width of {0} and a height of {1}", _gridWidth, _gridHeight);

        // remove everything from the currently loaded level
        OverworldGameplayManager.Instance.UnloadOverworld();

        // Create a new level from scratch with a obstacle ring at the edges
        List <SerialisableTile> tiles = new List <SerialisableTile>();

        for (int i = 0; i < _gridWidth; i++)
        {
            for (int j = 0; j < _gridHeight; j++)
            {
                string tileId = Guid.NewGuid().ToString();

                GridLocation gridLocation = new GridLocation(i, j);
                SerialisableTileMainMaterial mainMaterial = new SerialisableTileMainMaterial("GroundMainMaterial", new SerialisableLandMaterial());

                List <SerialisableTileAttribute>    tileAttributes    = new List <SerialisableTileAttribute>();
                List <SerialisableTileBackground>   tileBackgrounds   = new List <SerialisableTileBackground>();
                List <SerialisableTileCornerFiller> tileCornerFillers = new List <SerialisableTileCornerFiller>();

                SerialisableTileBaseGround baseBackground = TryAddBaseBackgroundForNewOverworld(tileBackgrounds, tileAttributes);

                if (baseBackground != null)
                {
                    tileBackgrounds.Add(new SerialisableTileBackground(baseBackground.GetType().ToString(), baseBackground));
                }

                SerialisableTile tile = new SerialisableTile(tileId, mainMaterial, tileAttributes, tileBackgrounds, tileCornerFillers, gridLocation.X, gridLocation.Y);
                tiles.Add(tile);
            }
        }

        OverworldData newOverworldData = new OverworldData();

        newOverworldData.Tiles = tiles;

        OverworldLoader.LoadOverworldForEditor(newOverworldData);
    }