Beispiel #1
0
 //Function to handle if Player is hit by Enemy 1
 public void PlayerHitByEnemy1()
 {
     if (Enemy1CollisionRect.Intersects(Player.CollisionRectangle))
     {
         Player.takeDamage();
         hit = true;
         //knockback = true;
         movementSpeed = 0;
     }
 }
Beispiel #2
0
        ////Function that handles the player knock back
        //public void KnockBack()
        //{
        //    if(!isFacingLeft)
        //    {
        //        if(knockback)
        //        {
        //            Player.position.X -= 2;
        //            distanceKnocked += 2;
        //        }
        //    }
        //    else
        //    {
        //        if(knockback)
        //        {
        //            Player.position.X += 2;
        //            distanceKnocked += 2;
        //        }
        //    }

        //    if(distanceKnocked>=knockbackDistance)
        //    {
        //        knockback = false;
        //        hit = false;
        //        distanceKnocked = 0;
        //        enemyState = EnemyState.idle;
        //    }
        //}

        //Function that returns boolean if the enemy is hit by projectile
        public bool Enemy1HitByRect(Rectangle collisionRect)
        {
            if (Enemy1CollisionRect.Intersects(collisionRect))
            {
                enemyHP--;
                SoundEffects.EnemyHurt.Play();
                enemyColor          = Color.Red * 0.6f;
                elapsedRedColorTime = 0;
                return(true);
            }
            return(false);
        }