コード例 #1
0
    // Redundant? Possible. But I am not sure
    // Unity says this is the one to use, yet OnDestroy works and possibly works better?
    // Let's do both to be safe.
    void OnDestroy()
    {
        //print("Player was was destroyed");
        if (playerButton != null)
        {
            Destroy(playerButton);
        }

        if (isLocalPlayer)
        {
            GUIManagerScript.SetInput(false);
            GUIManagerScript.SetButton(false);
            GUIManagerScript.SetRulesButton(false);
            GUIManagerScript.SetBackButton(false);
            GUIManagerScript.HideColorShow();
            if (GUIManagerScript.countdownText != null)
            {
                GUIManagerScript.countdownText.enabled = false;
            }

            if (AudioManagerScript.instance != null)
            {
                AudioManagerScript.instance.StopSFX();
                AudioManagerScript.instance.EndGameMusic();
                AudioManagerScript.instance.StartMenuMusic();
            }
        }

        // If this is a client player on the server then OnClientExitLobby will not be called.
        // Call it here instead.
        if (networkManager.IsHost() && networkManager.localPlayer != this)
        {
            OnClientExitLobby();
        }
    }
コード例 #2
0
    void Start()
    {
        playerParent = GUIManagerScript.playerParent;
        playerButton = transform.Find("PlayerButton").gameObject;

        playerButton.transform.SetParent(playerParent.transform, false);
        playerButton.transform.localScale = Vector3.one;

        playerButtonOutline         = playerButton.GetComponent <Outline>();
        playerButtonOutline.enabled = false;

        playerButton.SetActive(false);

        if (isLocalPlayer)
        {
            playerButton.GetComponent <Button>().interactable = false;
            playerButton.transform.localPosition = Vector3.zero;

            GUIManagerScript.DisableInput(false);
            GUIManagerScript.SetBackButton(false);

            nameText = "";
            GUIManagerScript.FillPlayerText(nameText);
        }
    }
コード例 #3
0
    public void BackButtonPressed()
    {
        // Oops, let's reset the match ID
        networkedPScript.CmdResetMatchSongID();

        List <CaptainsMessPlayer> players = networkedPScript.GetPlayers();

        int size = players.Count;

        foreach (CaptainsMessPlayer player in players)
        {
            NetworkedPlayerScript nps = player.GetComponent <NetworkedPlayerScript>();
            if (!nps.isLocalPlayer)
            {
                nps.playerButton.SetActive(true);
                nps.playerButton.GetComponent <Button>().interactable = true;

                Vector3 goal = player.GetComponent <RemotePlayerScript>().GetPosition();

                nps.playerButton.transform.DOLocalMove(goal, nps.fastMovementSpeed);
                nps.playerButton.transform.DOScale(Vector3.one, nps.fastMovementSpeed);
            }
            else
            {
                nps.playerParent.GetComponent <RectTransform>().sizeDelta = new Vector2(160 * (size + 1), 340);
            }
        }


        GUIManagerScript.SetBackButton(false);
    }
コード例 #4
0
    public void RpcStartGame(int s)
    {
        songID            = s;
        scored_ThisRound  = 0;
        scored_TimeBonus  = 0;
        scored_FirstBonus = false;
        scored_WasGuessed = false;

        //playerParent.GetComponent<PlayerParentScript>().Unlock();

        // Bullshit code. Temp? Maybe not?
        // What if player WAS ready, but now that we're actually starting they are no longer?
        // Too late for them! Let's double check
        if (!ready)
        {
            Assert.IsFalse(ready, "Player wasn't ready, but the server thought they were!");
            // Oh noes! What do we do? Let's cheat:
            SetReady(true);
            // See buddy, you were ready the whole time, right?
        }
        ResetMatch();

        if (isLocalPlayer)
        {
            GUIManagerScript.SetButton(false);

            GUIManagerScript.SetBackButton(false);

            Color clr = ColorScript.GetColor(GetColor());
            clr = clr * 0.5f;
            GUIManagerScript.SetNumberInputFieldColor(clr);
            GUIManagerScript.ClearNumberInput();
            GUIManagerScript.SetSongSetButton(false);

            //Hacky bullshit for finding which kind of game we're in?
            GameManagerScript gameManager = FindObjectOfType <GameManagerScript>();
            Assert.IsNotNull <GameManagerScript>(gameManager);
            int index = gameManager.GetSongSet();

            AudioManagerScript.instance.StartGameMusic(index);

            GUIManagerScript.SetClassicGameParent(color, ColorScript.GetColor(color), ColorScript.GetColorName(color));

            localPScript.reminded = false;
        }

        List <CaptainsMessPlayer> players = GetPlayers();

        foreach (CaptainsMessPlayer player in players)
        {
            NetworkedPlayerScript nps = player.GetComponent <NetworkedPlayerScript>();
            if (!nps.isLocalPlayer)
            {
                player.GetComponent <NetworkedPlayerScript>().playerButton.SetActive(true);
                player.GetComponent <NetworkedPlayerScript>().playerButton.GetComponent <Button>().interactable = true;
            }
        }
    }
