Exemplo n.º 1
0
        private void Initialize()
        {
            var width  = config.GetMapSizeFor("x");
            var height = config.GetMapSizeFor("y");

            //var width =   int.Parse(config.GetSection("consolegame:mapsettings:x").Value);
            //var mapSettings = config.GetSection("consolegame:mapsettings");
            //int.TryParse(mapSettings["y"], out int height);

            //map = new ConsoleMap(height, width);
            var heroCell = map.GetCell(0, 0);

            hero = new Hero(heroCell);
            map.Creatures.Add(hero);

            var r = new Random();

            //map.GetCell(2,2).Items.Add(Item.Coin());
            //map.GetCell(2,2).Items.Add(Item.Coin());
            map.GetCell(RH(r), RW(r)).Items.Add(Item.Coin());
            map.GetCell(RH(r), RW(r)).Items.Add(Item.Coin());
            map.GetCell(RH(r), RW(r)).Items.Add(Item.Torch());
            map.GetCell(RH(r), RW(r)).Items.Add(Potion.HealthPortion());
            map.GetCell(RH(r), RW(r)).Items.Add(Potion.HealthPortion());

            map.Place(new Orc(map.GetCell(RH(r), RW(r)), 120));
            map.Place(new Orc(map.GetCell(RH(r), RW(r)), 120));
            map.Place(new Troll(map.GetCell(RH(r), RW(r)), 160));
            map.Place(new Troll(map.GetCell(RH(r), RW(r)), 160));
            map.Place(new Goblin(map.GetCell(RH(r), RW(r)), 200));

            map.Creatures.ForEach(c =>
            {
                c.AddMessage  = ui.AddMessage;
                c.AddMessage += m => Debug.WriteLine(m);
            });
        }