public IEnumerator DoActionShockAgainAndReset(AudioClip _sfxMove = null, AudioClip _sfxShake = null)
    {
        if (_sfxMove != null)
        {
            MyAudioManager.instance.PlaySfx(_sfxMove);
        }

        bool _isFinished = false;

        LeanTween.scale(gameObject, Vector3.one, 0.5f).setEase(LeanTweenType.easeInSine).setOnComplete(() => {
            _isFinished = true;
        });
        yield return(new WaitUntil(() => _isFinished));

        yield return(Yielders.Get(0.2f));

        if (_sfxMove != null)
        {
            MyAudioManager.instance.PlaySfx(_sfxMove);
        }

        LeanTween.scale(diskUpRectTransform.gameObject, Vector3.one, 0.3f).setEase(LeanTweenType.easeInSine);
        LeanTween.alpha(diskUpRectTransform, 1f, 0.3f).setEase(LeanTweenType.easeInSine);
        yield return(Yielders.Get(0.7f));

        if (_sfxShake != null)
        {
            MyAudioManager.instance.PlaySfx(_sfxShake);
        }

        diskShakeController.SetUpShakeLocalPoint(1f);
        yield return(Yielders.Get(1f));

        diskShakeController.SetUpStopShake();
        diskShakeController.transform.localPosition = Vector3.zero;
        diskShakeController.transform.localRotation = Quaternion.identity;

        yield return(Yielders.Get(0.5f));

        if (_sfxMove != null)
        {
            MyAudioManager.instance.PlaySfx(_sfxMove);
        }

        _isFinished = false;
        LeanTween.scale(gameObject, Vector3.one * ratioScaleDefault, 0.5f).setEase(LeanTweenType.easeOutSine).setOnComplete(() => {
            _isFinished = true;
        });
        yield return(new WaitUntil(() => _isFinished));

        yield return(Yielders.Get(0.1f));
    }
    IEnumerator DoActionCountDownWithTimeLeft(double _timeLeft, System.Action _onFinished)
    {
        double _tmpTime = _timeLeft;

        if (_tmpTime < 0)
        {
            _tmpTime = 0;
        }
        txtCountDown.text = string.Format("{0:00}", (long)_tmpTime);

        while (_tmpTime > 0f)
        {
            yield return(null);

            _tmpTime -= Time.unscaledDeltaTime;
            if (!hadSetWarning && _tmpTime <= 5f)
            {
                hadSetWarning      = true;
                txtCountDown.color = colorTxtCountDownYellow;
            }
            if (!hadSetVibrate && _tmpTime <= 3f)
            {
                hadSetVibrate      = true;
                txtCountDown.color = colorTxtCountDownRed;
                textCountDownShakeController.SetUpShakeLocalPoint(-1);
            }

            if (_tmpTime < 0f)
            {
                _tmpTime = 0f;
            }
            txtCountDown.text = string.Format("{0:00}", (long)_tmpTime);
        }

        txtCountDown.text = "00";
        yield return(null);

        if (_onFinished != null)
        {
            _onFinished();
        }

        diskShakeController.SetUpStopShake();
        diskShakeController.transform.localPosition = Vector3.zero;
        diskShakeController.transform.localRotation = Quaternion.identity;
        textCountDownShakeController.SetUpStopShake();
        textCountDownShakeController.transform.localPosition = Vector3.zero;
        textCountDownShakeController.transform.localRotation = Quaternion.identity;
        hadSetVibrate = hadSetWarning = hadLockScreen = false;
    }
예제 #3
0
    IEnumerator DoActionCountDownWithTimeLeft(double _timeLeft, System.Action _onFinished)
    {
        double _tmpTime = _timeLeft;

        if (_tmpTime < 0)
        {
            _tmpTime = 0;
        }
        txtCountDown.text = string.Format("{0:00}", (long)_tmpTime);

        while (_tmpTime > 0f)
        {
            yield return(null);

            _tmpTime -= Time.unscaledDeltaTime;
            if (!hadSetWarning && _tmpTime <= 5f)
            {
                hadSetWarning      = true;
                txtCountDown.color = colorTxtCountDownYellow;
            }
            if (!hadSetVibrate && _tmpTime <= 3f)
            {
                hadSetVibrate      = true;
                txtCountDown.color = colorTxtCountDownRed;
                myShakeController.SetUpShakeLocalPoint(-1);
            }
            if (_tmpTime < 0f)
            {
                _tmpTime = 0f;
            }
            txtCountDown.text = string.Format("{0:00}", (long)_tmpTime);
        }

        txtCountDown.text = "00";
        yield return(null);

        if (_onFinished != null)
        {
            _onFinished();
        }

        ResetData();
    }