private IEnumerator Play(WaitWhile sourceClipReady) { yield return(sourceClipReady); source.prepareCompleted += PlayOnReady; source.Prepare(); }
void Start() { rotationIntervals = new WaitForSeconds[numberOfRotationIntervals]; waitWhileUntriggered = new WaitWhile(() => canBeRotated); waitWhileRotating = new WaitWhile(() => isRotating); wallRenderers = new MeshRenderer[6]; wallCameras = new Camera[6]; wallTriggers = new RotationTrigger[6]; formerFloor = 0; floor = 0; for (int i = 0; i < numberOfRotationIntervals; i++) { rotationIntervals[i] = new WaitForSeconds(Random.Range(minIntervalSeconds, maxIntervalSeconds)); } for (int o = 0; o < walls.Length; o++) { wallRenderers [o] = walls [o].GetComponent <MeshRenderer> (); wallCameras [o] = walls [o].GetComponentInChildren <Camera> (); wallTriggers [o] = walls [o].GetComponentInChildren <RotationTrigger> (); } //Disable the cameras on all walls except for the floor - They are not disabled by default so they can render the edge markings onto the render textures. StartCoroutine(DisableWallCameras()); }
private IEnumerator AnimCoroutine() { if (Cover) { WaitWhile ww = new WaitWhile(() => Cover.gameObject.activeSelf); yield return(ww); } while (true) { currentTime += Time.deltaTime; if (currentTime >= AnimSpeed) { curId++; if (mSprits.Length <= curId) { curId = 0; } mImg.sprite = mSprits[curId]; currentTime = 0f; } yield return(null); } }
public IEnumerator Scroll() { IsScrolling = true; float target = GetTargetIndex(); float now = rect.horizontalNormalizedPosition; if (Mathf.Abs(target - now) < float.Epsilon) { yield break; } float t = 0f; var col = new WaitWhile(() => { t += Time.deltaTime; rect.horizontalNormalizedPosition = Mathf.Lerp(now, target, t / dulation); return(t / dulation < 1f); }); yield return(col); rect.horizontalNormalizedPosition = target; IsScrolling = false; }
private void Start() { Player = GameObject.FindGameObjectWithTag("Player"); playerTransform = Player.transform; if (!playerTransform) { Debug.LogWarning("Player not found by Game Manager."); } playerRigidbody = Player.GetComponent <Rigidbody2D>(); if (!playerRigidbody) { Debug.LogWarning("Rigidbody2D not found on player."); } playerRewindTime = Player.GetComponent <RewindTime>(); if (!playerRigidbody) { Debug.LogWarning("RewindTime not found on player."); } playerAnimator = Player.GetComponent <Animator>(); if (!playerRigidbody) { Debug.LogWarning("Animator not found on player."); } if (!swordEffect) { Debug.LogWarning("Sword Effect not attached to Game Manager!"); } swordEffectAnimator = swordEffect.GetComponent <Animator>(); waitUntilPlayerPositionTooLow = new WaitUntil(PlayerPositionTooLow); waitForFlashTime = new WaitForSeconds(flashTime); waitForSwordDuration1SecondLess = new WaitForSeconds(swordDuration - 1f); waitWhilePlayerAtMaxHealth = new WaitWhile(PlayerAtMaxHealth); Setup(); }
void Awake() { _gameMgr = this; Screen.SetResolution(1280, 720, false); _resourceMgr = GetComponent <SC_ResourceMgr>(); _stringMgr = GetComponent <SC_StringMgr>(); buttons = FindObjectsOfType <Button>(); eventTriggers = new EventTrigger[buttons.Length]; for (int n = 0; n < buttons.Length; n++) { eventTriggers[n] = buttons[n].gameObject.GetComponent <EventTrigger>(); } for (int n = 0; n < sysButtons.Length; n++) { sysButtons[n].gameObject.SetActive(true); } baseText = null; baseSprite = nullSprite; isAreaClear = new bool[4]; //가독성을 위해 [0]부터[3]까지 할당 waitFadeOut = new WaitWhile(() => isFadeOut); //IEnumerator용 isFadeOut이 false 될 때 까지 대기.(페이드아웃 중 True) waitFadeIn = new WaitWhile(() => isFadeIn); //IEnumerator용 isFadeIn이 false 될 때 까지 대기.(페이드인 중 True) waitEvent = new WaitWhile(() => isEventPlaying); //IEnumerator용 isEventPlaying가 false 될 때 까지 대기. waitText = new WaitWhile(() => isPlayingText); //IEnumerator용 isPlayingText가 false 될 때 까지 대기. waitClick = new WaitWhile(() => trigger_Click); //IEnumerator용 trigger_Click가 false 될 때 까지 대기. FadeIn(); }
void Awake() { Refresh(); if (Wait == null && _eventData != null) { Wait = new WaitWhile(() => PanelVector2 == _eventData.position); } }
public WaitForPredicateAction(MonoBehaviour mono, Func <bool> predicate, Action action) { this.action = action; waitWhile = new WaitWhile(predicate); mono.StartCoroutine(Enumerator()); }
public static IEnumerator WaitWhile(Func <bool> condition, Action action) { var wait = new WaitWhile(condition); yield return(wait); action(); }
public static WaitWhile Until(WaitWhile handle, System.Func <bool> predicate) { if (handle == null) { handle = new WaitWhile(predicate); } return(handle); }
/// <summary> /// Download a mod /// TODO refactor and make status optional somehow so downloads can be done without form /// </summary> /// <param name="modDownloadProgress"></param> /// <param name="status"></param> /// <param name="callback"></param> public void DownloadMod( DownloadStatus status, Action <object, DownloadProgressChangedEventArgs> callback) { //This is to get the last thrown exception from within the loop //(right now just to catch timeouts) Exception exception = null; foreach (ModUrl url in Urls) { var downloaded = false; var downloading = false; try { var client = TryDownload(url, status); client.DownloadProgressChanged += (s, e) => { downloading = true; if (e.ProgressPercentage >= 100) { downloaded = true; } }; } catch (Exception) { continue; } var wait = new WaitWhile().OrError(new TimeSpan(0, 0, 15)); try { //Wait until we have started downloading or if //we go over the timeout then just move to the next url while (wait.Variable(downloading).IsFalse) { } } catch (Exceptions.TimeoutException ex) { exception = ex; continue; } while (!downloaded) { } if (ExtractMod(status)) { return; } } ThrowModDownloadException(exception); }
IEnumerator TurnManage() { float time = turnTime; roundNum = 0; quizQue = new Queue <string>(); WaitForSeconds delay = new WaitForSeconds(0.5f); WaitForSecondsRealtime wait = new WaitForSecondsRealtime(1); WaitWhile waitWhile = new WaitWhile(() => dialog != null); yield return(StartCoroutine(DatabaseConnecter.GetInstance().GetQuizWord(quizQue))); do { foreach (var player in PhotonNetwork.PlayerList) { quizWord = ""; currentPlayer = player.NickName; QuizWordChange(); yield return(delay); yield return(waitWhile); SendRPC("TurnChange", currentPlayer); yield return(delay); yield return(waitWhile); while (time > 0 && answerNum > 0) { time -= wait.waitTime; SendRPC("TimeChange", time); yield return(wait); } time = turnTime; } roundNum++; yield return(delay); yield return(waitWhile); SendRPC("Alert", $"{roundNum} 라운드가 종료됐습니다.", 3f); } while (roundNum < maxRoundNum); yield return(waitWhile); SendRPC("GameEnd", GameEndType.normal, ""); isPlaying = false; //GameEnd(); }
private void Awake() { _playerController = GetComponent <PlayerController>(); _spriteRenderer = GetComponent <SpriteRenderer>(); _playerCollider = GetComponent <Collider2D>(); _waitWhileExplotionIsPlaying = new WaitWhile(() => _playerExplotion.isPlaying); RegisterPreservable(); }
protected IEnumerator WaitUntilDonePlaying(AudioPlayer ap) { CustomYieldInstruction wait = new WaitUntil(() => ap.Player.clip.loadState == AudioDataLoadState.Loaded); yield return(wait); wait = new WaitWhile(() => ap.Player.isPlaying); yield return(wait); Debug.Log(("AudioService: Done Playing Clip - " + ap.Clip.name).Colored(Colors.magenta)); PushAudioSource(ap); }
private async void Awake() { Logger.Log("Awake call"); this.waitWhileMenuMusic = new WaitWhile(() => MenuMusic == null || !MenuMusic); this.waitWhileLoading = new WaitWhile(() => this._isLoadingAudioClip); if (!Directory.Exists(UserDataPath)) { Directory.CreateDirectory(UserDataPath); } await this.GetSongsListAsync(); }
private IEnumerator PlayEndAudioCoroutine(AudioClip clip, float volume = 1f) { WaitWhile ww = new WaitWhile(() => mAudio.isPlaying); mAudio.clip = clip; mAudio.volume = volume; mAudio.Play(); SetTotalAlpha(0); yield return(ww); SetTotalAlpha(1f); gameObject.SetActive(false); }
void Start() { health = GetComponentInChildren <Slider>(); buttons = GetComponentsInChildren <Button>(); anims = GetComponentsInChildren <Animator>(); splashes = GetComponentsInChildren <Text>(); whileTrying = new WaitWhile(() => IsTrying()); health.value = health.maxValue = maxHealth; splashes[0].gameObject.SetActive(false); splashes[1].gameObject.SetActive(false); splashes[2].gameObject.SetActive(false); StartCoroutine(BeginTrials()); }
private IEnumerator LifetimeCoroutine() { if (wait == null) { wait = new WaitWhile(() => this.particle.IsAlive(true)); } yield return(wait); yield return(delay); // stow PoolingManager.instance.Stow(this); }
private void Start() { _state = BattleState.None; _eventSystem = FindObjectOfType <Tool.PokemonBattleEventSystem>(); _uiManager.gameObject.SetActive(false); _waitDialogueUpdating = new WaitWhile (() => { return(_dialogueController._isEnd == false); }); _waitInputing = new WaitWhile (() => { return(!Input.GetButtonDown("Interact") && !Input.GetButtonDown("Submit")); }); _waitUIUpdating = new WaitWhile (() => { return(_uiManager._mainUI._isPlayerHpAnimating || _uiManager._mainUI._isEnemyHpAnimating); }); }
/// <summary> /// Return the WaitWhile, it there's no created instance, /// It will create new one. /// </summary> /// <param name="idx"></param> /// <param name="predicate"></param> /// <returns></returns> internal static CustomYieldInstruction WaitWhile(int idx, System.Func <bool> predicate) { var t = default(CustomYieldInstruction); if (false == YieldWhileDic.ContainsKey(idx)) { t = new WaitWhile(predicate); YieldUntilDic.Add(idx, t); } else { t = YieldWhileDic[idx]; } return(t); }
private void Awake() { /* * if (!projectileObj) { * Debug.LogWarning("No projectile object loaded on Office Angel Attack!"); * } */ waitForCoolDown = new WaitForSeconds(cooldown); selfTransform = GetComponent <Transform>(); enemyComponent = GetComponent <Enemy>(); if (!enemyComponent) { Debug.LogWarning("Enemy component not found on OfficeAngel!"); } waitWhileStunned = new WaitWhile(enemyComponent.GetIsStunned); }
public static int get_keepWaiting(IntPtr l) { int result; try { WaitWhile waitWhile = (WaitWhile)LuaObject.checkSelf(l); LuaObject.pushValue(l, true); LuaObject.pushValue(l, waitWhile.keepWaiting); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int constructor(IntPtr l) { int result; try { Func <bool> predicate; LuaObject.checkDelegate <Func <bool> >(l, 2, out predicate); WaitWhile o = new WaitWhile(predicate); LuaObject.pushValue(l, true); LuaObject.pushValue(l, o); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
protected virtual void Awake() { if (VoxelManager.Instance == null) { VoxelManager.Instance = this; DontDestroyOnLoad(this.gameObject); } else { Destroy(this.gameObject); return; } this.waitWhileUpdatingChunk = new WaitWhile(() => { return(this.updatingChunk != null && this.updatingChunk.IsUpdating); }); for (int i = 0; i < this.worlds.Count; i++) { WorldDefinition world = this.worlds[i]; for (int j = 0; j < world.Blocks.Count; j++) { BlockDefinition block = world.Blocks[j]; if (!this.blocks.Contains(block)) { this.blocks.Add(block); this.blocksDictionary.Add(block.Identifier, block); } } } for (int j = 0; j < this.currentWorld.TexturesUV.Count; j++) { TextureUV textureUV = this.currentWorld.TexturesUV[j]; if (!this.texturesUVDictionary.ContainsKey(textureUV.Texture)) { this.texturesUVDictionary.Add(textureUV.Texture, textureUV.UV); } } }
/// <summary> /// Move a folder to another folder overwriting any conflicting folder /// </summary> /// <param name="source"></param> /// <param name="dest"></param> private void MoveFolderToFolder(string source, string dest) { if (Directory.Exists(dest)) { Directory.Delete(source, true); return; } var moved = false; var wait = new WaitWhile().OrError(new TimeSpan(0, 0, 5)); while (wait.Variable(moved).IsFalse) { try { Directory.Move(source, dest); } catch (IOException) { continue; } moved = true; } }
public static SimpleCoroutineAwaiter GetAwaiter(this WaitWhile instruction) { return(GetAwaiterReturnVoid(instruction)); }
public static AwaiterCoroutine <WaitWhile> GetAwaiter(this WaitWhile waitWhile) { return(new AwaiterCoroutine <WaitWhile>(waitWhile)); }
// The coroutine that is started by Unity. This wraps the existing coroutine with // additional functions. IEnumerator _coroutine() { // Cache objects to avoid generating unnecessary rubbish. var waitToResume = new WaitWhile(isSuspended); if (mutex != null) { // wait to acquire the lock. if (!_single) { yield return(new WaitUntil(Function.delay(CoroutineMonitor.TryEnter, mutex))); } SetInUseBy(mutex, this); // it is possible for the suspend flag to be set before the coroutine even starts // executing, so we will have to pause the execution in such a situation. if (suspend) { yield return(waitToResume); } } // set the started status flag started = true; // this if statement is here because it is also possible for the coroutine to be // interrupted before execution, specifically while waiting for a lock on the mutex // in chained mode. If such a case happens, we do not want the user code to run at all. if (!interrupt) { while (routine.MoveNext()) { // Due to the syntax of iterators, assume that the user code is executed here. // The yield instruction for user code yield return(routine.Current); // Check if the suspend flag is set before running the next chunk of user code. if (suspend) { yield return(waitToResume); } // Check if the interrupt flag is set before running the next chunk of user // code. if (interrupt) { break; } } // guarantee execution of dispose block routine.Dispose(); } // Release the lock on the mutex if possible. Note that if the interrupt flag is set, // Then the Interrupt() function would have already released the lock, so we don't do // it twice. if (mutex != null && !interrupt) { CoroutineMonitor.Exit(mutex); } // Set the complete status flag. completed = true; }
public WaitWhileOrForSecondsRealtime(WaitWhile waitWhile, WaitForSecondsRealtime waitForSecondsRealtime) { WaitWhile = waitWhile; WaitForSecondsRealtime = waitForSecondsRealtime; }
internal CardNameTranslationManager() { _nameTracker = new NameTracker(); _cardsInProgress = new HashSet <string>(); _waitWhileCardsAreInProgress = new WaitWhile(AreCardsInProgress); }