Example #1
0
        public void GetHit(Player player, string direction)
        {
            health -= 15;
            if (health <= 0)
            {
                currentLocation.RemoveEnemy(this);
                drops.ForEach(drop =>
                {
                    if (drop.Count > 0)
                    {
                        drop.SetLocation(new Vector2(location.X + (width / 2), location.Y));
                        currentLocation.AddItem(drop);
                    }
                });
                player.AddXp(xp);
                return;
            }

            state       = "hurt";
            hurtCounter = 20;

            if (direction == "left")
            {
                horizontalVelocity -= 5;
            }
            else
            {
                horizontalVelocity += 5;
            }
            if (!isFalling)
            {
                verticalVelocity = -7;
            }
            else
            {
                verticalVelocity -= 3;
            }
            isFalling = true;
        }