Exemple #1
0
        public EntityFactory(
            IGameState gameState,
            IMap map,
            ITaskProcessor taskProcessor,
            IToolset toolset)
        {
            Condition.Requires(gameState, nameof(gameState)).IsNotNull();
            Condition.Requires(map, nameof(map)).IsNotNull();
            Condition.Requires(taskProcessor, nameof(taskProcessor)).IsNotNull();
            Condition.Requires(toolset, nameof(toolset)).IsNotNull();

            this._gameState     = gameState;
            this._map           = map;
            this._taskProcessor = taskProcessor;
            this._toolset       = toolset;

            this._types = new Dictionary <EntityType, Type>
            {
                { EntityType.Finish, typeof(GroundEntities.FinishEntity) },
                { EntityType.Ground, typeof(GroundEntities.GroundEntity) },
                { EntityType.Wall, typeof(GroundEntities.WallEntity) },

                { EntityType.PlayerMover, typeof(PlayerMoverEntity) },
                { EntityType.ToolsetSelector, typeof(ToolsetSelectorEntity) },

                { EntityType.Torch, typeof(TorchEntity) },

                { EntityType.RotateToLeft, typeof(RotateToLeftEntity) },
                { EntityType.RotateToRight, typeof(RotateToRightEntity) },
            };
        }
        public PlayerEntity(
            int x,
            int y,
            IGameState gameState,
            ITaskProcessor taskProcessor,
            IToolset toolset)
            : base(
                EntityType.Player,
                x,
                y,
                MapLayer.Player,
                new[] {
            EntityProperty.PointIsBusy,
            EntityProperty.StopLazerRay
        })
        {
            Condition.Requires(gameState, nameof(gameState)).IsNotNull();
            Condition.Requires(taskProcessor, nameof(taskProcessor)).IsNotNull();
            Condition.Requires(toolset, nameof(toolset)).IsNotNull();

            this._state = PlayerState.Live;

            this._gameState     = gameState;
            this._taskProcessor = taskProcessor;
            this._toolset       = toolset;
        }
Exemple #3
0
        public Game(
            // Game objects:
            IGameState gameState,
            IMap map,
            IToolset toolset,
            // Processors:
            IDrawMapProcessor drawMapProcessor,
            IDrawToolsetProcessor drawToolsetProcessor,
            ITaskProcessor taskProcessor,
            // Settings:
            IDrawSettings drawSettings,
            IEntityFactory entityFactory,

            ILevelBuilder levelBuilder)
        {
            #region Arguments Validation

            Condition.Requires(gameState, nameof(gameState)).IsNotNull();
            Condition.Requires(map, nameof(map)).IsNotNull();
            Condition.Requires(toolset, nameof(toolset)).IsNotNull();

            Condition.Requires(drawMapProcessor, nameof(drawMapProcessor)).IsNotNull();
            Condition.Requires(drawToolsetProcessor, nameof(drawToolsetProcessor)).IsNotNull();
            Condition.Requires(taskProcessor, nameof(taskProcessor)).IsNotNull();

            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            Condition.Requires(entityFactory, nameof(entityFactory)).IsNotNull();

            Condition.Requires(levelBuilder, nameof(levelBuilder)).IsNotNull();

            #endregion Arguments Validation

            this._levelBuilder = levelBuilder;
            this._state        = gameState;
            this._map          = map;
            this._toolset      = toolset;

            this._drawMapProcessor     = drawMapProcessor;
            this._drawToolsetProcessor = drawToolsetProcessor;
            this._taskProcessor        = taskProcessor;

            this._gameProcessorsBasket = new GameProcessorsBasket(
                this._state,
                this._map,
                this._toolset);

            this.MapLeftButtonMouseController = new MapLeftButtonMouseController(
                drawSettings,
                entityFactory,
                this._map,
                this._taskProcessor,
                this._toolset);

            this.MapRightButtonMouseController = new MapRightButtonMouseController(
                this._toolset);

            this.ToolsLeftButtonMouseController = new ToolsLeftButtonMouseController(
                drawSettings,
                this._toolset);
        }
        public MapRightButtonMouseController(
            IToolset toolset)
        {
            Condition.Requires(toolset, nameof(toolset)).IsNotNull();

            this._toolset = toolset;
        }
        public ToolsLeftButtonMouseController(
            IDrawSettings drawSettings,
            IToolset toolset)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            Condition.Requires(toolset, nameof(toolset)).IsNotNull();

            this._toolset      = toolset;
            this._drawSettings = drawSettings;
        }
 public GameProcessorsBasket(
     IGameState gameState,
     IMap map,
     IToolset toolset)
 {
     this._gameProcessors = new IGameProcessor[] {
         new LazerProcessor(
             map)
     };
 }
        public StandardConverter(IToolset toolset)
        {
            if (toolset == null)
            {
                throw new ArgumentNullException("toolset");
            }

            Toolset = toolset;

            Tracer.Trace(string.Format("T:{0} Created StandardConverter", Thread.CurrentThread.Name));
        }
