Ejemplo n.º 1
0
    public void RpcEndGame(short winner, int[] teamScores)
    {
        if (!isLocalPlayer)
        {
            return;
        }
        MultiplayerManager.ClientNotifyGameEnd(winner);
        //Disable active camera controller, enable death camera controller
        activeCamera.GetComponent <BoatCameraNetworked>().enabled = false;
        activeCamera.GetComponent <OrbitalCamera>().enabled       = true;
        gameOver = true;

        //Set up game-over screen with relevant information
        GameObject endScreen = GameObject.Find("Canvas(Health)").transform.Find("EndScreen").gameObject;

        endScreen.SetActive(true);
        Text teamWin = endScreen.transform.Find("TeamWinText").GetComponent <Text>();

        teamWin.gameObject.SetActive(true);
        teamWin.text  = "Team " + MultiplayerManager.GetTeam(winner).teamName + " wins!";
        teamWin.color = MultiplayerManager.GetTeam(winner).teamColor;
        if (winner == team)
        {
            endScreen.transform.Find("YouWin").gameObject.SetActive(true);
        }
        else
        {
            endScreen.transform.Find("YouLose").gameObject.SetActive(true);
        }
        Text scoreText = endScreen.transform.Find("FinalScore").GetComponent <Text>();

        scoreText.text = "Scores: \n";
        for (short i = 0; i < MultiplayerManager.GetCurrentGamemode().NumTeams(); i++)
        {
            scoreText.text += MultiplayerManager.GetTeam(i).teamName + ": " + teamScores[i] + "\n";
        }
        //play sounds
        if (winner == team)
        {
            transform.Find("ShipSounds").Find("MatchWin").GetComponent <AudioSource>().Play();
        }
        else
        {
            transform.Find("ShipSounds").Find("MatchLose").GetComponent <AudioSource>().Play();
        }
        GameObject.Find("InGame").GetComponent <AudioSource>().volume = 0.1f;
        InputWrapper.CaptureKeyboard();
        InputWrapper.CaptureMouse();
    }
Ejemplo n.º 2
0
    private void Update()
    {
        //if the player presses down the button to access the chat
        if (Input.GetButtonDown(messageSendKey)) //Special permissions - bypass InputWrapper
        {
            //if already typing, player is trying to send a message
            //or close the window if their text is empty
            if (inputField.IsActive())
            {
                //make sure the player has entered a message that isn't just whitespace
                if (playerCurrentChatValue.Length > 0 && Regex.Replace(playerCurrentChatValue, @"\s+", "").Length > 0)
                {
                    ChatMessage newMessage = new ChatMessage();
                    newMessage.message    = playerCurrentChatValue;
                    newMessage.playerName = mpManager.localPlayerName;
                    newMessage.hour       = System.DateTime.Now.Hour;
                    newMessage.minute     = System.DateTime.Now.Minute;

                    //tell the handler to send the message to the other clients
                    chatHandler.SendOutMessage(newMessage);

                    inputField.text        = String.Empty;
                    playerCurrentChatValue = String.Empty;
                }
                //deactivate the chat entry area
                inputField.DeactivateInputField();
                chatEnterField.SetActive(false);
                InputWrapper.ReleaseKeyboard();
            }
            //if not typing already
            //open the chat entry area so they can begin typing
            else
            {
                chatEnterField.SetActive(true);
                inputField.Select();
                inputField.ActivateInputField();
                InputWrapper.CaptureKeyboard();
            }
        }
        else if (Input.GetKeyDown(KeyCode.Escape)) //allow canceling message with escape
        {
            //deactivate the chat entry area
            inputField.DeactivateInputField();
            chatEnterField.SetActive(false);
            InputWrapper.ReleaseKeyboard();
        }

        //update the UI with whatever chat messages are currently in the array
        //System.Object[] array = chatQueue.ToArray();
        //Array.Reverse(array);
        //for (int i = 0; i < textSlots.Length; i++)
        //{
        //    if (i < chatQueue.Count)
        //    {
        //        textSlots[i].text = ChatHandler.ChatMessageToString(((ChatMessage)array[i]));
        //    }
        //    else
        //    {
        //        textSlots[i].text = String.Empty;
        //    }
        //}
    }