예제 #1
0
 /// <summary>
 /// If the collission is a foot try to parent.
 /// </summary>
 /// <param name="character">Character.</param>
 /// <param name="type">Type of raycast.</param>
 /// <returns>true if character should be parented to this platform, otherwise false.</returns>
 protected override bool CustomCollide(PlatformCollisionArgs args)
 {
     if (args.RaycastCollider.RaycastType == RaycastType.FOOT)
     {
         return true;
     }
     return false;
 }
예제 #2
0
        /// <summary>
        /// If the collission is a foot try to parent.
        /// </summary>
        /// <param name="character">Character.</param>
        /// <param name="type">Type of raycast.</param>
        protected override bool CustomCollide(PlatformCollisionArgs args)
        {
            if (args.RaycastCollider.RaycastType == RaycastType.FOOT)
            {
                return true;
            }
            if (parentOnHeadCollission && args.RaycastCollider.RaycastType == RaycastType.HEAD)
            {
                return true;
            }

            return false;
        }
예제 #3
0
 /// <summary>
 /// Called when one of the characters colliders collides with this enemys head.
 /// </summary>
 /// <param name="PlatformCollisionArgs">Arguments describing a platform collision.</param>
 /// <returns>Always returns false.</returns>
 public override bool Collide(PlatformCollisionArgs args)
 {
     if (args.RaycastCollider.RaycastType == RaycastType.FOOT)
     {
         // Apply upwards movement, this will work for most air movements, but in some cases you may need to provide a movement override
         args.Character.SetVelocityY(characterBobble);
         damageInfo.DamageCauser = args.Character;
         Debug.Log (damageInfo.DamageCauser);
         enemy.Damage(damageInfo);
         if (enemy.health <= 0)
         {
             // If the character is dead, turn everything off
             GetComponent<Collider2D>().enabled = false;
             enabled = false;
         }
     }
     return false;
 }
        /// <summary>
        /// If the collision is a foot and character is moving down get ready to launch.
        /// </summary>
        /// <param name="character">Character.</param>
        /// <param name="type">Type of raycast.</param>
        /// <returns>true if character should be parented to this platform, otherwise false.</returns>
        protected override bool CustomCollide(PlatformCollisionArgs args)
        {
            if (args.Character is Character &&
                (args.RaycastCollider.RaycastType == RaycastType.SIDE_RIGHT && springVelocity < 0) ||
                (args.RaycastCollider.RaycastType == RaycastType.SIDE_LEFT && springVelocity > 0))
            {
                if (character == args.Character) return true;

                if (character == null)
                {
                    character = (Character) args.Character;
                    StopCoroutine(DelaySpring());
                    StartCoroutine(DelaySpring());
                    return true;
                }
            }
            return false;
        }
예제 #5
0
 /// <summary>
 /// If the collision is a foot and character is moving down get ready to launch.
 /// </summary>
 /// <param name="character">Character.</param>
 /// <param name="type">Type of raycast.</param>
 /// <returns>true if character should be parented to this platform, otherwise false.</returns>
 protected override bool CustomCollide(PlatformCollisionArgs args)
 {
     if (args.RaycastCollider.RaycastType == RaycastType.FOOT && args.Character is Character)
     {
         if (character == args.Character) return true;
         if (args.Character.Velocity.y <= 0.0f)
         {
             if (character == null)
             {
                 character = (Character) args.Character;
                 StopCoroutine(DelaySpring());
                 StartCoroutine(DelaySpring());
                 return true;
             }
         }
     }
     return false;
 }
예제 #6
0
 /// <summary>
 /// Called when one of the characters colliders collides with this platform.
 /// </summary>
 /// <param name="character">Character.</param>
 /// <param name="type">Type of raycast.</param>
 /// <returns>tAlways returns false.</returns>
 public override bool Collide(PlatformCollisionArgs args)
 {
     Debug.Log ("Collide: " + args.Character + " " + args.RaycastCollider.RaycastType);
     return false;
 }