Beispiel #1
0
 private void OnRewardClaimed()
 {
     CoroutineController.DoAfterGivenTime(2f, () =>
     {
         ViewController.Instance.GameOverView.Close();
         NextLevel();
     });
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public void PlayConfetti(Action onComplete = null)
 {
     _confetti.gameObject.SetActive(true);
     _confetti.Play();
     CoroutineController.DoAfterGivenTime(_confetti.main.duration, () =>
     {
         _confetti.gameObject.SetActive(false);
         onComplete?.Invoke();
     });
 }
        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);
                });
            });
        }
Beispiel #5
0
        private void DisposeLevel()
        {
            TileMapSystem.HexagonBlowed   -= OnHexagonBlowed;
            TileMapSystem.OutOfMove       -= OnOutOfMove;
            BombHexagonBehaviour.Exploded -= OnBombExploded;

            Destroy(CurrentLevel.gameObject);

            CoroutineController.DoAfterGivenTime(1f, () =>
            {
                ViewController.Instance.GameOverView.Close();
                PrepareLevel();
            });
        }
Beispiel #6
0
        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);
        }