Ejemplo n.º 1
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;
        }
    }
Ejemplo n.º 2
0
    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();
        }
    }