예제 #1
0
        public void ExitRamp()
        {
            //Debug.Log("Ramp exited");
            float speedExitingRamp = Speed;

            RampMotion.Speed = 0;
            if (!IsInKickoutHole)
            {
                SetPhysicsEnabled(true);
            }

            // Adds impulse force to the pinball to
            // keep the momentum it had on the ramp
            if (!RampMotion.DropAtEnd)
            {
                Vector3 force =
                    RampMotion.GetRampSegmentDirection() * speedExitingRamp;

                if (_useGlobalRampExitSpeedMult)
                {
                    force = force *
                            PinballManager.Instance.GlobalRampExitMomentumFactor;
                }

                AddImpulseForce(force);
            }

            if (ExitingRamp != null)
            {
                ExitingRamp();
            }

            _ramp = null;
        }
예제 #2
0
 private void AbortRamp()
 {
     if (IsOnRamp)
     {
         Debug.Log("Ramp aborted");
         RampMotion.Deactivate(true);
         //_dropAtEnd = true;
         ExitRamp();
     }
 }
예제 #3
0
        private void DrawDirection()
        {
            if (Application.isPlaying)
            {
                Gizmos.color = Color.red;

                if (IsOnRamp)
                {
                    Gizmos.DrawLine(transform.position, transform.position + RampMotion.GetRampSegmentDirection() * _radius * 5);
                }
                else
                {
                    Gizmos.DrawLine(transform.position, transform.position + PhysicsVelocity.normalized * _radius * 5);
                }
            }
        }
예제 #4
0
        public void EnterRamp(Path path, Direction direction, Waypoint startWP,
                              float rampEnterMomentumFactor, float rampGravityMultiplier,
                              bool dropAtEnd, bool useGlobalRampExitSpeedMult, KickoutHole kickoutHole)
        {
            float speedEnteringRamp = Speed * rampEnterMomentumFactor;

            if (kickoutHole != null)
            {
                speedEnteringRamp = kickoutHole.KickForce;
            }
            else if (debug_useDebugRampSpeed)
            {
                speedEnteringRamp = debug_rampSpeed;
            }

            //Debug.Log("Ramp entered - speed: " + speedEnteringRamp);
            _ramp = path;
            //_dropAtEnd = dropAtEnd;
            _useGlobalRampExitSpeedMult = useGlobalRampExitSpeedMult;
            SetPhysicsEnabled(false);
            RampMotion.Activate(_ramp, direction, startWP, speedEnteringRamp,
                                rampGravityMultiplier, dropAtEnd, kickoutHole);
        }
예제 #5
0
        /// <summary>
        /// Updates the pinball if the game is not paused.
        /// </summary>
        public void UpdatePinball()
        {
            if (_heatBall)
            {
                _heatBall = HeatUpBall(_heatColor);
            }
            else if (_coolDown)
            {
                _coolDown = CoolDownBall(_heatColor);
            }
            _speed = Speed;

            if (IsOnRamp)
            {
                bool rampEnded = !RampMotion.MoveAlongRamp();

                if (rampEnded)
                {
                    ExitRamp();
                }
            }
            if (transform.position.y < -20f)
            {
                BallOutOfBounds();
            }
            float volume = Mathf.Clamp(0, 0, Settings.Instance.EffectVolume);

            if (!InputManager.NudgeVector.Equals(Vector3.zero))
            {
                AddImpulseForce(InputManager.NudgeVector);
            }

            PinballManager.Instance.CheckIfBallIsLost(this);

            HandleDebug();
        }