public StandartTwoPlayerEngine(IRenderer renderer, IInputProvider input)
 {
     this._renderer         = renderer;
     this._input            = input;
     this._board            = new Board();
     this._movementStrategy = new NormalMovementStrategy();
 }
 public KingSurvivalEngine(IRenderer renderer, IInputProvider inputProvider,IBoard board, IWinningConditions winningConditions)
 {
     this.renderer = renderer;
     this.provider = inputProvider;
     this.winningConditions = winningConditions;
     this.board = board;
 }
Example #3
0
 public Calculator(IInputProvider inputProvider, IOutputProvider outputProvider, IParseProvider parseProvider, IMathProvider mathProvider)
 {
     _inputProvider = inputProvider;
     _outputProvider = outputProvider;
     _parseProvider = parseProvider;
     _mathProvider = mathProvider;
 }
        private void CheckProvider()
        {
            switch (providerType)
            {
            case ProviderType.Player:

                _inputProvider = PlayerInputProvider.Instance;
                break;


            case ProviderType.Enemy:

                EnemyInputProvider provider;
                if ((provider = GetComponent <EnemyInputProvider>()) == null)
                {
                    this.gameObject.AddComponent(typeof(EnemyInputProvider));
                    provider = GetComponent <EnemyInputProvider>();
                }
                _inputProvider = provider;
                break;


            default:

                _inputProvider = new NullInputProvider();
                break;
            }
        }
Example #5
0
        private static void LoadSettings()
        {
            lock (SettingLock)
            {
                if (settings != null)
                {
                    return;
                }

                var settingsEntries = ClientData.GetSettings();
                settings = settingsEntries.ToDictionary(s => s.Name);

                if (ClientData.CheckForUpdates())
                {
                    settings = ClientData.GetSettings().ToDictionary(s => s.Name);
                }

                commandBindings = new ObservableCollection <CommandBinding>();
                commandBindings.CollectionChanged += OnCommandBindingsChanged;
                foreach (var cbe in ClientData.GetCommandBindings())
                {
                    IInputProvider provider = Enumerable.FirstOrDefault <IInputProvider> (Modules.Input, ip => Extensions.GetSimpleName(ip.GetType()) == cbe.ProviderType);
                    if (provider == null)
                    {
                        continue;
                    }

                    commandBindings.Add(new CommandBinding(provider, cbe.Command, cbe.Input));
                }
            }
        }
 public TwoPlayerEngine(IRenderer render, IInputProvider inputProvider)
 {
     this.renderer         = render;
     this.input            = inputProvider;
     this.movementStrategy = new NormalMovementStrategy();
     this.board            = new TheBoard();
 }
        public void LoadPictures()
        {
            IInputProvider iprov = Provider.Instance as IInputProvider;
            PictureList    pl    = iprov.GetPictures(new PictureSearch()
            {
                SearchProvider  = Provider,
                MaxPictureCount = 10,
                BannedURLs      = Settings.CurrentSettings.BannedImages,
                PreviewOnly     = true
            });

            foreach (Picture p in pl.Pictures)
            {
                PictureBox pb = new PictureBox();
                Image      i  = p.GetThumbnail();

                if (i == null)
                {
                    continue;
                }

                pb.Image  = i;
                pb.Width  = i.Width;
                pb.Height = i.Height;

                flowLayoutPanel1.Controls.Add(pb);
            }
        }
 public BitmapProcessor(
     IChangeDetector <Bitmap> changeDetector,
     IInputProvider <Bitmap> inputProvider)
 {
     _changeDetector = changeDetector;
     _inputProvider  = inputProvider;
 }
Example #9
0
 public Calculator(IInputProvider inputProvider, IOutputProvider outputProvider, IParseProvider parseProvider, IMathProvider mathProvider)
 {
     _inputProvider  = inputProvider;
     _outputProvider = outputProvider;
     _parseProvider  = parseProvider;
     _mathProvider   = mathProvider;
 }
