IEnumerator WaitForPlayerInputToTransition() { while (true) { if (Input.GetKeyDown(KeyCode.Space)) { Vector3 initial_position = transform.position; Vector3 final_position = new Vector3(20, 0, -10); /* Transition to new "room" */ yield return(StartCoroutine( CoroutineUtilities.MoveObjectOverTime(transform, initial_position, final_position, 2.5f) )); /* Hang around a little bit */ yield return(new WaitForSeconds(2)); /* Return to the previous room */ yield return(StartCoroutine( CoroutineUtilities.MoveObjectOverTime(transform, final_position, initial_position, 2.5f) )); } /* We must yield here to let time pass, or we will hardlock the game (due to infinite while loop) */ yield return(null); } }
private void AddMessageToChat(ChatMessagePacket msgPacket) { //Creates a new message and adds it to the list GameObject newMessageObject = Instantiate(m_messagePrefab, m_ViewContent); ChatMessage newCM = newMessageObject.GetComponent <ChatMessage>(); if (newCM == null) { Debug.LogError("Chat message prefab does not have a ChatMessage component, cannot add the recived message: " + msgPacket.Message); Destroy(newMessageObject); return; } //Init the message newCM.InitMessage(msgPacket.SenderID, msgPacket.Message); m_messagesList.AddLast(newCM); //If the chat history is full delete the last one if (m_messagesList.Count > m_maxChatHistoryLenght) { //Get the first message in the list, then remove it form the list and remvoe it from the ui LinkedListNode <ChatMessage> firstMessageNode = m_messagesList.First; ChatMessage cm = firstMessageNode.Value; m_messagesList.Remove(firstMessageNode); Destroy(cm.gameObject); } //Autoscroll Canvas.ForceUpdateCanvases(); StartCoroutine(CoroutineUtilities.DoOnNextFrame(() => { GetComponent <ScrollRect>().verticalScrollbar.value = 0.0f; })); }
public static void FreezeGame(GlobalConstants.GameFreezeEvent freezeEvent) { int freezeFrameCount = instance.gameFreezeTimers[freezeEvent]; IEnumerator freezeCoroutine = CoroutineUtilities.PauseForFrames(freezeFrameCount); instance.StartCoroutine(freezeCoroutine); }
/// <summary> /// Use an IEnumerator to first play the animation and then change the video settings. /// </summary> /// <returns></returns> internal IEnumerator ApplyVideo() { VidPanelAnimator.Play("Video Panel Out"); yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime((float)VidPanelAnimator.GetCurrentAnimatorClipInfo(0).Length))); MainPanel.SetActive(true); VidPanel.SetActive(false); AudioPanel.SetActive(false); RenderDistIni = MainCam.farClipPlane; ShadowDistIni = QualitySettings.shadowDistance; Debug.Log("Shadow dist ini" + ShadowDistIni); FovIni = MainCam.fieldOfView; AoBool = AoToggle.isOn; DofBool = DofToggle.isOn; _lastAoBool = AoBool; _lastDofBool = DofBool; _beforeRes = CurrentRes; LastTexLimit = QualitySettings.masterTextureLimit; LastShadowCascade = QualitySettings.shadowCascades; VsyncIni = QualitySettings.vSyncCount; _isFullscreen = Screen.fullScreen; try { DensityIni = CurrentTerrain.detailObjectDensity; TreeMeshAmtIni = CurrentTerrain.treeMaximumFullLODCount; } catch { Debug.Log("Please assign a terrain"); } _saveSettings.SaveGameSettings(); }
/// <summary> /// Use an IEnumerator to first play the animation and then change the video settings. /// </summary> /// <returns></returns> protected IEnumerator applyVideo() { vidPanelAnimator.Play("Video Panel Out"); yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime((float)vidPanelAnimator.GetCurrentAnimatorClipInfo(0).Length))); mainPanel.SetActive(true); vidPanel.SetActive(false); audioPanel.SetActive(false); renderDistINI = mainCam.farClipPlane; shadowDistINI = QualitySettings.shadowDistance; fovINI = mainCam.fieldOfView; aoToggle.isOn = lastAOBool; dofToggle.isOn = lastDOFBool; beforeRes = currentRes; lastTexLimit = QualitySettings.masterTextureLimit; lastShadowCascade = QualitySettings.shadowCascades; //isFullscreen = Screen.fullScreen; try { if (useSimpleTerrain == true) { treeMeshAmtINI = simpleTerrain.treeMaximumFullLODCount; } else { treeMeshAmtINI = simpleTerrain.treeMaximumFullLODCount; } } catch { Debug.Log("You probably did not assign a terrain. Here's the error anyway"); } }
/// <summary> /// Use an IEnumerator to first play the animation and then change the audio settings /// </summary> /// <returns></returns> internal IEnumerator cancelAudioMain() { audioPanelAnimator.Play("Audio Panel Out"); // Debug.Log(audioPanelAnimator.GetCurrentAnimatorClipInfo(0).Length); yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime((float)audioPanelAnimator.GetCurrentAnimatorClipInfo(0).Length))); mainPanel.SetActive(true); vidPanel.SetActive(false); audioPanel.SetActive(false); AudioListener.volume = beforeMaster; //Debug.Log(_beforeMaster + AudioListener.volume); try { for (_audioEffectAmt = 0; _audioEffectAmt < effects.Length; _audioEffectAmt++) { //get the values for all effects before the change effects[_audioEffectAmt].volume = _beforeEffectVol[_audioEffectAmt]; } for (int _musicAmt = 0; _musicAmt < music.Length; _musicAmt++) { music[_musicAmt].volume = _beforeMusic; } } catch { Debug.Log("please assign the audio sources in the manager"); } }
IEnumerator DoBoundRoutine(uint id, IEnumerator routine) { yield return(CoroutineUtilities.RunWhile(routine, () => idList.Contains(id))); idList.Remove(id); BoundRoutines.Remove(id); }
/// <summary> /// Use an IEnumerator to first play the animation and then change the video settings. /// </summary> /// <returns></returns> internal IEnumerator applyVideo() { vidPanelAnimator.Play("Video Panel Out"); yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime((float)vidPanelAnimator.GetCurrentAnimatorClipInfo(0).Length))); mainPanel.SetActive(true); vidPanel.SetActive(false); audioPanel.SetActive(false); renderDistINI = mainCam.farClipPlane; shadowDistINI = QualitySettings.shadowDistance; Debug.Log("Shadow dist ini" + shadowDistINI); fovINI = mainCam.fieldOfView; beforeRes = currentRes; lastTexLimit = QualitySettings.masterTextureLimit; lastShadowCascade = QualitySettings.shadowCascades; vsyncINI = QualitySettings.vSyncCount; isFullscreen = Screen.fullScreen; try { if (useSimpleTerrain == true) { densityINI = simpleTerrain.detailObjectDensity; treeMeshAmtINI = simpleTerrain.treeMaximumFullLODCount; } else { densityINI = terrain.detailObjectDensity; treeMeshAmtINI = simpleTerrain.treeMaximumFullLODCount; } } catch { Debug.Log("Please assign a terrain"); } saveSettings.SaveGameSettings(); }
//Show the THIRD TUTORIAL IEnumerator ShowExplosionTutorial(GameObject[] tutorial, GameObject effect) { Man.GetComponent <CharacterBehaviour>().SetInput(false); Woman.GetComponent <CharacterBehaviour>().SetInput(false); effect.SetActive(true); yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(1f))); for (int i = 0; i < RedLight.Length; i++) { RedLight[i].color = Color.red; } yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(2.3f))); effect.SetActive(false); if (_numTutorial != 0) //in every explosion with tutorial { BlackBackground.SetActive(true); tutorial[0].SetActive(true); tutorial[1].SetActive(false); //Change input for tutorial screenInput[0].SetActive(false); screenInput[1].SetActive(false); screenInput[2].SetActive(false); screenInput[3].SetActive(false); screenInput[4].SetActive(true); //set Tutorial screenInput[5].SetActive(true); //set Tutorial } else if (_numExplosion == 0) //at the start of the explosion without tutorial { screenInput[0].SetActive(false); screenInput[1].SetActive(false); screenInput[2].SetActive(true); //set Explosion control screenInput[3].SetActive(true); //set Explosion control screenInput[4].SetActive(false); screenInput[5].SetActive(false); Man.GetComponent <CharacterBehaviour>().SetInput(true); Woman.GetComponent <CharacterBehaviour>().SetInput(true); _showed = true; } else if (_numExplosion == 1) //at the end of the explosion without tutorial { RedLight[_lenghtRedLight].color = Color.grey; screenInput[0].SetActive(true); screenInput[1].SetActive(true); screenInput[2].SetActive(false); screenInput[3].SetActive(false); screenInput[4].SetActive(false); screenInput[5].SetActive(false); Man.GetComponent <CharacterBehaviour>().SetInput(true); Woman.GetComponent <CharacterBehaviour>().SetInput(true); _showed = true; } StopCoroutine("ShowExplosionTutorial"); _nextImage = true; }
IEnumerator DelayedItemIntro(float delay) { foreach (TextMenuItem item in itemList) { item.SetAccessibility(item.data.accessible); yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(delay))); } }
/// <summary> /// Displays an error message for the player about the username alreaby been taken /// </summary> /// <param name="name">The username that the player tried changing to</param> public void DisplayUsernameError(string name) { //Activate the error msg and make it wanish after a certain amount of time m_nameInputfield.gameObject.SetActive(false); m_nameErrorMsgText.gameObject.SetActive(true); m_nameErrorMsgText.text = string.Format("Name {0} is already taken...", name); CoroutineUtilities.DelaySeconds(() => { m_nameErrorMsgText.gameObject.SetActive(false); }, 2.5f); }
public IEnumerator RevertAudioSettings() { audioMasterVolumeSlider.value = SaveSettings.MasterVolumeIni; effectsVolumeSlider.value = SaveSettings.EffectVolumeIni; backgroundVolumeSlider.value = SaveSettings.BackgroundVolumeIni; yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(0.5f))); _panel.SetActive(false); }
//public void ResumeBtnClicked() //{ // if (Player._instance.IsAlive()) // { // Time.timeScale = 1; // //pauseAnimator.SetBool("fadeout", false); // //StartCoroutine(cPauseResumeSwitch(resumeBtn, pauseBtn)); // Game.SetGameState(Game.GameState.playing); // } //} private IEnumerator cPauseResumeSwitch(Button deactivateBtn, Button activateBtn) { //since we have paused the timescale "new WaitForSeconds" wont work, this is a nice workaround yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(buttonSwitchDelay))); deactivateBtn.gameObject.SetActive(false); activateBtn.gameObject.SetActive(true); yield break; }
/// <summary> /// Use an IEnumerator to first play the animation and then hide other panels settings /// </summary> /// <returns></returns> internal IEnumerator CreditsReturnMain() { CreditsPanelAnimator.Play("Credits Panel Out 1"); yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime((float)CreditsPanelAnimator.GetCurrentAnimatorClipInfo(0).Length))); MainPanel.SetActive(true); VidPanel.SetActive(false); AudioPanel.SetActive(false); CreditsPanel.SetActive(false); }
public IEnumerator SaveAudioSettings() { SaveSettings.MasterVolumeIni = audioMasterVolumeSlider.value; SaveSettings.EffectVolumeIni = effectsVolumeSlider.value; SaveSettings.BackgroundVolumeIni = backgroundVolumeSlider.value; yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(0.5f))); GameManager.Instance.SaveGameSettings(); _panel.SetActive(false); }
IEnumerator floatingDown() { _index += Time.unscaledDeltaTime; float y = Mathf.Abs(DownSpeed * Mathf.Sin(Amplitude * _index)); transform.localPosition -= new Vector3(0, y, 0); yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(0.5f))); Levitation = true; }
IEnumerator DeathRoutine() { //Lightly darken the screen over the course of two seconds LeanTween.value(gameObject, 0f, 0.5f, 2f).setOnUpdate((float value) => { gameOverTransparentCover.color = new Color(0f, 0f, 0f, value); }).setEase(LeanTweenType.easeOutCubic).setUseEstimatedTime(true); //Slow the timeScale down to 0 over the course of two seconds LeanTween.value(gameObject, 1f, 0f, 2f).setOnUpdate((float value) => { timeScale = value; }).setEase(LeanTweenType.easeOutCubic).setUseEstimatedTime(true); //Wait two seconds yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(2))); //Play click sound //generalAudioManager.PlayOneShot(retrySound); //Intensely brighten screen over the course of 0.1s LeanTween.value(gameObject, new Color(0f, 0f, 0f, 0.5f), new Color(1f, 1f, 1f, 0.9f), 0.1f).setOnUpdate((Color value) => { gameOverTransparentCover.color = value; }).setUseEstimatedTime(true); //Wait 0.1s yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(0.1f))); //Create text object GameObject textObject = new GameObject("Retry Text"); textObject.transform.SetParent(gameOverCanvas.transform); textObject.transform.position = gameOverCanvas.transform.position; textObject.tag = "Junk"; //Add text to that text object Text retryText = textObject.AddComponent <Text>(); retryText.font = Resources.Load <Font>("Fonts/Eras Demi ITC"); retryText.fontSize = 80; retryText.alignment = TextAnchor.MiddleCenter; retryText.horizontalOverflow = HorizontalWrapMode.Overflow; retryText.verticalOverflow = VerticalWrapMode.Overflow; retryText.GetComponent <Text>().text = "Retry?"; //Lessen the brightness over the course of 0.1s LeanTween.value(gameObject, new Color(1f, 1f, 1f, 0.9f), new Color(1f, 1f, 1f, 0.3f), 0.1f).setOnUpdate((Color value) => { gameOverTransparentCover.color = value; }).setUseEstimatedTime(true); //Wait 0.1s yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(0.1f))); }
private void OnClientStopped() { //IF there is a disconected task execute it as the network manager just stopped StartCoroutine(CoroutineUtilities.DoOnNextFrame(() => { if (m_DisconectedTask != null) { m_DisconectedTask.Invoke(); m_DisconectedTask = null; } })); }
private IEnumerator WaitForDeath() { StopAllAudio(); m_BGMSource.PlayOneShot(m_DeathClip); // stop time Time.timeScale = 0; yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(1))); SceneManager.LoadScene(SceneManager.GetSceneAt(0).name); Time.timeScale = 1; }
IEnumerator CountDown() { countdown.text = "3"; yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(1))); countdown.text = "2"; yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(1))); countdown.text = "1"; yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(1))); //time up, now resume the app }
/// <summary> /// Use an IEnumerator to first play the animation and then change the audio settings /// </summary> /// <returns></returns> protected IEnumerator applyAudioMain() { audioPanelAnimator.Play("Audio Panel Out"); yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime((float)audioPanelAnimator.GetCurrentAnimatorClipInfo(0).Length))); mainPanel.SetActive(true); vidPanel.SetActive(false); audioPanel.SetActive(false); _beforeMaster = AudioListener.volume; lastMusicMult = audioMusicSlider.value; lastAudioMult = audioEffectsSlider.value; }
IEnumerator Respawn() { yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(1.5f))); if (!GameManager.instance.IsGameOver()) { GameObject newPlayer = Instantiate <GameObject> (playerPrefab); newPlayer.transform.position = this.transform.position; GameManager.instance.EnableAllEnemies(true); } }
private void OnEnable() { //By degfualt make the next and previus not interactuable m_prevButton.interactable = false; m_nextButton.interactable = false; //Destroy all previous server entries game objects foreach (Transform t in m_ServerListLivingObject) { Destroy(t.gameObject); } //Start to search for a server after a delay StartCoroutine(CoroutineUtilities.DelaySeconds(() => { RefreshMachesList(); }, .2f)); }
// TODO : holding xbox button or pressing esc should bring up settings public IEnumerator RevertVideoSettings() { QualitySettings.SetQualityLevel(SaveSettings.CurrentQualityLevelIni); msaaDropdown.value = SaveSettings.MsaaIni; anisotropicDropdown.value = SaveSettings.AnisotropicFilteringLevelIni; renderDistSlider.value = SaveSettings.RenderDistIni; masterTexSlider.value = SaveSettings.TextureLimitIni; shadowDistSlider.value = SaveSettings.ShadowDistIni; shadowCascadesSlider.value = SaveSettings.ShadowCascadeIni; yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(0.5f))); _panel.SetActive(false); }
IEnumerator soundController() { while (true) { audioSource_Bang1.PlayOneShot(explosions[1]); yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(0.1f))); audioSource_Bang0.PlayOneShot(explosions[0]); yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(0.1f))); audioSource_Bang1.PlayOneShot(explosions[1]); } }
/// <summary> /// Use an IEnumerator to first play the animation and then change the audio settings /// </summary> /// <returns></returns> internal IEnumerator ApplyAudioMain() { AudioPanelAnimator.Play("Audio Panel Out"); yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime((float)AudioPanelAnimator.GetCurrentAnimatorClipInfo(0).Length))); MainPanel.SetActive(true); VidPanel.SetActive(false); AudioPanel.SetActive(false); BeforeMaster = AudioListener.volume; LastMusicMult = AudioMusicSlider.value; LastAudioMult = AudioEffectsSlider.value; _saveSettings.SaveGameSettings(); }
public IEnumerator SaveVideoSettings() { SaveSettings.CurrentQualityLevelIni = QualitySettings.GetQualityLevel(); SaveSettings.MsaaIni = msaaDropdown.value; SaveSettings.AnisotropicFilteringLevelIni = anisotropicDropdown.value; SaveSettings.RenderDistIni = renderDistSlider.value; SaveSettings.TextureLimitIni = (int)masterTexSlider.value; SaveSettings.ShadowDistIni = shadowDistSlider.value; SaveSettings.ShadowCascadeIni = (int)shadowCascadesSlider.value; yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(0.5f))); GameManager.Instance.SaveGameSettings(); _panel.SetActive(false); }
IEnumerator Start() { Vector3 newPos; // = transform.localPosition; int flip = 10; while (true) { flip = -flip; newPos = ((RectTransform)transform).localPosition; newPos.y -= flip; ((RectTransform)transform).localPosition = newPos; yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime(0.25f))); } }
public IEnumerator RunMoveUntil(IBossMove move, Func <bool> predicate) { CurrentMove = move; yield return(CoroutineUtilities.RunWhile(move.DoMove(), () => !predicate())); PreviousMove = move; if (CurrentMove == move) { CurrentMove = null; } else { move.OnCancel(); } }
/// <summary> /// Use an IEnumerator to first play the animation and then changethe video settings /// </summary> /// <returns></returns> internal IEnumerator cancelVideoMain() { vidPanelAnimator.Play("Video Panel Out"); yield return(StartCoroutine(CoroutineUtilities.WaitForRealTime((float)vidPanelAnimator.GetCurrentAnimatorClipInfo(0).Length))); try { mainCam.farClipPlane = renderDistINI; Terrain.activeTerrain.detailObjectDensity = densityINI; mainCam.fieldOfView = fovINI; mainPanel.SetActive(true); vidPanel.SetActive(false); audioPanel.SetActive(false); aoBool = lastAOBool; dofBool = lastDOFBool; Screen.SetResolution(beforeRes.width, beforeRes.height, Screen.fullScreen); QualitySettings.shadowDistance = shadowDistINI; QualitySettings.antiAliasing = (int)aaQualINI; QualitySettings.antiAliasing = msaaINI; QualitySettings.vSyncCount = vsyncINI; QualitySettings.masterTextureLimit = lastTexLimit; QualitySettings.shadowCascades = lastShadowCascade; Screen.fullScreen = isFullscreen; } catch { Debug.Log("A problem occured (chances are the terrain was not assigned )"); //mainCam.farClipPlane = renderDistINI; mainCam.fieldOfView = fovINI; mainPanel.SetActive(true); vidPanel.SetActive(false); audioPanel.SetActive(false); aoBool = lastAOBool; dofBool = lastDOFBool; QualitySettings.shadowDistance = shadowDistINI; Screen.SetResolution(beforeRes.width, beforeRes.height, Screen.fullScreen); QualitySettings.antiAliasing = (int)aaQualINI; QualitySettings.antiAliasing = msaaINI; QualitySettings.vSyncCount = vsyncINI; QualitySettings.masterTextureLimit = lastTexLimit; QualitySettings.shadowCascades = lastShadowCascade; //Screen.fullScreen = isFullscreen; } }