/// <summary> /// Releases a spindash. /// </summary> private void ReleaseSpindash() { if (!_chargingSpindash) { return; } if (_spindashDust != null) { _entityService.KillEntity(_spindashDust); _spindashDust = null; } _moveController.GroundSpeed = 8 + (Math.Floor(_spindashCharge) / 2.0); if (_screenDirection == Direction.Left) { _moveController.GroundSpeed *= -1; } _moveController.RollSound = 0; // small hack to cancel out the roll sound when we release the spindash _moveController.Roll(); _moveController.RollSound = _rollSoundId; _chargingSpindash = false; _audioService.PlaySoundEffect(_spindashReleaseSoundId); }
/// <summary> /// Charges a spindash. /// </summary> private void ChargeSpindash() { if (!_crouching) { return; } if (!_chargingSpindash) { _spindashCharge = 0.0; // spindash can be initiated before crouch is complete so make sure we are the correct size SetBoundingBox(RollingBox); var offset = _screenDirection == Direction.Left ? 16 : -16; var origin = new Point(Position.X + offset, Position.Y + 4); _spindashDust = _entityService.CreateEntity <SpindashDust>(origin); _spindashDust.VisLayer = VisLayer; _spindashDust.RenderPriority = RenderPriority.Highest; _spindashDust.FlipHorizontally = FlipHorizontally; } else { _spindashCharge += 2.0; _spindashDust.AnimSpeed = 20.0 + (_spindashCharge * 4.0); } _spindashCharge = Math.Min(_spindashCharge, 8.0); CurrentAnimSequenceIndex = 0; _chargingSpindash = true; _audioService.PlaySoundEffect(_spindashChargeSoundId); }