Esempio n. 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();
        }
    }
    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;
            }
        }
    }
Esempio n. 3
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;
            }
        }
    }
Esempio n. 4
0
    public void RpcEndGame()
    {
        SetReady(false);

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

            GUIManagerScript.SetBackButton(false);

            AudioManagerScript.instance.EndGameMusic();

            AudioManagerScript.instance.PlayRoundEnd(scored_GuessedCorrect);

            GUIManagerScript.HideColorShow();
        }
    }
Esempio n. 5
0
    void SortPlayers()
    {
        List <CaptainsMessPlayer> players = mess.Players();
        int i    = 0;
        int size = players.Count;

        List <CaptainsMessPlayer> SortedList = players.OrderBy(o => o.GetComponent <NetworkedPlayerScript>().nameText).ToList();

        foreach (CaptainsMessPlayer player in SortedList)
        {
            NetworkedPlayerScript nps = player.GetComponent <NetworkedPlayerScript>();
            if (!nps.isLocalPlayer)
            {
                RemotePlayerScript rps = player.GetComponent <RemotePlayerScript>();

                Vector3 goal = rps.SetPosition(++i, size);

                if (nps.playerButton.activeSelf == false)
                {
                    nps.playerButton.SetActive(true);
                    nps.playerButton.transform.localPosition = new Vector3(i * 160, -340, 0);
                }

                nps.playerButton.transform.DOLocalMove(goal, movementSpeed);
                nps.playerButton.transform.DOScale(Vector3.one, movementSpeed);
            }
            nps.SetColor();
            nps.SetNameText();
        }

        if (size >= 4)
        {
            GUIManagerScript.SetButton(true);
        }
        else
        {
            GUIManagerScript.SetButton(false);
        }

        playerParent.GetComponent <RectTransform>().sizeDelta = new Vector2(160 * (size + 1), 340);
    }