예제 #1
0
파일: Player.cs 프로젝트: Group4-CSE/Zelda
        public void dealDamage(IEnemy enemy)
        {
            sound1.EnemyHitDie(0);
            enemy.takeDamage((int)(2.0 * GameplayConstants.PLAYER_DEAL_DAMAGE_MODIFIER));

            //Figure out sound for enemy dying
        }
예제 #2
0
        public void dealDamage(IEnemy enemy)
        {
            sound1.EnemyHitDie(0);
            enemy.takeDamage(1);

            //Figure out sound for enemy dying
        }
예제 #3
0
 public void doDamage(IEnemy target, Sounds sounds)
 {
     sounds.EnemyHitDie(0);
     target.takeDamage(1);
     p.health += 2;
     if (p.health > p.maxHealth)
     {
         p.health = p.maxHealth;
     }
 }
예제 #4
0
 public void handleCollision(IPlayerProjectile projectile, IEnemy enemy, GameManager game, IRoom room, Sounds sounds)
 {
     projectile.doDamage(enemy, sounds);
     projectile.collide(game);
     if (enemy.getHealth() <= 0)
     {
         sounds.EnemyHitDie(1);
         room.RemoveEnemy(enemy);
     }
 }
예제 #5
0
        public void playerEnemyHandler(Rectangle collisionRect, IPlayer player, IEnemy enemy, IRoom room, Sounds sound)
        {
            //get direction
            int direction;
            //0=up, 1=right, 2=down, 3= left
            int xCollisionSize = collisionRect.Width;
            int yCollisionSize = collisionRect.Height;

            // We are in a Top / Bottom style collision
            if (xCollisionSize > yCollisionSize)
            {
                // IF the bottom left corner of our enemy is less than the the top left corner of the block
                // AND the bottom left corner of our enemy is greater than the half way point of the height of the block
                // We are on the bottom
                if (collisionRect.Y == enemyRect.Y)
                {
                    direction = 2;
                }
                else // We are on the top
                {
                    direction = 0;
                }
            }
            else // We are in a Left / Right style collision
            {
                // IF the top left corner of our enemy is less than the top right corner of the block
                // AND the top left corner of our enemy is greater than the half way point of the width of the block
                // We are on the right
                if (collisionRect.X == enemyRect.X)
                {
                    direction = 1;
                }
                else // We are on the left
                {
                    direction = 3;
                }
            }

            if (player.IsAttacking() && direction == player.GetDirection())
            {
                player.dealDamage(enemy);
                if (enemy.getHealth() <= 0)
                {
                    sound.EnemyHitDie(1);
                    room.RemoveEnemy(enemy);
                }
            }
            else
            {
                enemy.Attack(player);
                //game over if health<=0. do this later once we have game over procedure.
            }
        }
 public void doDamage(IEnemy target, Sounds sounds)
 {
     sounds.EnemyHitDie(0);
     target.takeDamage(1);
 }