コード例 #1
0
    // I don't know how, I don't know why, but this part has a particular code stink.

    // Runs a timer. If player hides during the timer, run other method. If
    // failed to hide within timer, run a method which makes the player
    public IEnumerator CheckIfHiddenInHidingFase()
    {
        // GameObject which is a collection of UI elements for the hiding timer. Is a child of a general collection of UI elements.
        GameObject HideTimer = CanvasPlayerUI.transform.Find("HideTimerHider").gameObject;

        // Is the script component of the UI that handles changing of HideTimer UI text.
        CountdownUIScript HideTimerCountdown = HideTimer.GetComponent <CountdownUIScript>();

        for (int i = secondsToHide; i > 0; i--)
        {
            // Changes text in UI.
            HideTimerCountdown.ChangeCountdownNumber("You have ", i, " seconds to hide!");

            yield return(new WaitForSecondsRealtime(1.0f));

            // Ends timer is player hides so player doesnt have to wait for the timer to run out
            if (hiderIsHidden)
            {
                i = 0;
            }
        }
        if (hiderIsHidden)
        {
            EndHiderHidingFaseHidden();
        }
        else
        {
            EndHiderHidingFaseTimerRanOut();
        }
    }
コード例 #2
0
    public IEnumerator StartSeekerWaitingFase()
    {
        // GameObject which is a collection of UI elements for the hiding timer. Is a child of a general collection of UI elements.
        GameObject HideTimer = CanvasPlayerUI.transform.Find("HideTimerSeeker").gameObject;

        HideTimer.SetActive(true);
        // Is the script component of the UI that handles changing of HideTimer UI text.
        CountdownUIScript HideTimerCountdown = HideTimer.GetComponent <CountdownUIScript>();

        for (int i = secondsToHide; i > 0; i--)
        {
            // Changes text in UI.
            HideTimerCountdown.ChangeCountdownNumber("Giving hider ", i, " seconds to hide...");

            yield return(new WaitForSecondsRealtime(1.0f));

            Debug.Log(hiderIsHidden);
            if (hiderIsHidden)
            {
                i = 0;
            }
            // Ends timer is player hides so player doesnt have to wait for the timer to run out
        }
        HideTimer.SetActive(false);
        StopSeekerWaitingFase();
    }
コード例 #3
0
    public IEnumerator StartSeekerSeekingFase()
    {
        // enable movement
        GameObject SeekerPlayerGameObject = GameObject.Find("Seeker");

        SeekerPlayerGameObject.GetComponent <PlayerMovementScript>().CanMove = true;

        SwitchResult HiderIsCaughtSwitch = new SwitchResult();

        HiderIsCaughtSwitch.Data = "Off";
        // GameObject which is a collection of UI elements for the hiding timer. Is a child of a general collection of UI elements.
        GameObject RoundTimer = CanvasPlayerUI.transform.Find("RoundTimer").gameObject;

        RoundTimer.SetActive(true);

        // Is the script component of the UI that handles changing of HideTimer UI text.
        CountdownUIScript RoundTimerCountdown = RoundTimer.GetComponent <CountdownUIScript>();

        for (int i = secondsToFind; i > 0; i--)
        {
            // Changes text in UI.
            RoundTimerCountdown.ChangeCountdownNumber("You have ", i, "seconds to catch the hider!");
            yield return(new WaitForSecondsRealtime(1.0f));

            StartCoroutine(MainConnectionScript.CheckDomoticzSwitch(hiderIsCaughtSwitchidx, HiderIsCaughtSwitch));
            if (HiderIsCaughtSwitch.Data == "On")
            {
                hiderIsFound = true;
            }

            // Ends timer is player hides so player doesnt have to wait for the timer to run out
            if (hiderIsFound)
            {
                i = 0;
            }
        }
        if (hiderIsFound)
        {
            StartCoroutine(MainConnectionScript.ChangeDomoticzSwitchStatus(hiderIsCaughtSwitchidx, true));
            SeekerWon("HiderWasCaught");
        }
        else
        {
            SeekerLost("TimeRanOut");
        }
        StopSeekerSeekingFase();
    }