// --- CLIENT CALLBACKS --- // Called on client when we connect to the server. void OnClientConnect(NetworkMessage msg) { // Immediately skip setup on connect if we're running in headless mode if (ConnectFourNPC.IsHeadlessMode()) { SkipSetup(); } // If we've already completed setup (this happens if this connect is a re-connect after the setup), immediately ready-up if (completedSetup) { // Re-send our board offset/size messages SendBoardSizeMessage(); SendBoardOffsetMessage(); // Set client state to ready on the server ClientScene.Ready(NetworkManager.Client.connection); // Show the board visuals ConnectFourBoard.Instance.ShowBoard(); } // Begin setup else { Debug.Log("[CLIENT] ConnectFourBoardSetup : OnClientConnect - Starting board setup..."); doingPlacement = true; FadeInitialHandle(true); boardSetupCanvas.DOFade(1.0f, 0.5f); } }
// Send BoardSizeMessage to server, only if the board size isn't fixed (i.e. the other player already set the board size) void SendBoardSizeMessage() { // Never send board size if we already have one, or if this is a headless instance if (hasFixedBoardSize || ConnectFourNPC.IsHeadlessMode()) { return; } var boardSizeMsg = new BoardSizeMessage() { playerId = NetworkManager.PlayerID, size = new Vector2(GetBoardWidth(), GetBoardHeight()), }; Debug.Log("[CLIENT] ConnectFourBoardSetup : SendBoardSizeMessage - Sending board size of " + boardSizeMsg.size); NetworkManager.Client.Send(ConnectFourMsgType.BoardSize, boardSizeMsg); }