コード例 #1
0
ファイル: MapLoader.cs プロジェクト: balorian/Ludum24
        internal static void decodeMap(Map map, MapData mapData, Color[,] rawMap)
        {
            map.Width = rawMap.GetLength(0);
            map.Height = rawMap.GetLength(1);
            map.TileMap = new Tile[map.Width, map.Height];

            for (int y = 0; y < rawMap.GetLength(1); y++)
            {
                for (int x = 0; x < rawMap.GetLength(0); x++)
                {
                    TileType type = TileType.none;
                    COLOR_DECODER.TryGetValue(rawMap[x, y], out type);
                    map.TileMap[x, y] = new Tile(map, type, new Vector2(x * GameState.TILE_SIZE, y * GameState.TILE_SIZE), mapData.levelTemplate);
                }
            }

            chooseFrames(map);
        }
コード例 #2
0
ファイル: MapLoader.cs プロジェクト: balorian/Ludum24
        public static Map loadRawMap(MapData mapData, GameScreen parent)
        {
            Map map = new Map(mapData.name, parent);
            Texture2D mapTexture = Engine.Content.Load<Texture2D>("levels/maps/" + mapData.mapImage);
            Color[] colors1D = new Color[mapTexture.Width * mapTexture.Height];
            mapTexture.GetData<Color>(colors1D);
            Color[,] rawMap = new Color[mapTexture.Width, mapTexture.Height];
            for (int x = 0; x < mapTexture.Width; x++)
                for (int y = 0; y < mapTexture.Height; y++)
                    rawMap[x, y] = colors1D[x + y * mapTexture.Width];
            decodeMap(map, mapData, rawMap);

            Dictionary<String, SpawnPoint> spawns = new Dictionary<string,SpawnPoint>();
            foreach(SpawnPoint point in mapData.spawnPoints){
                spawns.Add(point.name, point);
            }
            map.SpawnPoints = spawns;
            map.LevelDoors = mapData.exitPoints;

            return map;
        }