public void TryAttack(Character enemy)
 {
     if (!enemy.beingAttacked && attacking == false)
     {
         if (this.position.X - base.frame.Width - range < enemy.position.X && this.position.X > enemy.position.X
             || this.position.X + base.frame.Width + range > enemy.position.X && this.position.X < enemy.position.X)
         {
             attacking = true;
             attackedEnemy = enemy;
             attackedEnemy.beingAttacked = true;
         }
     }
 }
 public static void AddCharacter(Character character)
 {
     characterList.Add(character);
 }
        public override void Update()
        {
            if (hp > 0)
            {
                if (this.position.X < 0) { Bar.barValue.X -= 10; hp = 0; }
                else if (this.position.X > 800) { Bar.barValue.X += 10; hp = 0; }

                if (attackedEnemy != null)
                {
                    if (attackedEnemy.position.Y - 5 > position.Y) { position.Y+=1.5f; }
                    else if (attackedEnemy.position.Y + 5 < position.Y) { position.Y -= 1.5f; }

                    attackedEnemy.hp -= attack;
                    state = State.Attacking;
                    if (attackedEnemy.hp <= 0) { attackedEnemy = null; beingAttacked = false; }
                }
                else { attacking = false; beingAttacked = false; state = State.Walking; }
            }
            else
            {
                state = State.Dead;

                i++;
                if (i > 25) { dead = true; }
            }

            base.Update();
        }