Example #10
0
        private static string GetInputProviderArgument(IInputProvider inputProvider)
        {
            var argument = string.Empty;

            if (inputProvider is IConsoleInputProvider)
            {
                Console.WriteLine("Parameters will be taken until empty line");
                while (true)
                {
                    string line = Console.ReadLine();
                    if (string.IsNullOrEmpty(line))
                    {
                        break;
                    }
                    argument = $"{argument} | {line}";
                }
            }
            else if (inputProvider is IFileInputProvider)
            {
                Console.WriteLine("Filename");
                while (string.IsNullOrEmpty(argument))
                {
                    argument = Console.ReadLine();
                }

                Console.WriteLine();
            }
            else
            {
                throw new DevelopmentException($"{nameof(GetInputProviderArgument)} executed for not supported provider");
            }

            return(argument);
        }
Example #11
0
 public StandartTwoPlayerEngine(IRenderer renderer, IInputProvider provider)
 {
     this.renderer         = renderer;
     this.board            = new Board.Board();
     this.input            = provider;
     this.movementStrategy = new NormalMovementStrategy();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConsoleGame" /> class.
 /// </summary>
 /// <param name="inputProvider">The input provider.</param>
 /// <param name="renderer">The renderer.</param>
 /// <param name="damageHandler">The damage handler.</param>
 public ConsoleGame(IInputProvider inputProvider, ConsoleRenderer renderer, ICellDamageHandler damageHandler)
 {
     this.engine = new Engine(renderer, damageHandler);
     this.inputProvider = inputProvider;
     this.renderer = renderer;
     this.damageHandler = damageHandler;
 }
        public Engine(IInputProvider inputProvider, IOutputWriter outputWriter, ICommandParser commandParser)

        {
            this.commandParser = commandParser;
            this.inputProvider = inputProvider;
            this.outputWriter  = outputWriter;
        }
Example #14
0
        public MainWindow(
            IEnumerable <IControlContentProvider> controlContentProviders,
            IEnumerable <IPresenter <Bitmap> > presenters,
            IProcessor <Bitmap> bitmapProcessor,
            Configuration config,
            IInputProvider <Bitmap> inputProvider,
            IChangeDetector <Bitmap> changeDetector)
        {
            _bitmapProcessor  = bitmapProcessor;
            _config           = config;
            _inputProvider    = inputProvider;
            _changeDetector   = changeDetector;
            _bitmapPresenters = presenters.ToArray();

            InitializeComponent();

            trackAccuracy.Value  = _config.MaxGlitches;
            trackTolerance.Value = _config.Tolerance;

            foreach (var ccp in controlContentProviders)
            {
                var control = this.Controls.Find(ccp.Tag, true).SingleOrDefault();
                ccp.Control = control;
            }

            btStart_Click(this, null);
            CheckForChange_Tick(this, null);
        }
Example #15
0
 public AppLogic(IOutputProvider output, IInputProvider input, ICredentialManager credentialManager, IDataManager inventoryManager)
 {
     _output            = output;
     _input             = input;
     _credentialManager = credentialManager;
     _inventoryManager  = inventoryManager;
 }
Example #16
0
 void Start()
 {
     PlayerCore     = GetComponent <PlayerCore>();
     _inputProvider = GetComponent <IInputProvider>();
     OnStart();
     Initialize();
 }
Example #17
0
 public MyGame()
 {
     _graphics             = new GraphicsDeviceManager(this);
     _inputProvider        = new KeyboardInputProvider();
     _spritePack           = new SpritePack();
     Content.RootDirectory = "Content";
 }
Example #18
0
 private void InputTimerElapsedHandler(ThreadPoolTimer timer)
 {
     if (_CurrentInputProvider != null)
     {
         _CurrentInputProvider.Update();
         if (InputState.IsEmpty())
         {
             _InputProviderInactiveCount++;
         }
         if (_InputProviderInactiveCount > 10)
         {
             _InputProviderInactiveCount = 0;
             _CurrentInputProvider       = null;
         }
     }
     else
     {
         foreach (var provider in InputProviders)
         {
             provider.Update();
             if (!InputState.IsEmpty())
             {
                 _CurrentInputProvider = provider;
             }
         }
     }
 }
 public StandardTwoPlayerEngine(IRenderer renderer, IInputProvider inputProvider)
 {
     this.renderer = renderer;
     this.input = inputProvider;
     movementStrategy = new NormalMovementStrategy();
     this.board = new Board();
 }
        public CommandBindingViewModel(IInputProvider provider)
        {
            if (provider == null)
                throw new ArgumentNullException ("provider");

            this.provider = provider;
        }
Example #21
0
        private void Form1_Load(object sender, EventArgs e)
        {
            WallbaseImageSearchSettings wiss = new WallbaseImageSearchSettings();

            wiss.SA = "toplist";


            PictureSearch ps = new PictureSearch();

            ps.SearchProvider = new ActiveProviderInfo("Wallbase")
            {
                Active = true, ProviderConfig = wiss.Save()
            };
            ps.MaxPictureCount = 100;

            string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "TEMP");

            Directory.CreateDirectory(path);
            ps.SaveFolder = path;

            IInputProvider p = ps.SearchProvider.Instance as IInputProvider;

            pl = p.GetPictures(ps);

            Timer t = new Timer();

            t.Tick    += t_Tick;
            t.Interval = 5000;
            t.Enabled  = true;
        }
