Example #1
0
        public virtual void ReceiveAttack(int damage, Vector2 subjectPosition)
        {
            if (_dying || IsImunity)
            {
                return;
            }

            CharacterSprite.RequestImmunityAnimation();

            _knockbackAcceleration = Math.Sign(BoundingRectangle.Center.X - subjectPosition.X) * 5000f;
            _velocity.Y            = -300f;

            GainHP(-damage);
            if (GetHp() <= 0)
            {
                _dyingAcceleration = Math.Sign(Position.X - subjectPosition.X) * 0.7f;
                OnDie();
            }
        }
        public override void ReceiveAttack(int damage, Vector2 subjectPosition)
        {
            if (_dying || IsImunity)
            {
                return;
            }

            CharacterSprite.RequestImmunityAnimation();

            _hp = _hp - damage < 0 ? 0 : _hp - damage;
            if (_hp == 0)
            {
                IgnoreGravity      = false;
                _dyingAcceleration = Math.Sign(Position.X - subjectPosition.X) * 0.7f;
                OnDie();
            }

            _hitSe.PlaySafe();
        }