コード例 #5
0
    public void RpcStartGame(int s)
    {
        songID            = s;
        scored_ThisRound  = 0;
        scored_TimeBonus  = 0;
        scored_FirstBonus = false;
        scored_WasGuessed = false;

        //playerParent.GetComponent<PlayerParentScript>().Unlock();

        // Bullshit code. Temp? Maybe not?
        // What if player WAS ready, but now that we're actually starting they are no longer?
        // Too late for them! Let's double check
        if (!ready)
        {
            Assert.IsFalse(ready, "Player wasn't ready, but the server thought they were!");
            // Oh noes! What do we do? Let's cheat:
            SetReady(true);
            // See buddy, you were ready the whole time, right?
        }
        ResetMatch();

        if (isLocalPlayer)
        {
            GUIManagerScript.FillPlayerText(nameText);

            GUIManagerScript.SetButton(false);

            GUIManagerScript.DisableInput(true);
            GUIManagerScript.SetBackButton(false);

            AudioManagerScript.instance.StartGameMusic();

            GUIManagerScript.SetColorShow(nameText, ColorScript.GetColor(color), ColorScript.GetColorName(color));

            localPScript.reminded = false;
        }

        List <CaptainsMessPlayer> players = GetPlayers();

        foreach (CaptainsMessPlayer player in players)
        {
            NetworkedPlayerScript nps = player.GetComponent <NetworkedPlayerScript>();
            if (!nps.isLocalPlayer)
            {
                player.GetComponent <NetworkedPlayerScript>().playerButton.SetActive(true);
                player.GetComponent <NetworkedPlayerScript>().playerButton.GetComponent <Button>().interactable = true;
            }
        }
    }
コード例 #6
0
    public void LockChoiceButtonPressed()
    {
        InputField numberTextField = GUIManagerScript.numberTextField;

        int input = -1;

        if (System.Int32.TryParse(numberTextField.text, out input))
        {
            int s = DoesPlayerNumberExist(input);
            if (s != -1)
            {
                CmdSetMatchSongID(s, input);
                GUIManagerScript.NumberInputLocked(true);
                GUIManagerScript.SetBackButton(true);
            }
        }
    }
コード例 #7
0
    public void RpcEndGame()
    {
        SetReady(false);

        if (isLocalPlayer)
        {
            GUIManagerScript.SetButton(true);

            GUIManagerScript.SetBackButton(false);

            AudioManagerScript.instance.EndGameMusic();

            AudioManagerScript.instance.PlayRoundEnd(scored_GuessedCorrect);

            GUIManagerScript.HideColorShow();
        }
    }
コード例 #8
0
    public void PlayerButtonPressed()
    {
        GameManagerScript gameManager = FindObjectOfType <GameManagerScript>();

        Assert.IsNotNull <GameManagerScript>(gameManager);

        if (isLocalPlayer)
        {
            if (!gameManager.IsGameStarted())
            {
                ToggleReady();
            }
        }
        else
        {
            if (gameManager.IsGameStarted())
            {
                List <CaptainsMessPlayer> players = GetPlayers();
                foreach (CaptainsMessPlayer player in players)
                {
                    NetworkedPlayerScript nps = player.GetComponent <NetworkedPlayerScript>();
                    if (player.name == "LOCAL Player")
                    {
                        nps.CmdSetMatchSongID(songID, color);
                    }
                    nps.playerButton.SetActive(false);
                    nps.playerButton.GetComponent <Button>().interactable = false;
                }

                playerButton.SetActive(true);
                playerButton.GetComponent <Button>().interactable = false;
                playerButton.transform.DOLocalMove(new Vector3(30, 20, 0), fastMovementSpeed);
                playerButton.transform.DOScale(new Vector3(1.5f, 1.5f, 1f), fastMovementSpeed);

                playerParent.GetComponent <RectTransform>().sizeDelta = new Vector2(170, 140);

                GUIManagerScript.SetBackButton(true);
            }
        }
    }
コード例 #9
0
    public void BackButtonPressed()
    {
        // Oops, let's reset the match ID
        networkedPScript.CmdResetMatchSongID();

        GUIManagerScript.NumberInputLocked(false);

        List <CaptainsMessPlayer> players = networkedPScript.GetPlayers();

        int size = players.Count;

        foreach (CaptainsMessPlayer player in players)
        {
            NetworkedPlayerScript nps = player.GetComponent <NetworkedPlayerScript>();
            if (!nps.isLocalPlayer)
            {
                nps.playerButton.SetActive(true);
                nps.playerButton.GetComponent <Button>().interactable = true;

                Vector3 goal = player.GetComponent <RemotePlayerScript>().GetPosition();

                nps.playerButton.transform.DOLocalMove(goal, nps.fastMovementSpeed);
                nps.playerButton.transform.DOScale(Vector3.one, nps.fastMovementSpeed);
            }
            else
            {
                nps.playerParent.GetComponent <RectTransform>().sizeDelta = new Vector2(160 * (size + 1), 340);
            }
        }

        // Optional clear colors after backing out of choice?

        /*Color clr = ColorScript.GetColor(networkedPScript.GetColor());
         * clr = clr * 0.5f;
         * GUIManagerScript.SetNumberInputFieldColor(clr);
         * GUIManagerScript.ClearNumberInput();*/

        GUIManagerScript.SetBackButton(false);
    }