Example #22
0
 public ShowRecipeByName(IRecipeManager recipeManager, IInputProvider inputProvider, IModelDrawer <Recipe> recipeDrawer) :
     base(title: "Show recipe by name")
 {
     this.inputProvider = inputProvider;
     this.recipeDrawer  = recipeDrawer;
     this.recipeManager = recipeManager;
 }
Example #23
0
    private bool gameStartSignalFired = false;   // シーン読み込みのたび1回だけ発行する想定

    InputPresenter(IInputProvider input, Player player, GameController gameController, SignalBus signalBus)
    {
        this.player         = player;
        this.input          = input;
        this.gameController = gameController;
        this.signalBus      = signalBus;

        // 各種操作を監視してPlayerを動かす
        this.input.OnShot.Subscribe(push => {
            this.player.Shot(push);

            // ゲーム開始操作を兼ねるためSignal発行(そのシーンで1回だけ)
            if (!gameStartSignalFired)
            {
                signalBus.Fire <GameStartSignal>();
                gameStartSignalFired = true;
            }
        });
        this.input.OnThrow.Subscribe(angle => this.player.Throw(angle));
        this.input.OnBomb.Subscribe(_ => this.player.Bomb());

        this.input.OnMovePlayer
        .Where(info => Vector2.zero != info.MoveSpeed)
        .Subscribe(info => this.player.MovePlayer(info));

        // 各種操作を監視してGameControllerへ通知する
        this.input.OnMenu.Subscribe(_ => { });  // TODO:後で実装
        this.input.OnSpeedEdit.Subscribe(rate => this.gameController.UpdateSpeedMagnification(rate, EditMode.Rate_Delta));
    }
        /// <summary>
        /// Method that start the main logic of the game.
        /// </summary>
        /// <param name="output">Output renderer</param>
        /// <param name="input">Iput provider</param>
        /// <param name="cmmandLogger">Command logger</param>
        public static void Start(IRenderer output, IInputProvider input, ILogger cmmandLogger)
        {
            output.ShowInfoMessage("Please ente your name: ");
            string playerName = input.GetPlayerName();

            output.ShowInfoMessage("Please enter a dimension for the board the standard is 9x9");
            int dimension = input.GetPlayFieldDimensions();

            ICell playerCell = new Cell(new Position(dimension / 2, dimension / 2));
            IPlayField playField = null;
            var player = new Player.Player(playerName, playerCell);

            try
            {
                var playFieldGenerator = new StandardPlayFieldGenerator(player.CurentCell.Position, dimension, dimension);
                playField = new PlayField.PlayField(playFieldGenerator, player.CurentCell.Position, dimension, dimension);
            }
            catch (ArgumentOutOfRangeException e)
            {
                output.ShowInfoMessage(e.Message);
            }

            ICommandFactory commandFactory = new SimpleCommandFactory();
            IMementoCaretaker memory = new MementoCaretaker(new List<IMemento>());
            IScoreLadder ladder = ScoreLadder.Instance;
            IGameEngine gameEngine = new StandardGameEngine(output, input, playField, commandFactory, cmmandLogger, player,memory,ladder);
            gameEngine.Initialize(RandomNumberGenerator.Instance);
            gameEngine.Start();
        }
        /// <summary>
        /// Constructor with a specified input provider, used for unit tests
        /// </summary>
        /// <param name="ip"></param>
        public MoveProvider(IInputProvider ip)
        {
            // validate the inputs
            // If ip is null, throw an ArgumentNullException

            this.ip = ip;
        }
