/// <summary>
 /// Moves the character.
 /// </summary>
 override public void DoMove()
 {
     if (waitingToJump)
     {
         if (bobbleHeight > 0)
         {
             character.DefaultAirMovement.DoOverridenJump(bobbleHeight, 1);
         }
         if (enemyHurtBox != null && enemyHurtBox is EnemyHurtBox)
         {
             damageInfo.Direction = transform.position - ((EnemyHurtBox)enemyHurtBox).transform.position;
             enemyHurtBox.Damage(damageInfo);
         }
         waitingToJump = false;
     }
     else if (waitingToKick)
     {
         if (enemyHurtBox != null && enemyHurtBox is EnemyHurtBox)
         {
             damageInfo.Direction = transform.position - ((EnemyHurtBox)enemyHurtBox).transform.position;
             enemyHurtBox.Damage(damageInfo);
         }
         waitingToKick      = false;
         kickAnimationTimer = kickTime;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Do the actual hit.
 /// </summary>
 /// <param name="other">Other.</param>
 override protected bool DoHit(Collider2D other)
 {
     // Simple projectiles can hit only one thing
     if (!hasHitCharacter && enabled)
     {
         IHurtable hurtBox = (IHurtable)other.gameObject.GetComponent(typeof(IHurtable));
         // Got a hurt box and its not ourselves
         if (hurtBox != null && !hasHitCharacter && hurtBox.Mob != character)
         {
             if (projectile != null && destroyOnEnemyHit)
             {
                 projectile.DestroyProjectile(true);
             }
             damageInfo.Direction = transform.position - other.transform.position;
             hurtBox.Damage(damageInfo);
             if (!allowMultiHit)
             {
                 hasHitCharacter = true;
             }
             return(true);
         }
         else
         {
             if (projectile != null && destroyOnSceneryHit)
             {
                 projectile.DestroyProjectile(false);
             }
         }
     }
     return(false);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Do the actual hit.
 /// </summary>
 /// <param name="other">Other.</param>
 override protected bool DoHit(Collider2D other)
 {
     if (character.Velocity.y < 0 || character.PreviousVelocity.y < 0)
     {
         if (base.DoHit(other))
         {
             DoBobble();
             StartCoroutine(ResetCollider());
             return(true);
         }
         return(false);
     }
     if (kickHidingEnemies)
     {
         IHurtable hurtBox = (IHurtable)other.gameObject.GetComponent(typeof(IHurtable));
         // Got a hurt box and its not ourselves
         if (hurtBox != null && !hasHitCharacter && hurtBox.Mob is Enemy && ((Enemy)hurtBox.Mob).State == EnemyState.HIDING)
         {
             damageInfo.Direction = transform.position - other.transform.position;
             hurtBox.Damage(damageInfo);
             hasHitCharacter = true;
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Do the actual hit.
        /// </summary>
        /// <param name="other">Other.</param>
        override protected bool DoHit(Collider2D other)
        {
            // Simple projectiles can hit only one thing
            if (!hasHitCharacter && enabled)
            {
                IHurtable hurtBox = (IHurtable)other.gameObject.GetComponent(typeof(IHurtable));
                // Got a hurt box and its not ourselves
                if (hurtBox != null && !hasHitCharacter && hurtBox.Mob != character)
                {
                    if (projectile != null && destroyOnEnemyHit)
                    {
                        projectile.DestroyProjectile(true);
                    }
                    damageInfo.Direction = transform.position - other.transform.position;
                    hurtBox.Damage(damageInfo);
                    if (!allowMultiHit)
                    {
                        hasHitCharacter = true;
                    }
                    if (character is Character)
                    {
                        ((Character)character).HitEnemy(hurtBox.Mob, damageInfo);
                    }
                    return(true);
                }
                else
                {
                    if (hurtBox == null && projectile != null && destroyOnSceneryHit)
                    {
                        projectile.DestroyProjectile(false);
                    }
                    // TODO: Ideally this shouldn't be here but on something related to grappling hook projectile
                    if (projectile is GrapplingHookProjectile)
                    {
                        if (((GrapplingHookProjectile)projectile).shouldParent)
                        {
                            projectile.gameObject.transform.parent = other.gameObject.transform;
#if UNITY_EDITOR
                            if (other.gameObject.transform.lossyScale != Vector3.one)
                            {
                                Debug.LogWarning("Grapple with shouldParent==true requires that all the colliders it collides with have a GameObject scale of (1,1,1) due to Unity bug with parenting to non-uniform colliders. Instead of scaling your game objects set the size on the collider and leave the scale at (1,1,1).");
                            }
#endif
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 5
0
		/// <summary>
		/// Do the actual hit.
		/// </summary>
		/// <param name="other">Other.</param>
		/// <returns>true if a hit was done.</returns>
		virtual protected bool DoHit(Collider2D other)
		{
			IHurtable hurtBox = (IHurtable) other.gameObject.GetComponent(typeof(IHurtable));
			if (character == null) Debug.LogWarning("Tried to DoHit() but no character has been set");
			// Got a hurt box and its not ourselves
			if (hurtBox != null && !hasHitCharacter && hurtBox.Mob != character )
			{
				damageInfo.Direction = transform.position - other.transform.position;
				damageInfo.DamageCauser = character;
				hurtBox.Damage(damageInfo);
				if (character is Character) ((Character)character).HitEnemy(hurtBox.Mob, damageInfo);
				hasHitCharacter = true;
				return true;
			}
			return false;
		}