public JumpStrategy(Transform cachedTransform, Transform meshToRotate, PathFinder pathFinder, EnemyConfig config, float speedMultiplier) : base(cachedTransform, meshToRotate, pathFinder, config.edgeSize, config.speedUnitsPerSecond * speedMultiplier) { _jump = new JumpMove(_cachedTransform, _meshToRotate, _pathFinder, config.jumpForce, config.jumpAngle); _roll = new RollMove(_cachedTransform, _meshToRotate, _pathFinder, _edgeSize, _rollAnglePerUpdate); _maxJumpDistance = _jump.CalculateMaxJumpDistance(); _jumpChance = config.jumpChance; }
void JumpUp(Vector3 target) { velocity += Physics.gravity * Time.deltaTime; if (transform.position.y > target.y) { JumpEnum = JumpMove.FallingDown; } }
void MoveToEdge() { if (Vector3.Distance(transform.position, JumpTarget) >= 0.05f) { SetHorizontalVelocity(); } else { JumpEnum = JumpMove.FallingDown; velocity /= 5.0f; velocity.y = 1.5f; } }
void FallDown(Vector3 target) { velocity += Physics.gravity * Time.deltaTime; if (transform.position.y <= target.y) { JumpEnum = JumpMove.Regular; Vector3 unit = transform.position; unit.y = target.y; transform.position = unit; velocity = new Vector3(); } }
void PrepareJump(Vector3 target) { float targetY = target.y; target.y = transform.position.y; CalculateHeading(target); if (transform.position.y > targetY) { JumpEnum = JumpMove.MovingEdge; JumpTarget = transform.position + (target - transform.position) / 2.0f; } else { JumpEnum = JumpMove.JumpingUp; velocity = heading * MoveSpeed / 3.0f; float difference = targetY - transform.position.y; velocity.y = JumpVelocity * (0.5f + difference / 2.0f); } }