Example #26
0
        /// <summary>
        /// Method that start the main logic of the game.
        /// </summary>
        /// <param name="output">Output renderer</param>
        /// <param name="input">Iput provider</param>
        /// <param name="cmmandLogger">Command logger</param>
        public static void Start(IRenderer output, IInputProvider input, ILogger cmmandLogger)
        {
            output.ShowInfoMessage("Please ente your name: ");
            string playerName = input.GetPlayerName();

            output.ShowInfoMessage("Please enter a dimension for the board the standard is 9x9");
            int dimension = input.GetPlayFieldDimensions();

            ICell      playerCell = new Cell(new Position(dimension / 2, dimension / 2));
            IPlayField playField  = null;
            var        player     = new Player.Player(playerName, playerCell);

            try
            {
                var playFieldGenerator = new StandardPlayFieldGenerator(player.CurentCell.Position, dimension, dimension);
                playField = new PlayField.PlayField(playFieldGenerator, player.CurentCell.Position, dimension, dimension);
            }
            catch (ArgumentOutOfRangeException e)
            {
                output.ShowInfoMessage(e.Message);
            }

            ICommandFactory   commandFactory = new SimpleCommandFactory();
            IMementoCaretaker memory         = new MementoCaretaker(new List <IMemento>());
            IScoreLadder      ladder         = ScoreLadder.Instance;
            IGameEngine       gameEngine     = new StandardGameEngine(output, input, playField, commandFactory, cmmandLogger, player, memory, ladder);

            gameEngine.Initialize(RandomNumberGenerator.Instance);
            gameEngine.Start();
        }
Example #27
0
 public RestartController(MonoBehaviour script, DataCenter dataCenter, IInputProvider inputProvider)
 {
     this.script        = script;
     this.dataCenter    = dataCenter;
     this.inputProvider = inputProvider;
     this.thisCoroutine = Updater();
     this.script.StartCoroutine(this.thisCoroutine);
 }
Example #28
0
        public void SetUp()
        {
            _inputProvider = Substitute.For <IInputProvider>();
            var inputBackend = Substitute.For <IInputBackend>();

            inputBackend.CreateInputProvider().Returns(_inputProvider);
            _inputSystem = new InputSystem(inputBackend);
        }
Example #29
0
        public BindWindow(IInputProvider provider)
        {
            InitializeComponent();

            this.provider = provider;

            Loaded += (sender, e) => StartRecording();
        }
Example #30
0
 public StandardTwoPlayerEngine(IRenderer renderer, IInputProvider inputProvider, bool testing = false)
 {
     this.renderer         = renderer;
     this.input            = inputProvider;
     this.movementStrategy = new NormalMovementStrategy();
     this.board            = new Board();
     this.testing          = testing;
 }
Example #31
0
 public void Register(IInputProvider input)
 {
     if (input != null)
     {
         Context.Debug(() => $"Registering {input.GetType().Name}.");
     }
     InputProvider = input;
 }
        public void Awake()
        {
            _inputProvider = InputFactoring.CreateInstance();
            _timeToHint    = ContextProvider.Context.GameSettings.TimeToHint;

            Enable(true);
            Update();
        }
Example #33
0
 public ConferenceTrackManager(IDisplay display, IInputCollector inputCollector, IInputProvider inputProvider, IInputProcessor inputProcessor, TrackGenerator trackGenerator)
 {
     _display        = display;
     _inputCollector = inputCollector;
     _inputProvider  = inputProvider;
     _inputProcessor = inputProcessor;
     _trackGenerator = trackGenerator;
 }
Example #34
0
        private void StartInputRecording(IInputProvider provider, InputKeysModel target)
        {
            _targetInputModel = target;
            _model.Overlay    = _inputOverlay ??= new InputOverlay();

            _inputProvider          = provider;
            _inputProvider.KeyDown += OnInputProviderKeyDown;
        }
Example #35
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class.
        /// </summary>
        /// <param name="inputProvider">The input provider.</param>
        /// <param name="outputProvider">The output provider.</param>
        /// <param name="stateFactory">The factory that creates the game states.</param>
        public Game(IInputProvider inputProvider, IOutputProvider outputProvider, IStateFactory stateFactory)
        {
            this.InputProvider  = inputProvider;
            this.OutputProvider = outputProvider;
            this.StateFactory   = stateFactory;

            this.State = stateFactory.GetStartMenuState(this);
        }
