コード例 #1
0
ファイル: MainScript.cs プロジェクト: BaudoinWR/colors
    private void UpdateColor(float currentPosition)
    {
        textDebug.text  = "Mouse : " + Input.GetMouseButton(0);
        textDebug.text += "\ncurrentPosition : " + currentPosition;
        textDebug.text += "\npreviousPosition : " + previousPosition;
        textDebug.text += "\nchangingColor : " + isChangingColor;
        textDebug.text += "\nsaveFile : " + FileManagerScript.pathForDocumentsFile("colorSave");

        if (isChangingColor)
        {
            UpdateDirection(currentPosition);
            textDebug.text += "\ngoingUp : " + isGoingUp;

            previousPosition = currentPosition;

            float period = GetAverage(periods.ToArray());
            textDebug.text += "\nperiod : " + period;

            Color col = ColorScript.GetColor(period);
            lightGenerator.GetComponent <SpriteRenderer>().color = col;
            sin.GetComponent <SinWaveScript>().period            = period;
            sin.GetComponent <SinWaveScript>().c2 = col;
            textDebug.text += "\ncolor : " + col;

            while (periods.ToArray().Length > numberAveraged)
            {
                periods.Dequeue();
            }
        }
    }
コード例 #2
0
    private static void NumberInputProcessed(bool del)
    {
        GameObject            player = GameObject.Find("LOCAL Player");
        NetworkedPlayerScript nps    = player.GetComponent <NetworkedPlayerScript>();

        bool shouldClear = true;

        if (numberTextField.text != null)
        {
            int input = -1;
            if (System.Int32.TryParse(numberTextField.text, out input))
            {
                if (nps.GetColor() != input)
                {
                    if (nps.DoesPlayerNumberExist(input) != -1)
                    {
                        GUIManagerScript.SetNumberInputFieldColor(ColorScript.GetColor(input), true);
                        shouldClear = false;
                    }
                }
            }
        }

        if (shouldClear)
        {
            Color clr = ColorScript.GetColor(nps.GetColor());
            clr = clr * 0.5f;
            GUIManagerScript.SetNumberInputFieldColor(clr);

            if (del)
            {
                GUIManagerScript.ClearNumberInput();
            }
        }
    }
コード例 #3
0
    public static Color generateNewColor()
    {
        float period = Random.Range(0.055f, 1);
        Color col    = ColorScript.GetColor(period);

        return(col);
    }
コード例 #4
0
 void SetColor()
 {
     if (color != -1)
     {
         Color c = ColorScript.GetColor(color);
         playerButton.GetComponent <Image>().color = c;
     }
 }
コード例 #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.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;
            }
        }
    }
コード例 #6
0
 void SetColor()
 {
     if (color != -1)
     {
         Color c = ColorScript.GetColor(color);
         playerButton.GetComponent <Image>().color         = c;
         playerButton.GetComponentInChildren <Text>().text = color.ToString();
     }
 }
コード例 #7
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;
            }
        }
    }
コード例 #8
0
    void RpcSetColor(int c)
    {
        color   = c;
        to_sort = true;

        SetColor();

        if (isLocalPlayer)
        {
            string clr_name = ColorScript.GetColorName(c);

            Color clr = ColorScript.GetColor(c);
            GUIManagerScript.SetInputColor(clr, clr_name);
            clr = clr * 0.5f;
            GUIManagerScript.SetBGColor(clr);
            GUIManagerScript.FillPlayerNumber(c);
            GUIManagerScript.SetNumberInputFieldColor(clr);
            GUIManagerScript.ClearNumberInput();
        }
    }
コード例 #9
0
    void RpcSetColor(int c)
    {
        int oldColor = color;

        color = c;
        SetColor();

        string clr_name = ColorScript.GetColorName(c);

        if (isLocalPlayer)
        {
            Color clr = ColorScript.GetColor(c);
            GUIManagerScript.SetInputColor(clr, clr_name);
            clr = clr * 0.5f;
            GUIManagerScript.SetBGColor(clr);
        }

        if (nameText == ColorScript.GetColorName(oldColor) || nameText == "")
        {
            OnNameTextChanged(clr_name);
        }
    }
