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(); }
public IEnumerator DisableTimer(float _time) { fade.FadeOut(_time, false); yield return(new WaitForSeconds(_time)); StopAllCoroutines(); loadText.text = string.Empty; // fade.FadeOut(0.4f, false); gameObject.SetActive(fade); }
public void OnLevelResetStart() { _mainMenuElements.SetActive(false); _startInstructions.SetActive(false); _soundMeter.SetActive(false); _failureElements.SetActive(false); _victoryElements.SetActive(false); // Fade to Black _fade.FadeOut(); }
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(); } }
//OnTriggerEnter2D is sent when another object enters a trigger collider attached to this object (2D physics only). private void OnTriggerEnter2D(Collider2D other) { //Check if the tag of the trigger collided with is Exit. if (other.tag == "Exit") { TrackerManager.ClearedLevel(GameManager.instance.level, "Food ", food, "Time", GameManager.instance.time); ImageFade.FadeOut(restartLevelDelay); // Invoke the Restart function to start the next level with a delay of restartLevelDelay (default 1 second). Invoke("Restart", restartLevelDelay); //Disable the player object since level is over. enabled = false; } //Check if the tag of the trigger collided with is Food. else if (other.tag == "Food") { Analytics.CustomEvent("Food Picked Up"); //Add pointsPerFood to the players current food total. food += pointsPerFood; ValueSetter.maximum += pointsPerFood; //Update foodText to represent current total and notify player that they gained points foodText.text = " Food: " + food; //Call the RandomizeSfx function of SoundManager and pass in two eating sounds to choose between to play the eating sound effect. SoundManager.instance.RandomizeSfx(eatSound1, eatSound2); //Disable the food object the player collided with. other.gameObject.SetActive(false); } //Check if the tag of the trigger collided with is Soda. else if (other.tag == "Soda") { Analytics.CustomEvent("Food Picked Up"); Analytics.CustomEvent("Soda Picked Up"); //Add pointsPerSoda to players food points total food += pointsPerSoda; ValueSetter.maximum += pointsPerSoda; //Update foodText to represent current total and notify player that they gained points foodText.text = " Food: " + food; //Call the RandomizeSfx function of SoundManager and pass in two drinking sounds to choose between to play the drinking sound effect. SoundManager.instance.RandomizeSfx(drinkSound1, drinkSound2); //Disable the soda object the player collided with. other.gameObject.SetActive(false); } // Check if the player is colliding with an ore else if (other.tag == "Ores") { switch (other.name) { // add a diamond ore, and disable the gameobject case "Diamond(Clone)": TrackerManager.ItemPickUp(other.name); GameManager.instance.diamondPoints++; diamondCount++; inventoryText[0].text = "x" + "\n" + "\n" + diamondCount; other.gameObject.SetActive(false); break; // add a gold ore, and disable the gameobject case "Gold(Clone)": TrackerManager.ItemPickUp(other.name); GameManager.instance.goldPoints++; goldCount++; inventoryText[2].text = "x" + "\n" + "\n" + goldCount; other.gameObject.SetActive(false); break; // add a iron ore, and disable the gameobject case "Iron(Clone)": TrackerManager.ItemPickUp(other.name); GameManager.instance.ironPoints++; ironCount++; inventoryText[1].text = "x" + "\n" + "\n" + ironCount; other.gameObject.SetActive(false); break; default: break; } } }
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(); }