public void RegisterCommandsHandler(ICommandsHandler commandsHandler)
        {
            if (this.commandsHandler != null)
            {
                this.commandsHandler.UpdateEvent -= Update;
            }
            this.commandsHandler              = commandsHandler;
            this.log                          = commandsHandler.Logger;
            this.commandsHandler.UpdateEvent += Update;

            this.commandsHandler.ReceiveEvent += Receive;
        }
Example #2
0
        public Level(GraphicsDevice graphicsDevice, Resources resources)
        {
            _graphicsDevice = graphicsDevice;
            _grid           = new Grid(Configuration.Instance.GridWidth, Configuration.Instance.GridHeight);
            _inputTimeout   = new Timeout(Configuration.Instance.GameSpeed);
            _parser         = new Parser(resources);

            _renderTarget = new RenderTarget2D(_graphicsDevice, Configuration.Instance.CellWidth * Configuration.Instance.GridWidth, Configuration.Instance.CellHeight * Configuration.Instance.GridHeight);
            _resources    = resources;
            _screen       = new Rectangle(0, 0, (int)(Configuration.Instance.CellWidth * Configuration.Instance.GridWidth * Configuration.Instance.RenderFactor), (int)(Configuration.Instance.CellHeight * Configuration.Instance.GridHeight * Configuration.Instance.RenderFactor));
            _spriteBatch  = new SpriteBatch(_graphicsDevice);
            _turns        = new Stack <Stack <ICommand> >();

            _pipeline = new PipelineEntities(_spriteBatch);

            _doCommandsHandler   = new DoCommandsHandler(_pipeline, _resources, _grid);
            _unDoCommandsHandler = new UnDoCommandsHandler(_pipeline, _resources, _grid);
        }