コード例 #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();
            });
        }
コード例 #2
0
 public void Initialise()
 {
     _battleArena = new BattleArenaFactory().Create(5, 5);
     _currentGame = new Game(null);
     _robotFactory = new RobotFactory();
     _commandParser = new DeployRobotCommandParser(_currentGame, _robotFactory);
 }
コード例 #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);
 }
コード例 #4
0
        public RegisterRobotService(ILogger logger, IRobotFactory robotFactory)
        {
            _logger       = logger;
            _robotFactory = robotFactory;

            FetchRobotsFromLibrary();
        }
コード例 #5
0
 public Controller()
 {
     this.garage           = new Garage();
     this.robotFactory     = new RobotFactory();
     this.procedureFactory = new ProcedureFactory();
     this.procedures       = new ProcedureRepository();
 }
コード例 #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();
     }
 }
コード例 #7
0
ファイル: Mars.cs プロジェクト: sheepsteak/MartianRobots
        public Mars(IGrid grid, IRobotFactory robotFactory)
        {
            Contract.Requires(grid != null);
            Contract.Requires(robotFactory != null);

            this.grid = grid;
            this.robotFactory = robotFactory;
        }
コード例 #8
0
ファイル: ApplicationState.cs プロジェクト: shoter/Robots
        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()));
            }
        }
コード例 #9
0
ファイル: World.cs プロジェクト: Degot/MartianRobots
        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);
        }
コード例 #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);
        }
コード例 #11
0
 public void Initialise()
 {
     _robotFactory = new RobotFactory();
 }
コード例 #12
0
ファイル: RobotMapper.cs プロジェクト: MaksymRybak/RobotWars
        public RobotMapper(IRobotFactory robotFactory, IArenaFactory arenaFactory)
        {
            _robotFactory = robotFactory;

            _arenaMapper = new ArenaMapper(arenaFactory);
        }
コード例 #13
0
 public RobotStrategy(IRobotFactory robotFactory)
 {
     this.robotStrategy = robotFactory;
 }
コード例 #14
0
 public DeployRobotCommandParser(IGameConfiguration currentGameConfiguration, IRobotFactory robotFactory)
     : base(currentGameConfiguration, regexPattern)
 {
     _robotFactory = robotFactory;
 }