Example #36
0
    ////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////

    #region public methods

    public void Init(IInputProvider iInputProvider, float speed)
    {
        _iInputProvider = iInputProvider;
        _speed          = speed;

        _leftBorder  = LeftWall.localPosition.x + (LeftWall.localScale.x + Width) / 2;
        _rightBorder = RightWall.localPosition.x - (RightWall.localScale.x + Width) / 2;
    }
 public SSASOutputController(
     OutputContext context,
     IAction initializer,
     IInputProvider inputProvider,
     IOutputProvider outputProvider
     ) : base(context, initializer, inputProvider, outputProvider)
 {
 }
 protected BaseChessEngine(IRenderer renderer, IInputProvider inputProvider, IMovementStrategy movementStrategy)
 {
     this.Renderer = renderer;
     this.MovementStrategy = movementStrategy;
     this.Input = inputProvider;
     this.Board = new Board();
     this.GameState = GameState.Playing;
 }
        public void Init()
        {
            var mockReader = new Mock<IReader>();
            mockReader.Setup(r => r.ReadText()).Returns(FakePlayerName);
            this.reader = mockReader.Object;

            this.inputProvider = new ConsoleInputProvider(this.reader);
        }
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public MenuState(IInputProvider pInputProv, NavRoot pNavRoot,InteractionSettings pSettings){
			vInputProv = pInputProv;
			vSettings = pSettings;

			Arc = new ArcState(pNavRoot, vSettings);
			Cursor = new CursorState(vSettings);

			OnSideChange += (() => {});
		}
Example #41
0
 /// <summary>
 /// Constructor for the Engine class. 
 /// </summary>
 /// <param name="renderer">IRenderer object</param>
 /// <param name="inputProvider">IInputProvider object.</param>
 public Engine(IRenderer renderer, IInputProvider inputProvider)
 {
     this.inputProvider = inputProvider;
     this.renderer = renderer;
     this.scoreBoard = Scoreboard.Instance;
     this.wordDataBase = new WordDatabase(this.dataSerialization);
     this.wordFactory = new WordFactory(this.wordDataBase);
     this.gameLogic = new DefaultGameLogic();
     this.gameLogic.Word = this.wordFactory.GetWord(Categories.IT);
 }
        public CommandBindingViewModel(IInputProvider provider, CommandBindingEntry entry)
        {
            if (provider == null)
                throw new ArgumentNullException ("provider");

            this.provider = provider;
            Input = entry.Input;
            ProviderType = entry.ProviderType;
            Command = entry.Command;
        }
Example #43
0
 public InputBridge()
 {
     if (Input.GetJoystickNames().Length <= 0)
     {
         provider = new DesktopInput();
     }
     else
     {
         provider = new GamepadInput();
     }
 }
Example #44
0
        /// <summary>
        /// Creates a new keybinding.
        /// </summary>
        /// <exception cref="ArgumentNullException"><paramref name="provider"/> or <paramref name="input"/> is <c>null</c>.</exception>
        public CommandBinding(IInputProvider provider, Command action, string input)
        {
            if (provider == null)
                throw new ArgumentNullException ("provider");
            if (input == null)
                throw new ArgumentNullException ("input");

            Provider = provider;
            Command = action;
            Input = input;
        }
