///<summary>
 /// Konstruktor.
 ///</summary>
 /// <param name="b">objek board</param>
 /// <param name="d">objek dadu</param>
 /// <param name="gameType">tipe game</param>
 public Game(Board b, Dice d,int gameType)
 {
     this.dice = d;
     this.papan = b;
     if (gameType == GAME_TYPE1)
     {
         players = new Player[] { new Player(0, "Player 1", false), new Player(0, "Player 2", false) };
     }
     else
     {
         players = new Player[] { new Player(0, "Player 1", false), new Player(0, "Computer", true) };
     }
     this.winner = null;
     this.totalPlayer = players.Length;
     this.playingTurn = 0;
 }
 /// <summary>
 /// Konstraktor
 /// </summary>
 /// <param name="gameType">tipe game (1.(player vs player) atau 2.(player vs computer))</param>
 public MainForm(int gameType)
 {
     InitializeComponent();
     this.DoubleBuffered = true;
     b = new Board();
     snakes = b.Snakes;
     ladders = b.Ladders;
     convert = new Converter();
     game = new Game(b, new Dice(), gameType);
     if (gameType == 1)
     {
         playerAvatars = new Bitmap[] { new Bitmap(Properties.Resources.player1), new Bitmap(Properties.Resources.player2) };
     }
     else
     {
         playerAvatars = new Bitmap[] { new Bitmap(Properties.Resources.player1), new Bitmap(Properties.Resources.playerComp) };
     }
 }
Ejemplo n.º 3
0
 public PieceFinder(Image<Bgr, byte> image, Board.GridQuad[,] grid)
 {
     m_Image = image;
     m_Grid = grid;
 }
 public MenuFrame()
 {
     InitializeComponent();
     Board b = new Board();
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Start Game logic
        /// </summary>
        public void Start()
        {
            // Initialize the two basic objects needed for user interactions
            this.InputProvider = this.inputProvider ?? new ConsoleInputProvider();
            this.OutputRenderer = this.outputRenderer ?? new ConsoleRenderer();

            // Render initial UI
            this.OutputRenderer.RenderWelcomeScreen(string.Join(string.Empty, RenderersConstants.GameTitle));
            this.OutputRenderer.RenderNewPlayerCreationRequest();

            // Create the active player
            var player = new Player(this.InputProvider.ReceiveInputLine());

            // Render console menu handler and execute logic for requesting board settings
            // TODO: Refactor menu handler logic
            int[] cursorPosition = this.OutputRenderer.GetCursor();
            var menuItems = new List<IGameMode>()
            {
                new BeginnerMode(),
                new IntermediateMode(),
                new ExpertMode()
            };

            var menuHandler = new ConsoleMenuHandler(this.inputProvider, this.outputRenderer, menuItems, cursorPosition[0] + 1, cursorPosition[1]);

            menuHandler.ShowSelections();

            BoardSettings boardSettings = menuHandler.RequestUserSelection();
            this.OutputRenderer.ClearScreen();
            this.OutputRenderer.SetCursor(visible: true);
            //// End of menu handler logic

            var board = new Board(boardSettings, new List<IBoardObserver>());
            var scoreboard = new Scoreboard();
            var contentFactory = new ContentFactory();
            var initializationStrategy = new StandardGameInitializationStrategy(contentFactory);
            var boardOperator = new CommandOperator(board, scoreboard);
            var engine = new StandardOnePlayerMinesweeperEngine(board, this.inputProvider, this.outputRenderer, boardOperator, scoreboard, player);

            engine.Initialize(initializationStrategy);
            board.Subscribe(engine);
            engine.Run();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Start Game logic
        /// </summary>
        public void Start(Grid root)
        {
            // Initialize the two basic objects needed for user interactions
            this.InputProvider = this.inputProvider ?? new WpfInputProvider();
            this.OutputRenderer = this.outputRenderer ?? new WpfRenderer(root);

            string testPlayerName = "John";

            // Create the active player
            var player = new Player(testPlayerName);

            BoardSettings testBoardSettings = new EasyBoardSettings();

            var board = new Board(testBoardSettings, new List<IBoardObserver>());
            var scoreboard = new Scoreboard();
            var contentFactory = new ContentFactory();
            var initializationStrategy = new StandardGameInitializationStrategy(contentFactory);
            var boardOperator = new CommandOperator(board, scoreboard);
            var engine = new StandardOnePlayerMinesweeperEngine(board, this.inputProvider, this.outputRenderer, boardOperator, scoreboard, player);

            engine.Initialize(initializationStrategy);
            board.Subscribe(engine);
            engine.Run();
        }