コード例 #1
0
        public Terrain[,] generateWithMidpoint(Terrain[,] map, int m, int n)
        {
            List <String> terrains = new List <String> {
                "Lake", "Grass", "Desert", "Forest", "Mountain"
            };

            String t_left = terrains[r.Next(terrains.Count)];

            terrains.Remove(t_left);
            String t_right = terrains[r.Next(terrains.Count)];

            terrains.Remove(t_right);
            String b_left = terrains[r.Next(terrains.Count)];

            terrains.Remove(b_left);
            String b_right = terrains[r.Next(terrains.Count)];

            // initializing the corner values
            map[0, 0] = o.GiveTerrain(t_left);
            map[0, n] = o.GiveTerrain(t_right);
            map[m, 0] = o.GiveTerrain(b_left);
            map[m, n] = o.GiveTerrain(b_right);

            generateSection(map, 0, 0, m, n);

            // setting the map boundaries
            for (int i = 0; i < m; i++)
            {
                map[i, 0] = new Mountain();
                map[i, map.GetLength(0) - 1] = new Mountain();
            }
            for (int j = 0; j < n; j++)
            {
                map[0, j] = new Mountain();
                map[map.GetLength(1) - 1, j] = new Mountain();
            }

            // setting map center
            for (int i = (m / 2) - 3; i < (m / 2) + 4; i++)
            {
                for (int j = (n / 2) - 3; j < (n / 2) + 4; j++)
                {
                    map[i, j] = new Grass();
                }
            }

            return(map);
        }
コード例 #2
0
        public Shrine()
        {
            o = new OverworldFactory();

            m = new List <List <Terrain> > {
                new List <Terrain> {
                    o.GiveTerrain("Wall", " ╔ "), o.GiveTerrain("Grass"), o.GiveTerrain("Wall", " ╗ ")
                },
                new List <Terrain> {
                    o.GiveTerrain("Grass"), o.GiveTerrain("Altar"), o.GiveTerrain("Grass")
                },
                new List <Terrain> {
                    o.GiveTerrain("Wall", " ╚ "), o.GiveTerrain("Grass"), o.GiveTerrain("Wall", " ╝ ")
                }
            };

            /* m.Add(new List<string> { " ╔ ", "   ", " ╗ " });
             * m.Add(new List<string> { "   ", " ¤ ", "   " });
             * m.Add(new List<string> { " ╚ ", "   ", " ╝ " });
             */
        }