/// <summary>
 /// Helper for playing the landing movement effect
 /// </summary>
 protected void PlayLanding(MovementEventData data)
 {
     if (canPlayEffect)
     {
         m_CurrentMovementEventLibrary.PlayLanding(data);
     }
 }
 /// <summary>
 /// Helper for playing the right foot movement effect
 /// </summary>
 protected void PlayRightFoot(MovementEventData data)
 {
     if (canPlayEffect)
     {
         m_CurrentMovementEventLibrary.PlayRightFoot(data);
     }
 }
        // Helper function for ensuring that the MovementEventPlayer prefab is only instantiated once and the cached version is then used
        //      movementEventData: The data relating to the movement event
        //      prefab: The prefab to instantiate, if it is not cached
        //      instance: The cached instance of the prefab - this could be null and therefore the keyword ref is required
        void PlayInstancedEvent(MovementEventData movementEventData, MovementEventPlayer[] prefabs, ref MovementEventPlayer[] instances)
        {
            if (prefabs == null || prefabs.Length == 0)
            {
                return;
            }

            var arrayLength = prefabs.Length;

            if (instances == null || instances.Length == 0)
            {
                instances = new MovementEventPlayer[arrayLength];

                for (var i = 0; i < arrayLength; i++)
                {
                    instances[i] = Object.Instantiate(prefabs[i]);
                }
            }

            for (int i = 0; i < arrayLength; i++)
            {
                var instance = instances[i];
                if (instance == null)
                {
                    var player = Object.Instantiate(prefabs[i]);
                    instances[i] = player;
                    instance     = player;
                    player.Play(movementEventData);
                }

                instance.Play(movementEventData);
            }
        }
Пример #4
0
        // Safely broadcast movement event after collider detection
        //		movementEventData: Movement event data
        //		physicMaterial: the corresponding physic material
        void OnDetection(MovementEventData movementEventData, PhysicMaterial physicMaterial)
        {
            if (detection == null)
            {
                return;
            }

            detection(movementEventData, physicMaterial);
        }
Пример #5
0
        // Trigger when foot collider enters ground
        void OnTriggerEnter(Collider other)
        {
            if (m_LayerMask != (m_LayerMask | (1 << other.gameObject.layer)))
            {
                return;
            }

            var movementEventData = new MovementEventData(transform);

            OnDetection(movementEventData, other.sharedMaterial);
        }
 /// <summary>
 /// Helper for playing the Jumping movement event
 /// </summary>
 /// <param name="movementEventData">The data relating to the movement event</param>
 public void PlayJumping(MovementEventData movementEventData)
 {
     PlayInstancedEvent(movementEventData, m_JumpingEffects, ref m_JumpingInstances);
 }
 /// <summary>
 /// Helper for playing the Right Foot movement event
 /// </summary>
 /// <param name="movementEventData">The data relating to the movement event</param>
 public void PlayRightFoot(MovementEventData movementEventData)
 {
     PlayInstancedEvent(movementEventData, m_RightFootEffects, ref m_RightFootStepInstances);
 }