public void StopRollingSound()
 {
     if (MyAudioSourceComponent.IsPlaying())
     {
         MyAudioSourceComponent.Stop();
     }
 }
        void NudgeBallRight(float famount)
        {
            FHitResult _hit;

            MyOwner.SetActorLocation(
                MyOwner.GetActorLocation() +
                new FVector(0, famount, 0), false, out _hit, false);

            if (BallNudgeSound != null)
            {
                MyAudioSourceComponent.Sound = BallNudgeSound;
                MyAudioSourceComponent.Play();
            }
        }
Esempio n. 3
0
        void PlayPinStrikeSounds(AActor _other)
        {
            int   _settledPins = gamemode.lastSettledCount;
            float _center      = 50f;
            float _otherYLoc   = _other.GetActorLocation().Y;
            float _offset      = _otherYLoc >= 0 ?
                                 FMath.Abs(_otherYLoc - _center) : FMath.Abs(_otherYLoc + _center);
            float _highoffset = 350f;
            float _offsetAsPercentageDecimal = (_offset / _highoffset);
            float _highVelX = 2500f;
            float _lowVelX  = 1000f;
            float _velX     = FMath.Clamp(_other.GetVelocity().X, _lowVelX, _highVelX);
            float _velXAsPercentageDecimal = ((_velX - _lowVelX) / (_highVelX - _lowVelX));
            //The Less Pins, The Higher The Percentage
            float _pinSettledPenaltyAsPercentage = 1 - (_settledPins / 10);
            float _VelXMinusOffsetYDecimal       = _velXAsPercentageDecimal - (_offsetAsPercentageDecimal * offsetAsPercentageMultplier) - _pinSettledPenaltyAsPercentage;

            if (_offsetAsPercentageDecimal > 0.80f)
            {
                _VelXMinusOffsetYDecimal = FMath.Min(-0.5f, _VelXMinusOffsetYDecimal - 0.5f);
            }

            //MyOwner.PrintString($"Pin Strike. Vel: {_velX} VelAsPerc: {_velXAsPercentageDecimal} Off: {_offset} OffAsPerc: {_offsetAsPercentageDecimal} VelMinusOffset: {_VelXMinusOffsetYDecimal}", FLinearColor.Green, printToLog: true);
            Random _ran = new Random();

            if (_VelXMinusOffsetYDecimal <= -0.5)
            {
                MyAudioSourceComponent.Sound = _ran.Next(0, 2) == 0 ?
                                               PinStrikeSoundVolume1 : PinStrikeSoundVolume2;
            }
            else if (_VelXMinusOffsetYDecimal <= 0.2)
            {
                MyAudioSourceComponent.Sound = _ran.Next(0, 2) == 0 ?
                                               PinStrikeSoundVolume3 : PinStrikeSoundVolume4;
            }
            else
            {
                MyAudioSourceComponent.Sound = PinStrikeSoundVolume5;
            }

            MyAudioSourceComponent.Play();
        }
 void LaunchBall(FVector launchVelocity, UBowlingBallComponent bowlingBall)
 {
     if (MyMeshComponent == null)
     {
         MyOwner.PrintString("Please Assign A mesh component to the uproperty", FLinearColor.OrangeRed);
     }
     else if (MyAudioSourceComponent == null)
     {
         MyOwner.PrintString("Please Assign an audio component to the uproperty", FLinearColor.OrangeRed);
     }
     else if (BallRollingSound == null)
     {
         MyOwner.PrintString("Please Assign a sound clip to the ball rolling sound uproperty", FLinearColor.OrangeRed);
     }
     else
     {
         MyMeshComponent.AddImpulse(launchVelocity, MyMeshComponent.GetAttachSocketName(), true);
         MyAudioSourceComponent.Sound = BallRollingSound;
         MyAudioSourceComponent.Play();
     }
 }