Пример #1
0
        public void CreateMapFromImage(World world)
        {
            Bitmap mapImage = (Bitmap)Bitmap.FromFile(mapFile);

            world.Tiles = new ITerrain[WORLD_WIDTH, WORLD_HEIGHT];

            for (int x = 0; x < WORLD_WIDTH; x++)
            {
                for (int y = 0; y < WORLD_HEIGHT; y++)
                {
                    Vector2 worldIndex = new Vector2(x, y);

                    if (mapImage.GetPixel(x, y).Name == "ff6a4e2f")
                    {
                        world.Tiles[x, y] = TerrainFactory.CreateCaveFloor(worldIndex, world);
                    }
                    else if (mapImage.GetPixel(x, y).Name == "ff8c8c8c")
                    {
                        world.Tiles[x, y] = TerrainFactory.CreateCaveWall(worldIndex, world);
                    }
                    else if (mapImage.GetPixel(x, y).Name == "ff000000")
                    {
                        world.Tiles[x, y] = TerrainFactory.CreateNothing(worldIndex, world);
                    }
                    else if (mapImage.GetPixel(x, y).Name == "ff0000ff")
                    {
                        world.Tiles[x, y] = TerrainFactory.CreateWater(worldIndex, world);
                    }
                    else
                    {
                        Console.WriteLine("ERROR: Unknown terrain type");
                    }
                }
            }
        }
Пример #2
0
        public void CreateBigRoom(World world)
        {
            world.Tiles = new ITerrain[World.WORLD_WIDTH, World.WORLD_HEIGHT];

            for (int x = 0; x < World.WORLD_WIDTH; x++)
            {
                for (int y = 0; y < World.WORLD_HEIGHT; y++)
                {
                    Vector2 worldIndex = new Vector2(x, y);


                    world.Tiles[x, y] = TerrainFactory.CreateCaveFloor(worldIndex, world);
                }
            }
        }