Esempio n. 1
0
        public void handleRPCMove(NetworkMessage RPCMsg)
        {
            byte[]      bytes = RPCMsg.reader.ReadBytesAndSize();
            RPCMove     msg   = Deserialize <RPCMove> (bytes);
            PlayerColor color = msg.color;
            int         move  = msg.move;

            localRenderer.dropPiece(move, color == PlayerColor.Yellow ? Piece.Yellow : Piece.Red);
        }
Esempio n. 2
0
        public void onPlayerMove(object stringMsg, ConnectedClient c)
        {
            CommProtocol.StringMessage msg = (CommProtocol.StringMessage)stringMsg;
            ConnectedPlayer            p   = mainGame.getCurrentPlayer();

            mainGame.debugPrint("Incoming from: " + msg.color);
            if (msg.color != p.color || c.peerID != p.client.peerID || gameOver)
            {
                return;
            }

            string move = msg.msg;
            int    col;

            if (!int.TryParse(move, out col) || !board.isAllowedMove(col))
            {
                protocol.requestMove(p.client.peerID, board.ToString(), mainGame.getCurrentPlayer().color);
                return;
            }

            //Valid move was made
            mainGame.pushToRawLog(move);
            moveCounter++;
            board.dropPiece(p.color == Game.PlayerColor.Yellow ? BoardLogic.Piece.Yellow : BoardLogic.Piece.Red, col);
            RPCMove RPCmsg = new RPCMove(int.Parse(move), p.color);

            mainGame.broadcastRPCMove(RPCmsg);

            Game.PlayerColor winColor = board.hasWinner();
            if (winColor != Game.PlayerColor.None || moveCounter == 42)
            {
                mainGame.setGameOver(winColor);
                return;
            }

            mainGame.switchToNextPlayer();
            mainGame.startPlayerTimer();
            protocol.requestMove(mainGame.getCurrentPlayer().client.peerID, board.ToString(), mainGame.getCurrentPlayer().color);
        }
Esempio n. 3
0
 public void sendRPCMove(int targetID, RPCMove move)
 {
     sendMsg(move, targetID, (short)MsgType.RPCMove);
 }