Exemple #8
0
        public void FillToolset(IToolset toolset)
        {
            Condition.Requires(toolset, nameof(toolset)).IsNotNull();

            toolset.Add(EntityType.MirrorMainDiagonal);
            toolset.Add(EntityType.MirrorMainDiagonal);
            toolset.Add(EntityType.MirrorMainDiagonal);
            toolset.Add(EntityType.MirrorSideDiagonal);
            toolset.Add(EntityType.MirrorSideDiagonal);
            toolset.Add(EntityType.MirrorSideDiagonal);
        }
Exemple #9
0
        public StandardConverter(IToolset toolset)
        {
            if (toolset == null)
            {
                throw new ArgumentNullException("toolset");
            }

            Toolset = toolset;

            Tracer.Trace(string.Format("T:{0} Created StandardConverter", Thread.CurrentThread.Name));
        }
Exemple #10
0
        public void Build(
            LevelNumber levelNumber,
            IMap map,
            IToolset toolset)
        {
            Condition.Requires(map, nameof(map)).IsNotNull();
            Condition.Requires(toolset, nameof(toolset)).IsNotNull();

            var level = _levels[levelNumber];

            level.FillMap(map);
            level.FillToolset(toolset);
        }
        static TuesPechkinTests()
        {
            Debug.Listeners.Add(new DefaultTraceListener());

            toolset =
                new RemotingToolset <PdfToolset>(
                    new StaticDeployment(
                        Path.Combine(
                            AppDomain.CurrentDomain.BaseDirectory,
                            "wk-ver",
                            TEST_WK_VER)));

            converter = new ThreadSafeConverter(toolset);
        }
        public DrawToolsetProcessor(
            IDrawSettings drawSettings,
            IEntityFactory entityFactory,
            IGameState gameState,
            IToolset toolset)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            Condition.Requires(entityFactory, nameof(entityFactory)).IsNotNull();
            Condition.Requires(toolset, nameof(toolset)).IsNotNull();
            this._toolset = toolset;

            this._toolsetMap       = new ToolsetMap(entityFactory, this._toolset);
            this._drawMapProcessor = new DrawMapProcessor(drawSettings, gameState, this._toolsetMap);
        }
        static TuesPechkinTests()
        {
            Debug.Listeners.Add(new DefaultTraceListener());

            toolset =
                new RemotingToolset<PdfToolset>(
                    new StaticDeployment(
                        Path.Combine(
                            AppDomain.CurrentDomain.BaseDirectory,
                            "wk-ver",
                            TEST_WK_VER)));

            converter = new ThreadSafeConverter(toolset);
        }
        public ThreadSafeConverter(IToolset toolset)
            : base(toolset)
        {
            toolset.Unloaded += (sender, args) =>
            {
                new Thread(() => StopThread()).Start();
            };

            if (toolset is NestingToolset)
            {
                (toolset as NestingToolset).BeforeUnload += (sender, args) =>
                {
                    Invoke(sender as ActionShim);
                };
            }
        }
Exemple #15
0
        public ToolsetMap(
            IEntityFactory entityFactory,
            IToolset toolset)
        {
            Condition.Requires(entityFactory, nameof(entityFactory)).IsNotNull();
            Condition.Requires(toolset, nameof(toolset)).IsNotNull();

            this._toolset = toolset;
            _points       = new MapPoint[this.Width];

            for (int x = 0; x < this.Width; ++x)
            {
                _points[x] = new MapPoint(x, 0);
            }

            this._entityFactory = entityFactory;
        }
Exemple #16
0
        public ThreadSafeConverter(IToolset toolset)
            : base(toolset)
        {
            toolset.Unloaded += (sender, args) =>
            {
                new Thread(StopThread).Start();
            };

            var nestingToolset = toolset as NestingToolset;

            if (nestingToolset != null)
            {
                nestingToolset.BeforeUnload += (sender, args) =>
                {
                    Invoke(sender as ActionShim);
                };
            }
        }
Exemple #17
0
        public MapLeftButtonMouseController(
            IDrawSettings drawSettings,
            IEntityFactory entityFactory,
            IMap map,
            ITaskProcessor taskProcessor,
            IToolset toolset)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            Condition.Requires(entityFactory, nameof(entityFactory)).IsNotNull();
            Condition.Requires(map, nameof(map)).IsNotNull();
            Condition.Requires(taskProcessor, nameof(taskProcessor)).IsNotNull();
            Condition.Requires(toolset, nameof(toolset)).IsNotNull();

            this._drawSettings  = drawSettings;
            this._entityFactory = entityFactory;
            this._map           = map;
            this._taskProcessor = taskProcessor;
            this._toolset       = toolset;
        }
Exemple #18
0
 public void FillToolset(IToolset toolset)
 {
     Condition.Requires(toolset, nameof(toolset)).IsNotNull();
 }