Example #1
0
        IEnumerator Rebound(bool init = false)
        {
            if (init)
            {
                yield return(new WaitForSeconds(DashDuration));
            }

            var t = 0f;

            while (t < ChargeReboundTime - ChargeReboundDuration * 0.5f)
            {
                t += Time.deltaTime;
                yield return(null);
            }

            t = 0;
            var mapShoot = !_shootHolding;
            var mapDash  = !_dashButtom;

            _animation.CanRebound(false);
            Sfx.CanRebound(false);

            while (t < ChargeReboundDuration)
            {
                if (!_shootHolding)
                {
                    mapShoot = true;
                }
                if (!_dashButtom)
                {
                    mapDash = true;
                }

                _animation.CanRebound(true);
                Sfx.CanRebound(true);
                if (mapShoot && _shootHolding || mapDash && _dashButtom)
                {
                    if (_dashButtom && mapDash)
                    {
                        _charged = true;
                        DashStart();
                    }
                    else
                    {
                        _shootHoldingTime = Time.time - ChargeTime;
                        _shootHolding     = true;
                    }

                    yield break;
                }

                t += Time.deltaTime;
                yield return(null);
            }

            _animation.CanRebound(false);
            Sfx.CanRebound(false);
        }