Ejemplo n.º 1
0
        public void Damage(Bullet bullet)
        {
            _health -= bullet.damage;
            _healthBar.ChangePercentage(((float)_health / cStartHealth) * 100);
            if (_health <= 0)
            {
                _health = 0;
                canAct  = false;
                PooledObjects.explosions.Find(x => !x.IsVisible).Explode(this);
                //Play sound or something
                if (IsXboxControllerScheme(_usedControlScheme) && _isVibrating)
                {
                    GamePad.SetVibration(_gamePadIndex, 0, 0);
                }
                Hide();
            }
            else
            {
                if (bullet.damage == 3)
                {
                    AudioManager.PlaySFX("CriticalHit", 1);
                }
                else
                {
                    AudioManager.PlaySFX("Hit" + PlayScreen.random.Next(1, 4), 0.5f);
                }

                _receivedForceDirection = bullet.directionVector;
                _recievedForceTimer     = 0;
                _recievedForceMagnitude = bullet.damage * 3f;
                if (IsXboxControllerScheme(_usedControlScheme))
                {
                    _isVibrating    = true;
                    _vibrationTimer = 0;
                }
            }
        }