Example #45
0
 public ConsoleEngine(
     IScoreBoardService scoreBoardService, 
     IRenderer renderer, 
     IPlayer player, 
     IWordGenerator wordGenerator, 
     ICommandFactory commandFactory, 
     IInputProvider inputProvider)
     : base(scoreBoardService, renderer, player, wordGenerator, commandFactory)
 {
     this.InputProvider = inputProvider;
 }
 public KingSurvivalEngineContext(IRenderer renderer, IInputProvider inputProvider, IBoard board, IWinningConditions winningConditions, IList<IPlayer> players)
 {
     this.renderer = renderer;
     this.provider = inputProvider;
     this.winningConditions = winningConditions;
     this.players = players;
     this.memory = new BoardMemory();
     this.currentPlayerIndex = 0;
     this.board = board;
     this.kingPlayer = this.players[0];
     this.pawnPlayer = this.players[1];
 }
 public IChessEngine GetEngine(GameType gameType, IRenderer renderer, IInputProvider inputProvider, IMovementStrategy movementStrategy)
 {
     switch (gameType)
     {
         case GameType.Chess:
             return new StandartTwoPlayerEngine(renderer, inputProvider, movementStrategy);
         case GameType.KingSurvival:
             return new KingSurvivalEngine(renderer, inputProvider, movementStrategy);
         default:
             throw new ArgumentException();
     }
 }
 /// <summary>
 /// Constructor for King Survival Engine
 /// </summary>
 /// <param name="renderer">The output renderer</param>
 /// <param name="inputProvider">The input provider</param>
 /// <param name="board">The board for the game</param>
 /// <param name="winningConditions">Winning conditions for the game</param>
 /// <param name="players">Players that are playing the game</param>
 /// <param name="memory">The memory for the board</param>
 /// <param name="context">Context for command execute</param>
 /// <param name="commandFactory">Command Factory</param>
 public KingSurvivalEngine(
     IRenderer renderer,
     IInputProvider inputProvider,
     IBoard board,
     IWinningConditions winningConditions,
     IList<IPlayer> players,
     BoardMemory memory,
     ICommandContext context,
     ICommandFactory commandFactory)
 {
     this.context = new KingSurvivalEngineContext(renderer, inputProvider, board, winningConditions, players, memory, context, commandFactory);
 }
Example #49
0
 public bool Create(IInputListener listener, out IInputProvider provider)
 {
     try
     {
         provider = new KinectProvider(listener);
         return provider.Available;
     }
     catch
     {
         provider = null;
         return false;
     }
 }
Example #50
0
 public override void Update(IInputProvider input)
 {
     ushort keycode;
     while (input.TryGetKeyboardEvent(m_TranslateASCII, out keycode)) {
         if (m_BufferCount >= 16)
             continue;
         if (m_ReportUpDownEvents && ((keycode & 0x0F00) == EventUp) || ((keycode & 0x0F00) == EventDown)) {
             m_CommandBuffer[m_CommandBuffer[m_BufferCount++]] = keycode;
         }
         else if (m_ReportPressEvents && ((keycode & 0x0F00) == EventPress)) {
             m_CommandBuffer[m_CommandBuffer[m_BufferCount++]] = keycode;
         }
     }
 }
		public CoreEngine(IUIEngine uiEngine, IField field, IPlayer player, IActionProvider actionProvider = null, IMovement movement = null, ISolvedChecker solvedChecker = null)
		{
			this._uiEngine = uiEngine;
			this._inputProvider = uiEngine.InputProvider;
			this._field = field;
			this._player = player;
            this._highScores = HighScores.Instance;

			this.ActionProvider = actionProvider ?? new DefaultActionProvider(this);
			this.Movement = movement ?? new BackwardMovement(field);
			this.SolvedChecker = solvedChecker ?? new DefaultSolvedChecker();

			this.AttachUIToEvents();
		}
Example #52
0
        public void Start(IRenderer renderer, IInputProvider provider)
        {
            renderer.RenderMainMenu();
            IWinningConditions winningConditions = new WinningConditions();
            var players = new List<IPlayer>();
            var kingPlayer = new Player("king");
            var pawnPlayer = new Player("pawn");
            players.Add(kingPlayer);
            players.Add(pawnPlayer);

            var board = new Board.Board();

            var engine = new KingSurvivalEngine(renderer, provider, board, winningConditions, players);
            engine.InitializeGame().StartGame();
        }
Example #53
0
 /// <summary>
 /// Method for starting a game
 /// </summary>
 /// <param name="renderer">The renderer on which the info is going to be rendered</param>
 /// <param name="provider">The input provider that provides information</param>
 public void Start(IRenderer renderer, IInputProvider provider)
 {
     renderer.RenderMainMenu();
     IWinningConditions winningConditions = new WinningConditions();
     var players = new List<IPlayer>();
     var kingPlayer = new Player(provider.GetPlayerName());
     var pawnPlayer = new Player(provider.GetPlayerName());
     players.Add(kingPlayer);
     players.Add(pawnPlayer);
     var board = new Board.Board();
     var memory = new BoardMemory();
     var context = new CommandContext(memory, board, players[0]);
     var commandFactory = new CommandFactory();
     var engine = new KingSurvivalEngine(renderer, provider, board, winningConditions, players, memory, context, commandFactory);
     engine.InitializeGame().StartGame();
 }
