Exemple #1
0
    public void ConnectIP()
    {
        if (Topan.Network.isConnected)
        {
            return;
        }

        NetworkingGeneral.CreateInstance(cachedNetworking);
        Topan.Network.AddNetworkEventListener(this);
        TopanData initData = new TopanData();

        initData.Add("dat", NetworkingGeneral.ConvertToCombatant(AccountManager.profileData));
        PlayerPrefs.SetString("SavedIPConnect", DarkRef.RemoveSpaces(IPInput.value));
        PlayerPrefs.SetString("SavedPortConnect", portInput.value);
        Topan.Network.Connect(DarkRef.RemoveSpaces(IPInput.value), int.Parse(portInput.value), initData);
        GeneralVariables.lobbyManager.joiningLobby = true;
    }
Exemple #2
0
    private IEnumerator VersionCheckCoroutine()
    {
        multiplayerEnabled = true; //Set to false when version check is ready

        while (!multiplayerEnabled)
        {
            WWW verChk = new WWW("http://darkraze.byethost6.com/darkraze_files/versionChk.txt");

            yield return(verChk);

            bool unavailable = false;
            if (verChk.error != null)
            {
                mpErrorTooltip.text = "Version validation service is unavailable.";
                unavailable         = true;
            }
            else
            {
                if (DarkRef.RemoveSpaces(DarkRef.GetBuildVersion(true)) == DarkRef.RemoveSpaces(verChk.text))
                {
                    multiplayerEnabled = true;
                    yield break;
                }
                else
                {
                    Debug.LogWarning("Your version is not the latest! Multiplayer will be disabled");
                    mpErrorTooltip.text = "Your client version must be up-to-date to participate in multiplayer!";
                }
            }

            float waitTime = 0f;
            while (waitTime < 5.1f)
            {
                waitTime += Time.deltaTime;

                if (unavailable)
                {
                    mpErrorTooltip.text = "Version validation service is unavailable (retrying in: " + Mathf.Max(0f, 5.1f - waitTime).ToString("F0") + ").";
                }

                yield return(null);
            }
        }
    }
Exemple #3
0
    void Update()
    {
        if (!Topan.Network.isConnected)
        {
            return;
        }

        if (chatLength != NetworkingGeneral.gameChatList.Count)
        {
            chatOutput.CopyList(NetworkingGeneral.gameChatList);
            chatLength = NetworkingGeneral.gameChatList.Count;
        }

        if (Time.unscaledTime - chatActionTime >= antiFloodTime && Input.GetKeyDown(KeyCode.Return))
        {
            if (!chatInput.isSelected)
            {
                chatInput.isSelected = true;
            }
            else
            {
                bool sameAsLastMsg = (chatOutput.chatList.Count > 0) ? DarkRef.RemoveSpaces(chatOutput.chatList[chatOutput.chatList.Count - 1].ToLower()) == DarkRef.RemoveSpaces(chatInput.value.ToLower()) : false;
                if (netView != null && !string.IsNullOrEmpty(DarkRef.RemoveSpaces(chatInput.value)) && !sameAsLastMsg)
                {
                    string message = "[DAA314]" + AccountManager.profileData.username + "[-]: " + chatInput.value;
                    netView.RPC(Topan.RPCMode.All, "ChatMessage", message);
                }

                if (!string.IsNullOrEmpty(chatInput.value))
                {
                    chatActionTime = Time.unscaledTime;
                }

                chatInput.value      = "";
                chatInput.isSelected = false;
            }
        }
    }
