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; }
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; } }
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); } } }
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); }
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; }
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); } }
protected virtual void Update() { if (useSpeedCurve) { if (direction.magnitude > moveInputThreshold) { _speedCurveTime += Time.deltaTime; if (_speedCurveTime > speedCurve.Duration()) { _speedCurveTime = 0; } } else { _speedCurveTime = 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(); }
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(); }
public void DoShake() { DoShake(autoShakeCurve.Duration()); }
public static float EvaluatePercent(this AnimationCurve curve, float percent) { return(curve.Evaluate(percent * curve.Duration())); }