示例#1
0
        protected virtual void switchToPhysics()
        {
            pilot          = Object.Instantiate(mutableData.PilotPrefab, thisTransform.position, thisTransform.rotation);
            pilotTransform = pilot.transform;
            pilotBody      = pilot.GetComponent <Rigidbody>();
            SlideControllerListener component = pilotBody.GetComponent <SlideControllerListener>();

            if (component != null)
            {
                component.SlideController = this;
            }
            Rigidbody component2 = pilot.GetComponent <Rigidbody>();
            Vector3   wsVelocity = impulses.GetOutput().wsVelocity;

            component2.AddForce(wsVelocity, ForceMode.VelocityChange);
            mode         = Mode.PhysicsDriven;
            elapsedTime  = 0f;
            curSpringVel = 0f;
            originalDrag = pilotBody.drag;
            IsAirborne   = false;
            animator.SetBool(AnimationHashes.Params.SlideAirborne, IsAirborne);
            if (!isLocalPlayer)
            {
                return;
            }
            if (isSupportedByWater)
            {
                if (!string.IsNullOrEmpty(mutableData.Audio.SupportedEventName))
                {
                    EventManager.Instance.PostEvent(mutableData.Audio.SupportedEventName, EventAction.PlaySound, base.gameObject);
                }
                if (!string.IsNullOrEmpty(mutableData.Audio.AirborneEventName))
                {
                    EventManager.Instance.PostEvent(mutableData.Audio.AirborneEventName, EventAction.StopSound, base.gameObject);
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(mutableData.Audio.SupportedEventName))
                {
                    EventManager.Instance.PostEvent(mutableData.Audio.SupportedEventName, EventAction.StopSound, base.gameObject);
                }
                if (!string.IsNullOrEmpty(mutableData.Audio.AirborneEventName))
                {
                    EventManager.Instance.PostEvent(mutableData.Audio.AirborneEventName, EventAction.PlaySound, base.gameObject);
                }
            }
            spawnParticles();
        }
示例#2
0
        protected override void switchToPhysics()
        {
            if (FromSlideController)
            {
                pilotTransform = pilot.transform;
                pilotBody      = pilot.GetComponent <Rigidbody>();
                SlideControllerListener component = pilotBody.GetComponent <SlideControllerListener>();
                if (component != null)
                {
                    component.SlideController = this;
                }
                mode               = Mode.PhysicsDriven;
                elapsedTime        = 0f;
                curSpringVel       = 0f;
                originalDrag       = pilotBody.drag;
                pilotBody.velocity = Vector3.zero;
                spawnParticles();
            }
            else
            {
                base.switchToPhysics();
            }
            pilot.layer    = LayerMask.NameToLayer("NoncollidingTube");
            pilotBody.drag = myMutableData.RaceTrackProperties.Drag;
            Collider component2 = pilot.GetComponent <Collider>();

            if (component2 != null)
            {
                physicMaterial = component2.material;
                if (physicMaterial != null)
                {
                    bounciness                   = physicMaterial.bounciness;
                    physicMaterialCombine        = physicMaterial.bounceCombine;
                    physicMaterial.bounciness    = myMutableData.Bounciness;
                    physicMaterial.bounceCombine = myMutableData.BounceCombine;
                }
            }
        }