Beispiel #1
0
        public Map GenerateWorldMap()
        {
            Map map = new Map();
            map.CreateBasicMap(100, 100);

            int forestX = 40;
            int forestY = 40;
            int forestRadius = 30;

            for(int y=0;y<map.MapLength;y++)
            {
                for (int x = 0; x < map.MapWidth; x++)
                {
                    // Set Biome
                    if (Map.GetDistance(x, y, forestX, forestY) < forestRadius) map.Tiles[y][x].Biome = Biomes["Forest"];
                    else map.Tiles[y][x].Biome = Biomes["Field"];

                    // Select random ground
                    map.Tiles[y][x].Ground = map.Tiles[y][x].Biome.Grounds[Game.Random.Next(map.Tiles[y][x].Biome.Grounds.Count)];

                    // Select Random feature
                    if (Game.Random.NextDouble() > 0.8)
                    {
                        if (map.Tiles[y][x].Biome.Features.Count != 0)
                        {
                            map.Tiles[y][x].Feature = map.Tiles[y][x].Biome.Features[Game.Random.Next(map.Tiles[y][x].Biome.Features.Count)];
                        }
                    }
                }
            }

            return map;
        }
Beispiel #2
0
        public void Setup()
        {
            GameTime = new DateTime(1, 1, 1, 7, 0, 0);
            Actors = new List<Actor>();

            GameSetup = new GameSetup();
            GameSetup.SetupBiomes();
            GameSetup.SetupMobTypes();
            Map = GameSetup.GenerateWorldMap();

            Tile tile = Map.GetTile(5, 5);

            ActorType heroType = new ActorType();
            heroType.AccuracyTrend = new TraitTrend<int>((l) => 2 * l + 1);
            heroType.AttackTrend = new TraitTrend<int>((l) => (int)(Math.Pow(l, 2) + 10));
            heroType.DefenceTrend = new TraitTrend<int>((l) => (int)(0.9 * Math.Pow(l, 2) + 5));
            heroType.HealthTrend = new TraitTrend<int>((l) => (int)(0.7 * Math.Pow(l, 2) + 30));
            heroType.ExperienceTrend = new TraitTrend<int>((l) => (int)(Math.Pow(l, 3)));
            heroType.SpeedTrend = new TraitTrend<int>((l) => 10);

            Hero hero = new Hero(heroType, 5);
            hero.Name = "Hero";
            Hero = hero;
            AddActor(hero, tile);

            //MobType type = MobTypeFactory.GenerateMobType();
            for (int i = 0; i < 20; i++)
            {
                Mob mob = MobFactory.GenerateMob(GameSetup.MobTypes["Goblin"], 3);
                mob.Name = "Goblin " + i;

                while (true)
                {
                    Tile mobTile = Map.GetTile(Random.Next(0, Map.MapWidth - 1), Random.Next(0, Map.MapWidth - 1));
                    if (mobTile.Feature == null && mobTile.Actor == null)
                    {
                        AddActor(mob, mobTile);
                        break;
                    }
                }
            }
        }