Пример #1
0
        public Map(string filename, ContentManager content)
        {
            map = Squared.Tiled.Map.Load(filename, content);

            //order tilesets by the first tile id. needed for tile collision
            tilesets = map.Tilesets.OrderBy((item) => item.Value.FirstTileID).ToDictionary(i => i.Key, i => i.Value);

            Tiles     = new Tile[map.Height, map.Width];
            Enemies   = new InitialEnemy[map.ObjectGroups["enemies"].Objects.Count];
            NavMesh   = new Graph <Platform>();
            Platforms = new List <Platform>();

            LoadContent();
        }
Пример #2
0
    // TODO: something to indicate how the two maps connect, for a fancy transition type thing
    public void MapSwitch(string mapname)
    {
        map = Squared.Tiled.Map.Load(mapname, Content);
        mapfilename = mapname;

        obstructionTiles.FirstTileID = map.Tilesets["obstiles"].FirstTileID;
        obstructionTiles.tileWidth = map.TileWidth;
        obstructionTiles.tileHeight = map.TileHeight;

        // nuke all existing entities, except the player
        entities.Clear();
        entities.Add(player);

        foreach (var og in map.ObjectGroups) {
            foreach (var o in og.Value.Objects) {
                SpawnEntity(o.Value);
            }
        }
    }