Exemple #4
0
    void Update()
    {
        if (!Topan.Network.isConnected)
        {
            return;
        }

        if (chatLength != chatOutput.chatList.Count)
        {
            UpdateChatList();
        }

        bool allChatPressed  = cInput.GetButtonDown("General Chat");
        bool teamChatPressed = GeneralVariables.gameModeHasTeams && cInput.GetButtonDown("Team Chat");

        if (!(RestrictionManager.restricted && !RestrictionManager.allInput) && !RoundEndManager.isRoundEnded && allChatPressed || (useTeamChat && teamChatPressed))
        {
            if (!chatInput.isSelected)
            {
                if (Time.unscaledTime - floodTime >= antiFloodTime)
                {
                    //                    chatInput.restrictFrames = 1;
                    chatInput.isSelected        = true;
                    RestrictionManager.allInput = true;

                    if (teamChatPressed)
                    {
                        isTeamChat = true;
                    }

                    if (chatIndicator != null)
                    {
                        if (teamChatPressed)
                        {
                            chatIndLabel.text = "TEAM";
                        }
                        else
                        {
                            chatIndLabel.text = "ALL";
                        }

                        if (useTeamChat)
                        {
                            chatIndicator.alpha = 1f;
                        }
                    }

                    startChatTime = Time.unscaledTime;
                }
            }
            else if (Input.GetKeyDown(primaryChatKey.ToLower()))
            {
                bool sameAsLastMsg = (chatOutput.chatList.Count > 0) ? DarkRef.RemoveSpaces(chatOutput.chatList[chatOutput.chatList.Count - 1].ToLower()) == DarkRef.RemoveSpaces(chatInput.value.ToLower()) : false;
                if (chatNetGeneral != null && !string.IsNullOrEmpty(DarkRef.RemoveSpaces(chatInput.value)) && !(spamProtection && sameAsLastMsg))
                {
                    if (isTeamChat)
                    {
                        int    myTeam  = (int)((byte)Topan.Network.player.GetPlayerData("team"));
                        string message = "[TEAM] [DAA314]" + AccountManager.profileData.username + "[-]: " + chatInput.value;
                        NetworkingGeneral.gameChatList.Add(message);
                        chatNetGeneral.RPC(DarkRef.SendTeamMessage(myTeam), "ChatMessage", message);
                    }
                    else
                    {
                        chatNetGeneral.RPC(Topan.RPCMode.All, "ChatMessage", "[DAA314]" + AccountManager.profileData.username + "[-]: " + chatInput.value);
                    }
                }
                if (!string.IsNullOrEmpty(chatInput.value))
                {
                    floodTime = Time.unscaledTime;
                }

                chatInput.value               = "";
                chatInput.isSelected          = false;
                isTeamChat                    = false;
                RestrictionManager.restricted = false;
            }
        }

        if (Time.unscaledTime - startChatTime >= 0.6f)
        {
            chatIndicator.alpha -= Time.unscaledDeltaTime * 2.2f;
        }
    }
    void Update()
    {
        inSpawnScreen = (GeneralVariables.spawnController != null && GeneralVariables.spawnController.inSpawnScreen);
        if (showGUI != (Topan.Network.isConnected && !inSpawnScreen))
        {
            GUICheckMP();
        }

        if (Topan.Network.isConnected)
        {
            if (leaderboard.alpha <= 0f && cInput.GetButtonDown("Leaderboard") && !RestrictionManager.restricted)
            {
                lGUI.Refresh(); //Refresh once leaderboard fades in.
            }

            if (!RestrictionManager.restricted && Time.time > 1f && cInput.GetButton("Leaderboard"))
            {
                leaderboard.alpha = Mathf.MoveTowards(leaderboard.alpha, 1f, Time.unscaledDeltaTime * 7f);
            }
            else
            {
                leaderboard.alpha = Mathf.MoveTowards(leaderboard.alpha, 0f, Time.unscaledDeltaTime * 7f);
            }

            if (GeneralVariables.Networking != null)
            {
                serverPL = (byte)Topan.Network.connectedPlayers.Length;
                if (!GeneralVariables.Networking.matchStarted)
                {
                    GeneralVariables.uiController.mpGUI.timerLabels[0].text = "--";
                    GeneralVariables.uiController.mpGUI.timerLabels[1].text = "--";

                    syncTimer += Time.deltaTime;
                    if (syncTimer >= 1f)
                    {
                        int peopleLeft = Mathf.Max(0, Mathf.CeilToInt(Topan.Network.connectedPlayers.Length * 0.25f) - GeneralVariables.Networking.availablePlayers.Length);
                        if (Topan.Network.isServer && GeneralVariables.server != null && peopleLeft != lastSentPL)
                        {
                            Topan.Network.SetServerInfo("pl", (byte)peopleLeft);
                            lastSentPL = peopleLeft;
                        }

                        syncTimer -= 1f;
                    }

                    if (Topan.Network.HasServerInfo("pl"))
                    {
                        serverPL = (byte)Topan.Network.GetServerInfo("pl");
                    }
                }

                waitForPlayers.gameObject.SetActive(true);

                if (!GeneralVariables.Networking.matchStarted && !GeneralVariables.Networking.finishedGame && !GeneralVariables.Networking.countingDown && serverPL > 0)
                {
                    waitForPlayers.alpha = Mathf.MoveTowards(waitForPlayers.alpha, 1f, Time.unscaledDeltaTime * 6f);
                    waitText.text        = "BATTLE AWAITING";
                    playersLeft.text     = serverPL.ToString() + " player" + ((serverPL > 1) ? "s" : "") + " left";
                }
                else if (GeneralVariables.Networking.countingDown && !GeneralVariables.Networking.finishedGame && GeneralVariables.Networking.countdown >= 0 && serverPL <= 0)
                {
                    waitForPlayers.alpha = Mathf.MoveTowards(waitForPlayers.alpha, 1f, Time.unscaledDeltaTime * 6f);
                    waitText.text        = "BATTLE IMMINENT";
                    playersLeft.text     = "Match starting in: " + GeneralVariables.Networking.countdown.ToString();
                }
                else
                {
                    waitForPlayers.alpha = Mathf.MoveTowards(waitForPlayers.alpha, 0f, Time.unscaledDeltaTime * 6f);
                }
            }
        }

        ObjectiveProgressGUI();

        if (showGUI)
        {
            if (gManager != null)
            {
                gManager.leaderboardBlur = leaderboard.alpha * 0.9f;
            }

            if (chatLength != NetworkingGeneral.gameChatList.Count)
            {
                chatOutput.CopyList(NetworkingGeneral.gameChatList);
                chatLength      = NetworkingGeneral.gameChatList.Count;
                inactivityTimer = 0f;
            }

            if (!(RestrictionManager.restricted && !RestrictionManager.allInput) && !RoundEndManager.isRoundEnded)
            {
                bool allChatPressed  = cInput.GetButtonDown("General Chat");
                bool teamChatPressed = GeneralVariables.gameModeHasTeams && cInput.GetButtonDown("Team Chat");
                if (allChatPressed || teamChatPressed)
                {
                    if (!chatInput.isSelected)
                    {
                        if (Time.unscaledTime - startChatTime >= 0.25f)
                        {
                            chatInput.isSelected = true;
                            //                            chatInput.restrictFrames = 1;
                            RestrictionManager.allInput = true;

                            if (teamChatPressed)
                            {
                                isTeamChat        = true;
                                chatIndLabel.text = "TEAM";
                            }
                            else
                            {
                                chatIndLabel.text = "ALL";
                            }

                            chatIndicator.alpha = 1f;
                            startChatTime       = Time.unscaledTime;
                        }
                    }
                    else if (Input.GetKeyDown(allChat.ToLower()))
                    {
                        bool sameAsLastMsg = (chatOutput.chatList.Count > 0) ? DarkRef.RemoveSpaces(chatOutput.chatList[chatOutput.chatList.Count - 1].ToLower()) == DarkRef.RemoveSpaces(chatInput.value.ToLower()) : false;
                        if (!string.IsNullOrEmpty(DarkRef.RemoveSpaces(chatInput.value)) && !sameAsLastMsg)
                        {
                            if (isTeamChat)
                            {
                                int    myTeam  = (int)((byte)Topan.Network.player.GetPlayerData("team"));
                                string message = "[TEAM] [DAA314]" + AccountManager.profileData.username + "[-]: " + chatInput.value;
                                NetworkingGeneral.gameChatList.Add(message);
                                chatNetGeneral.RPC(DarkRef.SendTeamMessage(myTeam), "ChatMessage", message);
                            }
                            else
                            {
                                chatNetGeneral.RPC(Topan.RPCMode.All, "ChatMessage", "[DAA314]" + AccountManager.profileData.username + "[-]: " + chatInput.value);
                            }
                        }

                        chatInput.value               = "";
                        chatInput.isSelected          = false;
                        isTeamChat                    = false;
                        RestrictionManager.restricted = false;
                    }
                }
            }

            if (Time.unscaledTime - startChatTime >= 0.6f)
            {
                chatIndicator.alpha -= Time.unscaledDeltaTime * 2.2f;
            }

            ChatFocusGUI();
        }
    }