コード例 #1
0
ファイル: Game.cs プロジェクト: Vasil-Pavlov/Labyrinth-4
 private Game(IPlayer player, IRenderer renderer, IScoreBoardObserver scoreboard, LabyrinthProcesor processor)
 {
     this.renderer = renderer;
     this.player = player;
     this.scoreBoardHandler = scoreboard;
     this.processor = processor;
 }
コード例 #2
0
ファイル: Context.cs プロジェクト: TeamLabyrinth4/Labyrinth-4
 /// <summary>
 /// Creates instance of the context object.
 /// </summary>
 /// <param name="player">Accepts any instance of IPlayer.</param>
 /// <param name="renderer">Accepts any instance of IRenderer.</param>
 /// <param name="scoreboard">Accepts any instance of IScoreBoardObserver.</param>
 /// <param name="matrix">Accepts instance of the class LabyrinthMatrix.</param>
 public Context(IScoreBoardObserver scoreboardHandler, IRenderer renderer, IPlayer player, LabyrinthMatrix matrix)
 {
     this.ScoreboardHandler = scoreboardHandler;
     this.Renderer = renderer;
     this.Player = player;
     this.Matrix = matrix;
     this.Memory = new StateMemory();
 }
コード例 #3
0
 public Game SetupGame(SimpleConsoleGameBuilder objectBuilder)
 {
     this.renderer = objectBuilder.CreteRenderer();
     this.player = objectBuilder.CreatePlayer();
     this.scoreBoardHandler = objectBuilder.CreteScoreBoardHanler();
     this.procesor = new LabyrinthProcesor(this.renderer, this.player, this.scoreBoardHandler);
     return Game.Instance(this.player, this.renderer, this.scoreBoardHandler, this.procesor);
 }
コード例 #4
0
 /// <summary>
 /// Creates instance of the context object.
 /// </summary>
 /// <param name="player">Accepts any instance of IPlayer.</param>
 /// <param name="renderer">Accepts any instance of IRenderer.</param>
 /// <param name="scoreboard">Accepts any instance of IScoreBoardObserver.</param>
 /// <param name="matrix">Accepts instance of the class LabyrinthMatrix.</param>
 public Context(IScoreBoardObserver scoreboardHandler, IRenderer renderer, IPlayer player, LabyrinthMatrix matrix)
 {
     this.ScoreboardHandler = scoreboardHandler;
     this.Renderer          = renderer;
     this.Player            = player;
     this.Matrix            = matrix;
     this.Memory            = new StateMemory();
 }
コード例 #5
0
        /// <summary>
        /// Creates instance of the game engine object.
        /// </summary>
        /// <param name="player">Accepts any instance of IPlayer.</param>
        /// <param name="renderer">Accepts any instance of IRenderer.</param>
        /// <param name="scoreboard">Accepts any instance of IScoreBoardObserver.</param>
        /// <param name="matrix">Accepts instance of the class LabyrinthMatrix.</param>
        private GameEngine(IPlayer player, IRenderer renderer, IScoreBoardObserver scoreboard, LabyrinthMatrix matrix)
        {
            this.context = new Context(scoreboard, renderer, player, matrix);
            this.factory = new CommandFactory(this.context);

            this.Attach(this.context.ScoreboardHandler);
            this.context.StartNewGame();
        }
コード例 #6
0
        /// <summary>
        /// Creates instance of the game engine object.
        /// </summary>
        /// <param name="player">Accepts any instance of IPlayer.</param>
        /// <param name="renderer">Accepts any instance of IRenderer.</param>
        /// <param name="scoreboard">Accepts any instance of IScoreBoardObserver.</param>
        /// <param name="matrix">Accepts instance of the class LabyrinthMatrix.</param>
        private GameEngine(IPlayer player, IRenderer renderer, IScoreBoardObserver scoreboard, LabyrinthMatrix matrix)
        {
            this.context = new Context(scoreboard, renderer, player, matrix);
            this.factory = new CommandFactory(this.context);

            this.Attach(this.context.ScoreboardHandler);
            this.context.StartNewGame();
        }
コード例 #7
0
 public GameCommand(LabyrinthProcesor labyrinthProcesor, IScoreBoardObserver scoreboardHandler, IRenderer renderer, IPlayer player, string command)
 {
     this.labyrinthProcesor = labyrinthProcesor;
     this.scoreboardHandler = scoreboardHandler;
     this.renderer = renderer;
     this.player = player;
     this.command = command;
 }
コード例 #8
0
 public LabyrinthProcesor(IRenderer renderer, IPlayer player, IScoreBoardObserver scoreBoardHandler)
 {
     this.Attach(scoreBoardHandler);
     this.messenger = new Messenger();
     this.scoreBoardHandler = scoreBoardHandler;
     this.renderer = renderer;
     this.player = player;
     this.Restart();
 }
コード例 #9
0
        /// <summary>
        /// The methods put the creation of the initial game objects in the correct order.
        /// </summary>
        /// <param name="objectBuilder">Gets a concrete builder, which will provide the needed objects.</param>
        /// <returns>Instance of the game engine.</returns>
        public GameEngine SetupGame(IGameObjectBuilder objectBuilder)
        {
            this.renderer          = objectBuilder.CreteRenderer();
            this.player            = objectBuilder.CreatePlayer();
            this.scoreboard        = objectBuilder.CreateScoreboard();
            this.scoreBoardHandler = objectBuilder.CreteScoreBoardHanler(this.scoreboard);
            this.matrix            = objectBuilder.CreateLabyrinthMatrix();

            return(GameEngine.Instance(this.player, this.renderer, this.scoreBoardHandler, this.matrix));
        }