コード例 #10
0
    void Update()
    {
        GameManagerScript gameManager = FindObjectOfType <GameManagerScript>();

        Assert.IsNotNull <GameManagerScript>(gameManager);

        if (gameManager.IsInPostGame())
        {
            sliderText.text = "";

            infoText.enabled      = false;
            countdownText.enabled = false;

            string details = "";

            if (networkedPScript.GetFirstBonus())
            {
                details = "(First to guess: +100)\n";
            }

            int song  = networkedPScript.GetSongID();
            int match = networkedPScript.GetMatchSongID();

            int songTypeIndex = gameManager.GetSongSet();


            if (match != -1)
            {
                answerParent.SetActive(true);
                playerPickedBtn.GetComponent <Image>().color         = ColorScript.GetColor(networkedPScript.picked_color);
                playerPickedBtn.GetComponentInChildren <Text>().text = networkedPScript.picked_color.ToString();
                noGuessText.enabled = false;

                if (song == match)
                {
                    lookingForParent.SetActive(false);

                    answerText.text = "Correct!";
                    details        += "(Found Dance Partner: +250)\n(Time Bonus: +" + networkedPScript.GetTimeBonus() + ")\n";

                    listeningToText.text = "You were dancing to:\n" + AudioManagerScript.GetSongName(songTypeIndex, song);
                }
                else
                {
                    lookingForParent.SetActive(true);

                    lookingForBtn.GetComponent <Image>().color         = ColorScript.GetColor(networkedPScript.match_color);
                    lookingForBtn.GetComponentInChildren <Text>().text = networkedPScript.match_color.ToString();

                    answerText.text = "Wrong!";

                    listeningToText.text = "You heard: " + AudioManagerScript.GetSongName(songTypeIndex, song) + "\nThey heard: " + AudioManagerScript.GetSongName(songTypeIndex, match);
                }
            }
            else
            {
                lookingForParent.SetActive(false);
                answerParent.SetActive(false);
                noGuessText.enabled = true;

                listeningToText.text = "You were dancing to:\n" + AudioManagerScript.GetSongName(songTypeIndex, song);
            }

            finalScoreText.text = "Score: +" + networkedPScript.GetScoredThisRound().ToString();

            if (networkedPScript.GetWasGuessed())
            {
                details += "(Partner found you: +500)";
            }

            if (details != "")
            {
                details = "Score breakdown:\n" + details;
            }

            detailsText.text = details;

            continuingInText.text = "Automatically continuing in " + Mathf.CeilToInt(gameManager.endgameCountDown);
        }
        else
        {
            float countDown = gameManager.countDown;

            float captainsCountdown = networkedPScript.captainsCountdown;
            if (captainsCountdown > 0)
            {
                sliderText.text  = "";
                infoText.enabled = true;

                if (captainsCountdown < 1)
                {
                    infoText.text = "DANCE!";
                }
                else if (captainsCountdown >= (4f)) //Plus one second for the "Dance" end
                {
                    infoText.text = "Ready?";
                }
                else
                {
                    infoText.text = "" + Mathf.Floor(captainsCountdown);
                }
            }
            else if (countDown > 0)
            {
                bool chosen = (networkedPScript.GetMatchSongID() == -1);
                if (chosen)
                {
                    sliderText.text = "Chose your dance partner:";
                }
                else
                {
                    sliderText.text = "Press back to undo current choice";
                }
                infoText.enabled      = false;
                countdownText.enabled = true;
                countdownText.text    = "" + Mathf.Ceil(countDown);

                if (reminded == false)
                {
                    if (countDown < 30 && chosen)
                    {
                        Debug.Log("Reminder to pick!");
                        AudioManagerScript.instance.PlayFind();
                        reminded = true;
                    }
                }
            }
            else
            {
                sliderText.text  = "Other players:";
                infoText.enabled = false;
            }
        }
    }