Ejemplo n.º 1
0
        public Game(IMonsterFactory factory)
        {
            gamer = new Hero(); // герой, за которого играем

            //Список комнат в локации
            Room[] rooms = new Room[]
            {
                new Room(),
                new Room(),
                new Room()
            };

            //Список сокровищ в локации
            Treasure[] treasures = new Treasure[]
            {
                new Treasure(),
                new Treasure(),
                new Treasure()
            };

            IMonster[] monsters = new IMonster[50]; // Список монстров в локации

            for (int i = 0; i < monsters.Length; i++)
            {
                monsters[i] = factory.Create(); // задаем тип монстра
            }

            location = new Dangeon(monsters, rooms, treasures); // инициализация игровой локации
        }
Ejemplo n.º 2
0
        public string Execute(string[] inputArgs)
        {
            string monsterType = inputArgs[0];
            var    monster     = factory.Create(monsterType);

            this.repository.Add(monster);
            //
            return(string.Format(addedMonsterMessege, monster.GetType().Name));
        }
Ejemplo n.º 3
0
        public string Execute(string[] inputArgs)
        {
            string monsterType = inputArgs[0];

            var monster = monsterFactory.Create(monsterType);

            this.monsterRepository.Add(monster);

            return(string.Format(succesfullMesage, monster.GetType().Name));
        }
Ejemplo n.º 4
0
        public string Execute(string[] inputArgs)
        {
            string monsterType = inputArgs[0].ToLower();

            var monster = monsterFactory.Create(monsterType);

            this.monsterRepository.Add(monster);

            return($"Successfully created new {monster.GetType().Name}!");
        }
Ejemplo n.º 5
0
        public string Execute(string[] inputArgs)
        {
            var type = inputArgs[0];

            var monster = monsterFactory.Create(type);

            monsterRepository.Add(monster);

            return($"Successfully created new {monster.GetType().Name}!");
        }
        public IEnumerable <BaseSpaceObject> Create(int amount)
        {
            for (var i = 0; i < amount; i++)
            {
                var genPlanet = randomGenerator.GenerateBool(probPlanet);

                if (genPlanet)
                {
                    yield return(planetFactory.Create());
                }
                else
                {
                    yield return(monsterFactory.Create());
                }
            }
        }
        public void ItCanCreateAMonster()
        {
            var monster = _monsterFactory.Create();

            Assert.IsAssignableFrom <IMonster>(monster);
        }