Esempio n. 1
0
        /// <summary>
        /// Private static helper that triggers a Robot Factories
        /// DeployRobots method (affecting Robots in the Factory).
        /// </summary>
        /// <param name="robotFactory">The Robot Factory to trigger the action on.</param>
        private static void DeployRobots(IRobotFactory robotFactory)
        {
            // If Factory is not null then deploy the Robots
            robotFactory?.DeployRobots().ToList().ForEach(robot =>
            {
                // If each robot is not null then trigger various robot behaviours (move, speak, attack, etc) and 'output', depending on implementation
                if (robot != null)
                {
                    robot.Move();
                    robot.Speak();
                    robot.Attack();

                    if (robot is ISmallRobot)
                    {
                        ((ISmallRobot)robot).Sneak();
                    }
                    else if (robot is ILargeRobot)
                    {
                        ((ILargeRobot)robot).Crush();
                    }
                }

                Console.WriteLine();
            });
        }
 public void Initialise()
 {
     _battleArena = new BattleArenaFactory().Create(5, 5);
     _currentGame = new Game(null);
     _robotFactory = new RobotFactory();
     _commandParser = new DeployRobotCommandParser(_currentGame, _robotFactory);
 }
Esempio n. 3
0
 public CompetitionBootstrap(IBattleArena battleArena, INavigationSystem navigationSystem,
                             IRobotFactory robotFactory, IArenaFactory arenaFactory, IConsoleWrapper console, ILogWriter logWriter)
 {
     _logWriter   = logWriter;
     _console     = console;
     _gameConsole = new GameConsole(battleArena, navigationSystem, robotFactory, arenaFactory, console, logWriter);
 }
Esempio n. 4
0
        public RegisterRobotService(ILogger logger, IRobotFactory robotFactory)
        {
            _logger       = logger;
            _robotFactory = robotFactory;

            FetchRobotsFromLibrary();
        }
 public Controller()
 {
     this.garage           = new Garage();
     this.robotFactory     = new RobotFactory();
     this.procedureFactory = new ProcedureFactory();
     this.procedures       = new ProcedureRepository();
 }
Esempio n. 6
0
 /// <summary>
 /// Private static helper that triggers a Robot Factories
 /// Paint/AttachWeapons methods (affecting Robots in the Factory).
 /// </summary>
 /// <param name="robotFactory">The Robot Factory to trigger actions on.</param>
 private static void PerformFactoryProcessing(IRobotFactory robotFactory)
 {
     if (robotFactory != null)
     {
         robotFactory.PaintRobots();
         robotFactory.AttachWeapons();
     }
 }
Esempio n. 7
0
        public Mars(IGrid grid, IRobotFactory robotFactory)
        {
            Contract.Requires(grid != null);
            Contract.Requires(robotFactory != null);

            this.grid = grid;
            this.robotFactory = robotFactory;
        }
Esempio n. 8
0
        public ApplicationState(IRobotFactory robotFactory, IProgramExecutionService programExecutionService)
        {
            var robots = robotFactory.GetRegisteredRobots();

            RobotsList.Capacity = robots.Count();

            foreach (var r in robots)
            {
                RobotsList.Add(new RobotState(programExecutionService, r, new RobotLog()));
            }
        }
Esempio n. 9
0
        public World(IGrid grid, IRobotFactory robotFactory, IRobotInstructionHandler[] instructionHandlers)
        {
            _brain        = new StateMachine();
            _grid         = grid;
            _robotFactory = robotFactory;
            _robots       = new List <Robot>();

            _dispatcher = instructionHandlers.ToDictionary(rc => rc.Key, rc => rc);
            _parser     = new Parser(instructionHandlers);

            _brain.SetState(InitializeGrid);
        }
Esempio n. 10
0
        public GameConsole(IBattleArena battleArena, INavigationSystem navigationSystem, IRobotFactory robotFactory, IArenaFactory arenaFactory, IConsoleWrapper console, ILogWriter logWriter)
        {
            _battleArena      = battleArena;
            _navigationSystem = navigationSystem;
            _console          = console;
            _logWriter        = logWriter;

            _robotMapper = new RobotMapper(robotFactory, arenaFactory);
            _arenaMapper = new ArenaMapper(arenaFactory);
        }
Esempio n. 11
0
 public void Initialise()
 {
     _robotFactory = new RobotFactory();
 }
Esempio n. 12
0
        public RobotMapper(IRobotFactory robotFactory, IArenaFactory arenaFactory)
        {
            _robotFactory = robotFactory;

            _arenaMapper = new ArenaMapper(arenaFactory);
        }
Esempio n. 13
0
 public RobotStrategy(IRobotFactory robotFactory)
 {
     this.robotStrategy = robotFactory;
 }
 public DeployRobotCommandParser(IGameConfiguration currentGameConfiguration, IRobotFactory robotFactory)
     : base(currentGameConfiguration, regexPattern)
 {
     _robotFactory = robotFactory;
 }