public void Draw(Graphics g, GameState gState)
        {
            OwariGameState state = (OwariGameState)gState;

            for (int pos = 0; pos < 14; pos++)
                DrawBucket(g, state, pos);

            if (state.GameIsOver)
                DrawGameOver(g);
        }
예제 #2
0
        // A constructor that takes a premade board as its parameter.
        public GameServer(int port, GameState state, GameServerEventHandlerType aHandler)
        {
            this.shutDown = false;
            this.gameInProgress = false;
            this.client1Id = -1;
            this.client2Id = -1;
            this.connectionCount = 0;

            this.gameStateUpdateEventHandler = aHandler;
            this.logic = GameChoice.CurrentGame.GetNewGameLogic(state);

            this.server = new NetworkServer(port, new NetworkServerEventHandlerType(ServerEventHandler));
        }
 // An event with specified code, clientId, and message.
 public GameServerEventInfo(GameServerEventInfoCode aCode, GameState aState, string aMessage)
 {
     this.code = aCode;
     this.state = aState;
     this.message = aMessage;
 }
 // An event with specified code and clientId.
 public GameServerEventInfo(GameServerEventInfoCode aCode, GameState aState)
 {
     this.code = aCode;
     this.state = aState;
     this.message = null;
 }
예제 #5
0
 public TzaarLogic(GameState aState)
 {
     this.boardMap = new TzaarBoardMap();
     this.state = (TzaarGameState)aState;
 }
 public IGameLogic GetNewGameLogic(GameState aState)
 {
     return new TzaarLogic(aState);
 }
 public void Paint(Graphics g, GameState gameState)
 {
     this.painter.Draw(g, gameState);
 }
예제 #8
0
 public OwariLogic(GameState aState)
 {
     this.state = (OwariGameState)aState;
 }
예제 #9
0
 // Call the GUI handler so it can redraw the graphics, score, etc.
 private void CallEvent_Update(GameState state)
 {
     GameServerEventInfo info = new GameServerEventInfo(GameServerEventInfoCode.StateUpdated, state.Copy());
     this.gameStateUpdateEventHandler(info);
 }
 public IGameLogic GetNewGameLogic(GameState aState)
 {
     return new SkeletonLogic(aState);
 }
예제 #11
0
        public void Draw(Graphics g, GameState gState)
        {
            TzaarGameState state = (TzaarGameState)gState;

            // Draw the score counts.
            DrawPiece(g, Properties.Resources.WhiteTzaar, CurrentImageInfo.WhiteTzaarPoint, state.Board.WhiteTzaarCount.ToString(), TzaarColor.WHITE);
            DrawPiece(g, Properties.Resources.WhiteTzarra, CurrentImageInfo.WhiteTzarraPoint, state.Board.WhiteTzarraCount.ToString(), TzaarColor.WHITE);
            DrawPiece(g, Properties.Resources.WhiteTott, CurrentImageInfo.WhiteTottPoint, state.Board.WhiteTottCount.ToString(), TzaarColor.WHITE);
            DrawPiece(g, Properties.Resources.BlackTzaar, CurrentImageInfo.BlackTzaarPoint, state.Board.BlackTzaarCount.ToString(), TzaarColor.BLACK);
            DrawPiece(g, Properties.Resources.BlackTzarra, CurrentImageInfo.BlackTzarraPoint, state.Board.BlackTzarraCount.ToString(), TzaarColor.BLACK);
            DrawPiece(g, Properties.Resources.BlackTott, CurrentImageInfo.BlackTottPoint, state.Board.BlackTottCount.ToString(), TzaarColor.BLACK);

            // Now draw the board graphics updates.
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    Stack<TzaarPiece> S = state.Board.Query(i, j);
                    if (S == null)
                        break;
                    else if (S.Count == 0)
                        continue;
                    else
                        // There is at least 1 piece on this location; display it.
                        this.DrawStack(g, S, i, j);
                }
            }

            if (state.GameIsOver)
                DrawGameOver(g);
        }
        public new void Draw(Graphics g, GameState aState)
        {
            base.Draw(g, (TzaarGameState)aState);

            if (this.aPositionIsSelected)
                // Highlight a piece on the board.
                HighlightPosition(g, this.selectionCol, this.selectionRow);

            if (this.passButtonEnabled)
                // Draw a pass button.
                DrawPassButton(g);

            if (this.enableColorLogo)
                DrawLogo(g);
        }
        private void SwitchGames(int gameIndex, GameBoard aBoard)
        {
            if (!Prompt_StopCurrentGame())
                return;

            StopServer();

            this.gameStateQueue.Clear();
            this.currentGameState = null;

            GameChoice.SetCurrentGame(gameIndex);

            this.boardPainter = GameChoice.CurrentGame.GetNewGamePainter(pictureBox1);

            if (GameChoice.GameSupportsConfiguration(GameChoice.CurrentGame))
            {
                this.gamePropertyGrid = ((IGameConfig)GameChoice.CurrentGame).GetPropertyGrid();
                ChangeConfigMenuItem(true, "");
            }
            else
            {
                // This game does not support configuration.
                this.gamePropertyGrid = null;
                ChangeConfigMenuItem(false, "This game does not support configuration.");
            }

            Display("Loaded Game: " + GameChoice.CurrentGame.GetGameName() + ".\n");

            SetupInitialBoardState(aBoard);

            // Set the appropriate checkbox in the menu.
            for (int i = 0; i < GameChoice.Games.Length; i++)
                if (i == gameIndex)
                {
                    ((ToolStripMenuItem)this.switchGameToolStripMenuItem.DropDownItems[i]).Checked = true;
                    ((ToolStripMenuItem)this.switchGameToolStripMenuItem.DropDownItems[i]).CheckState = CheckState.Checked;
                }
                else
                {
                    ((ToolStripMenuItem)this.switchGameToolStripMenuItem.DropDownItems[i]).Checked = false;
                    ((ToolStripMenuItem)this.switchGameToolStripMenuItem.DropDownItems[i]).CheckState = CheckState.Unchecked;
                }

            StartServer();
        }
        private void SetupInitialBoardState(GameBoard aBoard)
        {
            if (aBoard == null)
                this.currentGameState = GameChoice.CurrentGame.GetNewGameState();
            else
                this.currentGameState = GameChoice.CurrentGame.GetNewGameState(aBoard);

            pictureBox1.Invalidate();
        }
        // This is where we actually do the screen updates.
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.CompositingQuality = CompositingQuality.HighQuality;
            g.SmoothingMode = SmoothingMode.HighQuality;

            // Process all the state snapshots on the queue.
            while (this.gameStateQueue.Count > 0)
            {
                GameState state = this.gameStateQueue.Dequeue();

                // Clear out the message queue on a game-switch.
                if (this.currentGameState != null && state.GetType() != this.currentGameState.GetType())
                    continue;

                // Process the state.
                this.currentGameState = state;
            }

            // Display the current game state.
            this.boardPainter.Draw(g, this.currentGameState);
        }
 // Construct and return a new instance of the game-specific IGameLogic.
 public IGameLogic GetNewGameLogic(GameState aState)
 {
     return new OwariLogic(aState);
 }