コード例 #10
0
        /// <summary>
        /// The methods put the creation of the initial game objects in the correct order.
        /// </summary>
        /// <param name="objectBuilder">Gets a concrete builder, which will provide the needed objects.</param>
        /// <returns>Instance of the game engine.</returns>
        public GameEngine SetupGame(IGameObjectBuilder objectBuilder)
        {
            this.renderer = objectBuilder.CreteRenderer();
            this.player = objectBuilder.CreatePlayer();
            this.scoreboard = objectBuilder.CreateScoreboard();
            this.scoreBoardHandler = objectBuilder.CreteScoreBoardHanler(this.scoreboard);
            this.matrix = objectBuilder.CreateLabyrinthMatrix();

            return GameEngine.Instance(this.player, this.renderer, this.scoreBoardHandler, this.matrix);
        }
コード例 #11
0
        public void IntanceReturnsGameEngineObject()
        {
            this.localScoreBoard = new LocalScoreBoard();
            this.scoreBoard      = new ScoreBoardHandler(localScoreBoard);
            this.renderer        = new ConsoleRenderer();
            this.player          = new Player("Goshou");
            this.matrix          = new LabyrinthMatrix();

            this.game    = GameEngine.Instance(this.player, this.renderer, this.scoreBoard, this.matrix);
            this.context = this.game.GetCurrentContext();

            Assert.IsTrue(game is GameEngine);
            Assert.AreEqual(8, this.player.PositionRow);
        }
コード例 #12
0
ファイル: Game.cs プロジェクト: Vasil-Pavlov/Labyrinth-4
        public static Game Instance(IPlayer player, IRenderer renderer, IScoreBoardObserver scoreboard, LabyrinthProcesor processor)
        {
            if (gameInstance == null)
            {
                lock (syncLock)
                {
                    if (gameInstance == null)
                    {
                        gameInstance = new Game(player, renderer, scoreboard, processor);
                    }
                }
            }

            return gameInstance;
        }
コード例 #13
0
        /// <summary>
        /// Creates a thread safety Singleton instance of the GameEngine.
        /// </summary>
        /// <param name="player">Accepts any instance of IPlayer.</param>
        /// <param name="renderer">Accepts any instance of IRenderer.</param>
        /// <param name="scoreboard">Accepts any instance of IScoreBoardObserver.</param>
        /// <param name="matrix">Accepts instance of the class LabyrinthMatrix.</param>
        /// <returns>Instance of the GameEngine class.</returns>
        public static GameEngine Instance(IPlayer player, IRenderer renderer, IScoreBoardObserver scoreboard, LabyrinthMatrix matrix)
        {
            if (gameInstance == null)
            {
                lock (syncLock)
                {
                    if (gameInstance == null)
                    {
                        gameInstance = new GameEngine(player, renderer, scoreboard, matrix);
                    }
                }
            }

            return(gameInstance);
        }
コード例 #14
0
        /// <summary>
        /// Creates a thread safety Singleton instance of the GameEngine. 
        /// </summary>
        /// <param name="player">Accepts any instance of IPlayer.</param>
        /// <param name="renderer">Accepts any instance of IRenderer.</param>
        /// <param name="scoreboard">Accepts any instance of IScoreBoardObserver.</param>
        /// <param name="matrix">Accepts instance of the class LabyrinthMatrix.</param>
        /// <returns>Instance of the GameEngine class.</returns>
        public static GameEngine Instance(IPlayer player, IRenderer renderer, IScoreBoardObserver scoreboard, LabyrinthMatrix matrix)
        {
            if (gameInstance == null)
            {
                lock (syncLock)
                {
                    if (gameInstance == null)
                    {
                        gameInstance = new GameEngine(player, renderer, scoreboard, matrix);
                    }
                }
            }

            return gameInstance;
        }
コード例 #15
0
 public void Detach(IScoreBoardObserver observer)
 {
     this.Observers.Remove(observer);
 }
コード例 #16
0
 public void Attach(IScoreBoardObserver observer)
 {
     this.Observers.Add(observer);
 }
コード例 #17
0
        public void IntanceReturnsGameEngineObject()
        {
            this.localScoreBoard = new LocalScoreBoard();
            this.scoreBoard = new ScoreBoardHandler(localScoreBoard);
            this.renderer = new ConsoleRenderer();
            this.player = new Player("Goshou");
            this.matrix = new LabyrinthMatrix();

            this.game = GameEngine.Instance(this.player, this.renderer, this.scoreBoard, this.matrix);
            this.context = this.game.GetCurrentContext();

            Assert.IsTrue(game is GameEngine);
            Assert.AreEqual(8, this.player.PositionRow);
        }
コード例 #18
0
 public void Detach(IScoreBoardObserver observer)
 {
     this.Observers.Remove(observer);
 }
コード例 #19
0
 public void Attach(IScoreBoardObserver observer)
 {
     this.Observers.Add(observer);
 }