Exemplo n.º 1
0
    // Send BoardOffsetMessage to the server (which sends it to all players)
    void SendBoardOffsetMessage()
    {
        // Move the board visuals to the placement of the board gizmo (this is also done again in ConnectFourBoard.OnBoardOffsetMessage)
        ConnectFourBoard.Instance.SetBoardOffset(NetworkManager.PlayerID, origin, rotation);

        var boardOffsetMsg = new BoardOffsetMessage()
        {
            playerId = NetworkManager.PlayerID,
            offset   = this.origin,
            rotation = this.rotation
        };

        Debug.Log("[CLIENT] ConnectFourBoardSetup : SendBoardSizeMessage - Sending board offset of offset=" + boardOffsetMsg.offset + ", rotation=" + rotation.eulerAngles);

        NetworkManager.Client.Send(ConnectFourMsgType.BoardOffset, boardOffsetMsg);
    }
Exemplo n.º 2
0
    // Called on the server when the client sends a message of type ConnectFourMsgType.BoardOffset to it
    void OnServerBoardOffsetMessage(NetworkMessage msg)
    {
        // Forward directly to the other player
        var boardOffsetMsg = msg.ReadMessage <BoardOffsetMessage>();

        // Save the offset's sent from the player (this is done so that if a player completes the setup before the other player has connected, we can send the newly-connected player the offsets)
        if (boardOffsetMsg.playerId == ConnectFour.PLAYER_ONE)
        {
            p1_offset = boardOffsetMsg;
        }
        else if (boardOffsetMsg.playerId == ConnectFour.PLAYER_TWO)
        {
            p2_offset = boardOffsetMsg;
        }

        // Send a BoardOffset message to all clients
        NetworkManager.SendToAll(ConnectFourMsgType.BoardOffset, boardOffsetMsg);
    }