private void OnGameplayFadeOutCallback() { bgMng.StartBackground(); videoAlreadyWhatched = false; DifficultyManager.StartGame(); int firstGame = PlayerPrefs.GetInt("Tutorial", 0); if (firstGame == 0) { readInput = false; isTutorial = true; tutorialTimes++; gameplayPanel.EnableTutorialPanel(true); spawnCtrl.StartSpawn(ShapeController.GetShapeByIndex(ShapeController.GetCurrentShapeIndex() - 1)); CoroutineController.StartRoutine(StartTutotrial, 6.5f); } else { spawnCtrl.StartSpawn(); readInput = true; isTutorial = false; } startState = true; }
public override void ApplyItemServer(Item.Item item) { if (item == null) { if (_isPowered) { if (State == DoorState.Closed) { State = DoorState.Opening; if (_prevCoroutinController != null) { _prevCoroutinController.ShouldStop = true; } _prevCoroutinController = new CoroutineController(); StartCoroutine(CloseDoorDelayed(_prevCoroutinController)); } if (State == DoorState.Opened) { State = DoorState.Closing; } } } }
private void OnRewardClaimed() { CoroutineController.DoAfterGivenTime(2f, () => { ViewController.Instance.GameOverView.Close(); NextLevel(); }); }
public static Coroutine StartCoroutineEx(this MonoBehaviour monoBehaviour, IEnumerator routine, out CoroutineController coroutineController) { if (routine == null) { throw new System.ArgumentNullException("routine is NULL"); } coroutineController = new CoroutineController(routine); return(monoBehaviour.StartCoroutine(coroutineController.Start())); }
public int ExecuteOnce(IEnumerator routine) { var controller = new CoroutineController(this, routine); controller.Start(); _onceDic.Add(controller.ID, controller); return(controller.ID); }
private static IEnumerator PingRoutine(string url, Action <bool> callback) { Stopwatch watch = new Stopwatch(); watch.Start(); Ping ping = new Ping(url); Log.Debug("Ping started"); bool shouldSkip = false; CoroutineController.DoAfterGivenTime(PingTimeOutDuration / 1000f, () => shouldSkip = true, "PingSkipTimer"); yield return(new WaitUntil(() => ping.isDone || shouldSkip)); watch.Stop(); if (ping.isDone) { Log.Debug("Ping completed."); Log.Debug("Ping time: " + ping.time); // If pinging exceeds the default time (timeout), Unity returns -1 as ping.time // This ping.time < 0 check is for that reason if (ping.time < 0 && ping.time > PingTimeOutDuration) { // ----FAIL---- Log.Error("Rateus Timeout. ping.time:" + ping.time); callback.Invoke(false); if (CoroutineController.IsCoroutineRunning("PingSkipTimer")) { CoroutineController.StopCoroutine("PingSkipTimer"); } } else { // ----SUCCESS----- callback.Invoke(true); } } else if (shouldSkip) { // ----FAIL---- Log.Error("Ping failed."); callback.Invoke(false); } else { // ----FAIL---- Log.Error("Unknown state."); callback.Invoke(false); } Log.Debug("Watch time: " + watch.Elapsed.TotalMilliseconds); }
private void ToggleMovement(bool state) { if (_isHit && state || _canMove == state) { return; } _canMove = state; CoroutineController.ToggleRoutine(state, MoveRoutineKey, MoveRoutine()); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.layer == LayerMask.NameToLayer("RoadBorder")) { StopAll(); CoroutineController.DoAfterFixedUpdate(() => Finish?.Invoke(false)); _rigidBody.transform.DOKill(); ResetTransform(); } }
private void ToggleRotating(bool state, Direction?direction = null) { if (_isHit && state || _canRotate == state) { return; } _canRotate = state; ToggleTireTracks(state); CoroutineController.ToggleRoutine(state, RotateRoutineKey, RotateRoutine(direction)); }
public void PlayConfetti(Action onComplete = null) { _confetti.gameObject.SetActive(true); _confetti.Play(); CoroutineController.DoAfterGivenTime(_confetti.main.duration, () => { _confetti.gameObject.SetActive(false); onComplete?.Invoke(); }); }
protected override void OnRestored() { HudEvents.In -= HudEvents_In; On.PlayerData.SetInt -= PlayerData_SetInt; foreach (var detour in _detours) { detour.Undo(); } CoroutineController.Start(OnToggledCoroutine()); }
protected override void OnApplied() { HudEvents.In += HudEvents_In; On.PlayerData.SetInt += PlayerData_SetInt; foreach (var detour in _detours) { detour.Apply(); } CoroutineController.Start(OnToggledCoroutine()); }
public void GameObjectComponentRemoval() { CoroutineController controller = new CoroutineController(); GameObject gameObject = new GameObject(controller); Assert.AreEqual(gameObject.Count, 2, "Initial count was not two, as it should've been."); gameObject.Remove(controller); Assert.AreEqual(gameObject.Count, 1, "Count after removal wasn't one, as it should've been (as only the Transform should be left attached)."); }
protected override void OnApplied() { HudEvents.In += HudEvents_In; IL.BossSequenceController.RestoreBindings += BossSequenceController_RestoreBindings; foreach (var detour in _detours) { detour.Apply(); } CoroutineController.Start(OnAppliedCoroutine()); }
public int Execute(IEnumerator routine, bool autoStart = true) { CoroutineController controller = new CoroutineController(this, routine); _controllersDic.Add(controller.ID, controller); if (autoStart) { StartExecute(controller.ID); } return(controller.ID); }
public void Start() { //Start Coroutine WITHOUT key RoutineWithoutKey().StartCoroutine(); //CoroutineController.StartCoroutine(RoutineWithKey()); <--- This also can be used //Do After Given Time with ANONYMOUS action CoroutineController.DoAfterGivenTime(3f, () => { Debug.Log("OVERRIDE!"); //Override Coroutine WITHOUT key RoutineWithoutKey().StartCoroutine(true); CoroutineController.DoAfterGivenTime(3f, () => { //Stop Coroutine WITHOUT key Debug.Log("STOP!"); RoutineWithoutKey().StopCoroutine(); }); }); //Cancellable Do After CoroutineController.DoAfterGivenTime(10f, () => { Debug.LogError("This should NOT be shown!"); }, "killme"); CoroutineController.DoAfterGivenTime(9f, () => { CoroutineController.StopCoroutine("killme"); }); //Do After Given Time with action Action action = () => { //Start Coroutine WITH key RoutineWithKey().StartCoroutine("myKey"); CoroutineController.DoAfterGivenTime(3f, () => { //Stop Coroutine WITH KEY RoutineWithKey().StopCoroutine("myKey"); }); }; action.DoAfterGivenTime(12f); CoroutineController.DoAfterGivenTime(18f, () => { RoutineWillDieItSelf().StartCoroutine(onFinished: isStopped => { Debug.Log("RoutineWillDieItSelf died by itself. IsStopped: " + isStopped); }); }); }
public static void Initialize() { if (_isInitialized) { return; } _isInitialized = true; InternetReachability = Application.internetReachability; CoroutineController.StartCoroutine(CheckInternetConnectionRoutine()); }
/// <summary> /// Extends <c>Unity.MonoBehaviour</c> to start a coroutine wrapper in a /// <see cref="CoroutineController"/>. /// </summary> public static CoroutineController StartCoroutineEx(this MonoBehaviour monoBehaviour, IEnumerator routine) { if (routine == null) { throw new System.ArgumentNullException("routine"); } CoroutineController coroutineController = new CoroutineController(routine); coroutineController.StartCoroutine(monoBehaviour); return(coroutineController); }
public override void Enter() { gm = context.GetGameManager(); musicCtrl = gm.GetMusicController(); uiMng = gm.GetUIManager(); mainMenuPanel = uiMng.GetMenu <UIMenu_MainMenu>(); uiMng.SetCurrentMenuAnimation <UIMenu_MainMenu>("MainMenuIn"); CoroutineController.StartRoutine(() => mainMenuPanel.EnablePanelContainer(true), 0.01f); musicCtrl.PlayMainMenuClip(); mainMenuPanel.StartGameButtonPressed = StartGameButtonPressed; }
/// <summary> /// Pings the given url. URL SHOULD BE IN IPv4 FORMAT /// </summary> /// <param name="url">Should be in IPv4 format</param> /// <param name="callback">Returns boolean for success</param> public static void PingUrl(string url, Action <bool> callback) { int count = url.Split('.').Length - 1; if (count != 3) { // Notation is probably wrong. Log.Warning("Are you sure you have given the url in IPv4 format?"); } CoroutineController.StartCoroutine(PingRoutine(url, callback), "PingRoutine"); }
protected override void OnRestored() { HudEvents.In -= HudEvents_In; On.GGCheckBoundSoul.OnEnter -= GGCheckBoundSoul_OnEnter; IL.BossSequenceController.RestoreBindings -= BossSequenceController_RestoreBindings; foreach (var detour in _detours) { detour.Undo(); } CoroutineController.Start(OnRestoredCoroutine()); }
private void HandleOnShapeGuessed() { if (i.shapesToAdd.Count == 0) { return; } shapeGuessed++; if (shapeGuessed == shapesToAdd[0].addNewShapeAfter) { CoroutineController.StartRoutine(AddNewShape, 0.5f); } }
private IEnumerator CloseDoorDelayed(CoroutineController controller) { yield return(new WaitForSeconds(DoorCloseDelay)); if (!controller.ShouldStop) { if (State == DoorState.Opened && Electrified) { State = DoorState.Closing; } Debug.Log("Coroutine!"); } }
private void DisposeLevel() { TileMapSystem.HexagonBlowed -= OnHexagonBlowed; TileMapSystem.OutOfMove -= OnOutOfMove; BombHexagonBehaviour.Exploded -= OnBombExploded; Destroy(CurrentLevel.gameObject); CoroutineController.DoAfterGivenTime(1f, () => { ViewController.Instance.GameOverView.Close(); PrepareLevel(); }); }
public static CoroutineController StartCoroutineExtension(this MonoBehaviour monoBehaviour, IEnumerator routine, Action onFinish) { if (routine == null) { throw new System.ArgumentNullException("Parameter 'routine' is NULL"); } CoroutineController coroutineController = new CoroutineController(routine); if (null != onFinish) { coroutineController.OnFinish += onFinish; } coroutineController.StartCoroutine(monoBehaviour); return(coroutineController); }
public void UpdateCoin(int to) { var counter = _currentCoin; DOTween.To( getter: () => counter, setter: i => counter = i, endValue: PlayerData.Coin, duration: 1f) .onUpdate = () => { _coinAmountText.text = counter.ToString(); }; CoroutineController.DoAfterGivenTime(1f, () => _currentCoin = PlayerData.Coin); }
/// <summary> /// Pings 8.8.8.8 and returns a bool callback. /// </summary> /// <param name="callback"></param> public static void PingGoogle(Action <bool> callback) { CoroutineController.StartCoroutine(PingRoutine("8.8.8.8", callback), "PingRoutine"); }
public static bool StopRequest(IEnumerator routine) { var sucess = false; CoroutineController controller = null; if (s_executingRequests.TryGetValue(routine, out controller)) { if (controller != null) { s_executingRequests.Remove(routine); } if (controller.state != CoroutineState.Finished) { sucess = true; //Stop Running Routines if (controller.state == CoroutineState.Running || controller.state == CoroutineState.Paused) { controller.Stop(); } } } if (s_pendingRequestsHash.Contains(routine)) { int v_index = s_pendingRequests.IndexOf(routine); if (v_index >= 0) { s_pendingRequests.RemoveAt(v_index); } sucess = s_pendingRequestsHash.Remove(routine) || sucess || v_index >= 0; } //Remove Sender from this routine MonoBehaviour sender = null; if (s_enumeratorToSenders.TryGetValue(routine, out sender)) { s_enumeratorToSenders.Remove(routine); } //Remove Hash var hash = ""; if (s_enumeratorToHashMap.TryGetValue(routine, out hash)) { s_enumeratorToHashMap.Remove(routine); s_hashToEnumeratorMap.Remove(hash); } if (sucess) { if (OnCancelRequest != null) { OnCancelRequest(sender, routine, hash); } } //The routine was finished but will only be unscheduled in next frame, so we can report the "OnRequestExecutionFinish" now else if (!sucess && controller != null) { if (OnRequestExecutionFinish != null) { OnRequestExecutionFinish(sender, routine, hash); } } return(sucess); }
public static Coroutine StartCoroutineEx(this MonoBehaviour monoBehaviour, IEnumerator routine, out CoroutineController coroutineController) { if (routine == null) { throw new System.ArgumentNullException("routine"); } coroutineController = new CoroutineController(routine); return monoBehaviour.StartCoroutine(coroutineController.Start()); }
private void Awake() { i = this; }
public void ExecuteOnce(IEnumerator routine) { CoroutineController controller = new CoroutineController(this, routine); controller.Start(); }