Example #1
0
        IEnumerator <WaitForSeconds> Age2()
        {
            Debug.Log("age 2!");
            ImageFade.FadeOut(3f);
            yield return(new WaitForSeconds(3.2f));

            //Add new
            foreach (Renderer render in Age2Remove.GetComponentsInChildren <Renderer>())
            {
                render.enabled = false;
            }

            foreach (Renderer render in Age2Add.GetComponentsInChildren <Renderer>())
            {
                render.enabled = true;
            }

            //Spawn new
            Renderer rend = playerMesh.GetComponent <Renderer>();

            rend.materials = new Material[]
            {
                null, null, null, MaterialAge2
            };
            player.transform.localScale = ScaleAge2;

            //Rain time!
            rainChild = Instantiate(rain);

            ImageFade.FadeIn(3f);
            yield return(new WaitForSeconds(2.0f));

            DoEvent();
        }
 private void OnEnable()
 {
     StartCoroutine(LoadingIconAnimation());
     StartCoroutine(PingLoading());
     fade.FadeIn(0.2f, false);
     partB.gameObject.SetActive(true);
 }
Example #3
0
    private IEnumerator Start()
    {
        fade.SetAlpha(0);
        yield return(new WaitForSeconds(0.2f));

        fade.FadeIn(0.9f, false);
    }
    public void OnLevelResetFinished()
    {
        // unfade from black
        _fade.FadeIn();

        _mainMenuElements.SetActive(true);
        _startInstructions.SetActive(false);
        _soundMeter.SetActive(false);
        _failureElements.SetActive(false);
        _victoryElements.SetActive(false);
    }
Example #5
0
 private void BackgroundFade(Sprite newSprite)
 {
     // checking which image to set new sprite on cross fade
     if (theBGImage2imageFade.GetTargetAlpha() == 0)
     {
         theBGImage2image.sprite = newSprite;
         theBGImage2imageFade.FadeIn();
     }
     else
     {
         theBGImage1image.sprite = newSprite;
         theBGImage2imageFade.FadeOut();
     }
 }
Example #6
0
    IEnumerator StateTransition(State nextState)
    {
        // Toggling activated objects from states
        if (currentState != null)
        {
            string[] theTags = currentState.GetActivatedTags();
            foreach (string thisTag in theTags)
            {
                ToggleObjByName(thisTag);
            }
        }
        string[] nextTags = nextState.GetActivatedTags();
        foreach (string nextTag in nextTags)
        {
            ToggleObjByName(nextTag);
        }

        // Updating state
        currentState = nextState;

        // Fading old state out
        textBGFade.FadeOut();
        textFade.FadeOut();
        buttonHolderFade.FadeOut();

        // Transition Audio
        bool[] clipBools    = nextState.GetClipBools();
        bool   rainOn       = clipBools[0];
        bool   rainMuffled  = clipBools[1];
        bool   musicOn      = clipBools[2];
        bool   musicMuffled = clipBools[3];
        bool   waterDripOn  = clipBools[4];
        bool   heartBeatOn  = clipBools[5];

        rainFilter.enabled   = rainMuffled;
        rainSource.mute      = !rainOn;
        rainFilter.enabled   = rainMuffled;
        musicSource.mute     = !musicOn;
        musicFilter.enabled  = musicMuffled;
        waterDripSource.mute = !waterDripOn;
        heartBeatSource.mute = !heartBeatOn;

        // Updating background image
        Sprite nextSprite = nextState.GetBackgroundImage();

        if (nextSprite != null)
        {
            BackgroundFade(nextSprite);
            yield return(new WaitForSeconds(0.1f));

            while (theBGImage2imageFade.CheckFading())
            {
                yield return(new WaitForSeconds(0.1f));
            }
        }
        yield return(new WaitForSeconds(0.1f));

        while (textBGFade.CheckFading() || textFade.CheckFading() || buttonHolderFade.CheckFading())
        {
            yield return(new WaitForSeconds(0.1f));
        }
        textComponent.text = nextState.GetStateStory();

        // Adding new buttons
        var nextStates      = nextState.GetNextStates();
        var nextStatesNames = nextState.GetNextStatesNames();
        var index           = 0;

        foreach (State child in nextStates)
        {
            GameObject newButton = Instantiate(theButtonPrefab);
            newButton.transform.SetParent(buttonHolder.transform, false);
            string nextStateName = nextStatesNames[index];
            newButton.GetComponentInChildren <TextMeshProUGUI>().text = nextStateName;
            newButton.GetComponentInChildren <Button>().onClick.AddListener(() => { theGame.NextState(child); });
            index++;
        }

        // Fading in buttons
        float delayTime = 1f;

        if (GetCurrentStateName() == startingState.name)
        {
            delayTime = startDelay;
        }
        StartCoroutine(ButtonsFadeIn());

        textBGFade.FadeIn();
        textFade.FadeIn();
        buttonHolderFade.FadeIn();
    }