예제 #1
0
    IEnumerator DashRoutine()
    {
        float t = 0;

        while (t < dashSpeedMultiplier.Duration() * spawnSpikesPercentage)
        {
            _dashMultiplier = dashSpeedMultiplier.Evaluate(t);
            t += Time.deltaTime;
            yield return(null);
        }

        playMaker.SendEvent("dashFinish");

        float remainingDashTime = dashSpeedMultiplier.Duration() * (1 - spawnSpikesPercentage);

        yield return(new WaitForSeconds(remainingDashTime));

        _dashing        = false;
        _cooldown       = true;
        _dashMultiplier = 1;

        // cooldown
        yield return(new WaitForSeconds(dashCooldown));

        playMaker.SendEvent("cooldownFinish");
        _cooldown = false;
    }
예제 #2
0
    void Start()
    {
        if (startScale == StartScale.SmallScale)
        {
            transform.localScale = Vector3.one * scalingCurve.Evaluate(0);
        }

        if (startScale == StartScale.BigScale)
        {
            transform.localScale = Vector3.one * scalingCurve.Evaluate(scalingCurve.Duration());
        }
    }
    private void UpdateShootInput()
    {
        if (loadingShot)
        {
            if (Input.GetKeyUp(fire))
            {
                ShootObject();
                loadingShot = false;
                return;
            }

            var loadingShotTime = Time.time - loadingShotStartTime;
            if (loadingShotTime >= shootAngleOverTime.Duration())
            {
                shootAngle  = -shootAngleOverTime.FirstValue();
                loadingShot = false;
            }

            shootAngle = -shootAngleOverTime.Evaluate(loadingShotTime);

            return;
        }

        if (Input.GetKey(fire))
        {
            loadingShot          = true;
            loadingShotStartTime = Time.time;
        }
    }
예제 #4
0
    public void FixedTick()
    {
        if (_swingTime >= 0)
        {
            _swingTime += Time.deltaTime;

            float from = _currentBatPos == BatPosition.Left ? ANGLE_LEFT : ANGLE_RIGHT;
            float to   = _currentBatPos == BatPosition.Left ? ANGLE_RIGHT : ANGLE_LEFT;

            _currentBatAngle = Mathf.LerpUnclamped(from, to, batSwing.Evaluate(_swingTime));
            SetBatGrahpicsRotation(_currentBatAngle);

            Vector2 boxPos = batGraphics.TransformPoint(hitBoxOffset);

            int  numbHits     = Physics2D.OverlapBox(boxPos, hitBoxSize, _currentBatAngle, _contactFilter, _hitResults);
            bool hitSomething = false;
            for (int i = 0; i < numbHits; i++)
            {
                Collider2D hit = _hitResults[i];
                if (hit.attachedRigidbody != null && !_hitObjects.Contains(hit) && hit.gameObject != _playerController.gameObject)
                {
                    hit.attachedRigidbody.velocity = batPivot.right * 5f;
                    _hitObjects.Add(hit);
                    hitSomething = true;

                    playerController.HitSound();

                    batHitParticles.transform.position = hit.attachedRigidbody.transform.position - Vector3.forward * 5f;
                    batHitParticles.Play();
                }
            }
            if (hitSomething)
            {
                CameraShakerController.CameraShake();
            }

            if (_swingTime >= batSwing.Duration())
            {
                _swingTime = -1f;
                _isSwining = false;

                _hitObjects.Clear();


                if (_currentBatPos == BatPosition.Right)
                {
                    _playerController.playerAnimation.BatWobbleLeft();
                }
                else
                {
                    _playerController.playerAnimation.BatWobbleRight();
                }

                _currentBatPos = (BatPosition)(((int)_currentBatPos) * -1);
            }
        }
    }
예제 #5
0
        public float ValueFor(float xAxisInput)
        {
            float processedX = xAxisInput;

            if (curveMode == CurveMode.Loop)
            {
                float remainder = xAxisInput % curve.Duration();
                processedX = curve.StartTime() + remainder;
            }

            return(curve.Evaluate(processedX) * multiplier);
        }
예제 #6
0
    IEnumerator DashRoutine()
    {
        float t = 0;

        while (t < dashSpeedMultiplier.Duration())
        {
            _dashMultiplier = dashSpeedMultiplier.Evaluate(t);
            t += Time.deltaTime;
            yield return(null);
        }

        playMaker.SendEvent("dashFinish");

        _dashing        = false;
        _dashMultiplier = 1;
    }
예제 #7
0
    private IEnumerator FadeCoroutine()
    {
        meshRenderer.enabled = true;

        float duration = fadeCurve.Duration();
        float elapsed  = 0f;

        while (elapsed < duration)
        {
            float evaluated = fadeCurve.Evaluate(elapsed / duration);
            wireframeMaterial.SetFloat("_LineOpacity", evaluated);

            elapsed += Time.deltaTime;

            yield return(null);
        }
    }
예제 #8
0
 protected virtual void Update()
 {
     if (useSpeedCurve)
     {
         if (direction.magnitude > moveInputThreshold)
         {
             _speedCurveTime += Time.deltaTime;
             if (_speedCurveTime > speedCurve.Duration())
             {
                 _speedCurveTime = 0;
             }
         }
         else
         {
             _speedCurveTime = 0;
         }
     }
 }
예제 #9
0
    IEnumerator MoveAlongPathSequence()
    {
        Vector3 initScale    = objectOnPath.transform.localScale;
        float   lerpProgress = 0;
        float   duration     = movementCurve.Duration();

        while (lerpProgress < 1)
        {
            lerpProgress += deltaTime / duration;
            progress      = movementCurve.Evaluate(lerpProgress * duration);
            if (scaleObjectOnPath)
            {
                objectOnPath.transform.localScale = initScale * scaleCurve.Evaluate(lerpProgress);
            }
            yield return(null);
        }
        progress = 1;
        moveAlongPathComplete.Invoke();
    }
예제 #10
0
    IEnumerator MoveAlongPath(CinemachinePath path)
    {
        float duration = pathMovementCurve.Duration();
        float progress = 0;

        Debug.Log("Starting lerp with a duration of " + duration);

        pathFollower.path = path;

        while (progress < 1)
        {
            progress += Time.deltaTime / duration;
            Debug.Log("progress is now " + progress);
            pathFollower.SetNormalizedPathPos(pathMovementCurve.Evaluate(progress * duration));
            yield return(null);
        }

        ActivateGlyph();
    }
예제 #11
0
 public void DoShake()
 {
     DoShake(autoShakeCurve.Duration());
 }
예제 #12
0
 public static float EvaluatePercent(this AnimationCurve curve, float percent)
 {
     return(curve.Evaluate(percent * curve.Duration()));
 }