Esempio n. 1
0
        /// <summary>
        /// Takes damage from another entity.
        /// </summary>
        /// <param name="other">The entity that dealt the damage.</param>
        public void TakeDamage(GameEntity other)
        {
            if (_takingDamage || (_invulnerabilityTime > _varService.GlobalTime))
            {
                return;
            }

            var a = Math.Sign(Position.X - other.Position.X);

            if (a == 0)
            {
                a = 1;
            }

            _moveController.Unroll();
            _moveController.SetSpeed(2.0 * a, -4.0);

            _moveController.ControlsEnabled = false;
            _takingDamage           = true;
            _moveController.Gravity = FallDamageGravity;

            _ringCollectTime = _varService.GlobalTime + 1.0;

            if (Rings > 0)
            {
                LoseRings();
            }
        }