Example #1
0
    void HostingWindow(int windowID)        // Window 5
    {
        GUILayout.BeginVertical();
        GUILayout.Space(5);

        if (networkManager.info == false)
        {
            if (networkManager.hosting == true && networkManager.connectionType == NetworkManager.ConnectionType.Hosting)
            {
                GUILayout.Label("Waiting for Opponent", labelCenterMediumStyle);

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Label(loadingImage.CurrentLoadingImage());
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }

            if (networkManager.hosting == true && networkManager.connectionType == NetworkManager.ConnectionType.Connected)
            {
                GUILayout.Label(preferencesManager.preferences.playerName + " VS " + networkManager.opponent.name, labelCenterLargeStyle);

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Label("Match length: Indefinite", labelLeftMediumStyle);
                GUILayout.FlexibleSpace();
                GUILayout.Label("Cards in MasterDeck: " + deckManager.masterDeck.gameCards.Length, labelLeftMediumStyle);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                if (networkManager.options == false)
                {
                    GUILayout.Space(20);
                    if (GUILayout.Button("Begin Match", buttonCenterLargeStyle))
                    {
                        deckManager.SetupDecks();
                        networkManager.connectionType = NetworkManager.ConnectionType.Playing;
                        networkManager.BrodcastChatMessage("Match between " + preferencesManager.preferences.playerName + " and " + networkManager.opponent.name + " started at " + System.DateTime.Now.ToString("HH:mm") + "!");
                    }

                    GUILayout.Space(5);
                    if (GUILayout.Button("Match Options", buttonCenterMediumStyle))
                    {
                        networkManager.options = true;
                    }

                    if (GUILayout.Button("Boot Opponent", buttonCenterMediumStyle))
                    {
                        debugLog.ReceiveMessage("\nBooting Opponent");
                        if (networkManager.BootOpponent())
                        {
                            debugLog.ReceiveMessage("\tOpponent Disconnected Successfully");
                        }
                        else
                        {
                            debugLog.ReceiveMessage("\tERROR: Unable to Disconnect Opponent");
                        }
                    }
                }
                else
                {
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Back", buttonCenterMediumStyle))
                    {
                        networkManager.options = false;
                    }
                }
            }
        }
        else
        {
            GUILayout.Label(networkManager.infoString, labelCenterMediumStyle);
        }

        if (networkManager.options == false)
        {
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Disable Hosting", buttonCenterMediumStyle))
            {
                debugLog.ReceiveMessage("\nShutting Down Server");
                if (networkManager.ShutdownHost())
                {
                    debugLog.ReceiveMessage("\tHosting Disabled Successfully");
                }
                else
                {
                    debugLog.ReceiveMessage("\tERROR: Unable to Disable Hosting");
                }

                play    = true;
                options = false;

                GUI.FocusControl("");
                GUI.FocusWindow(1);
            }
        }

        GUILayout.EndVertical();
    }