Example #54
0
        /// <summary>
        /// Constructor with which you can supply the input and the output provider independently
        /// </summary>
        /// <param name="input">The input provider</param>
        /// <param name="output">The output provider</param>
        public Interpreter(IInputProvider input, IOutputProvider output, String program = "")
        {
            if (input == null) throw new ArgumentNullException("input");
            if (output == null) throw new ArgumentNullException("output");

            this.inputProvider = input;
            this.outputDestination = output;

            InitializeActionList(input, output);

            ValidateSourceFile(program);

            ProgramString = program;
            PointerPosition = 0;
            loopIndexes = new Stack<Int32>();
            MemoryCells = new List<Int32>();
            MemoryCells.Add(0);
        }
 /// <summary>
 /// Standard game engine constructor.
 /// </summary>
 /// <param name="renderer">Output renderer.</param>
 /// <param name="inputProvider">Input provider.</param>
 /// <param name="playField">Game play field.</param>
 /// <param name="commandFactory">Game command factory.</param>
 /// <param name="logger">Command execution logger.</param>
 /// <param name="player">Player</param>
 public StandardGameEngine(
     IRenderer renderer,
     IInputProvider inputProvider,
     IPlayField playField,
     ICommandFactory commandFactory,
     ILogger logger,
     IPlayer player,
     IMementoCaretaker memory,
     IScoreLadder ladder)
 {
     this.playField = playField;
     this.renderer = renderer;
     this.input = inputProvider;
     this.ladder = ladder;
     this.commandFactory = commandFactory;
     this.logger = logger;
     this.player = player;
     this.memory = memory;
 }
 /// <summary>
 /// Constructor for creating King Survival Engine
 /// </summary>
 /// <param name="renderer">The output renderer</param>
 /// <param name="inputProvider">The input provider</param>
 /// <param name="board">The board for the game</param>
 /// <param name="winningConditions">Winning conditions for the game</param>
 /// <param name="players">Players that are playing the game</param>
 /// <param name="memory">The memory for the board</param>
 /// <param name="context">Context for command execute</param>
 /// <param name="commandFactory">Command Factory</param>
 public KingSurvivalEngineContext(
     IRenderer renderer,
     IInputProvider inputProvider,
     IBoard board,
     IWinningConditions winningConditions,
     IList<IPlayer> players,
     BoardMemory memory,
     ICommandContext context,
     ICommandFactory commandFactory)
 {
     this.renderer = renderer;
     this.provider = inputProvider;
     this.winningConditions = winningConditions;
     this.players = players;
     this.memory = memory;
     this.currentPlayerIndex = 0;
     this.board = board;
     this.kingPlayer = this.players[0];
     this.pawnPlayer = this.players[1];
     this.context = context;
     this.commandFactory = commandFactory;
 }
Example #57
0
 internal void UnregisterInputProvider(IInputProvider inputProvider)
 {
     _inputProviders.Remove(inputProvider);
 }
Example #58
0
        internal InputProviderSite RegisterInputProvider(IInputProvider inputProvider)
        {
            SecurityHelper.DemandUnrestrictedUIPermission();
//             VerifyAccess();


            // Create a site for this provider, and keep track of it.
            InputProviderSite site = new InputProviderSite(this, inputProvider);
            _inputProviders[inputProvider] = site;

            return site;
        }
Example #59
0
 public Shape(IInputProvider input)
 {
     widthAndHeightInput = input;
 }
Example #60
0
 private void InputTimerElapsedHandler(ThreadPoolTimer timer)
 {
     if (_CurrentInputProvider != null)
     {
         _CurrentInputProvider.Update();
         if (InputState.IsEmpty())
             _InputProviderInactiveCount++;
         if (_InputProviderInactiveCount > 10)
         {
             _InputProviderInactiveCount = 0;
             _CurrentInputProvider = null;
         }
     }
     else
     {
         foreach (var provider in InputProviders)
         {
             provider.Update();
             if (!InputState.IsEmpty())
                 _CurrentInputProvider = provider;
         }
     }
 }