示例#1
0
        public virtual void onHit(Vector2 knockback)
        {
            var xKnockback           = _playerComponent.CurrentStateHorizontalKnockback();
            var yKnockback           = _playerComponent.CurrentStateVerticalKnockback();
            var screenShakeMagnitude = _playerComponent.CurrentStateScreenShakeMagnitude();

            var diff = Math.Sign((entity.position - _playerComponent.entity.position).X);

            knockback.X = diff;

            _knockbackTick     = new Vector2(0.05f, yKnockback);
            _knockbackVelocity = new Vector2(knockback.X * 2, -1000);

            if (Math.Abs(xKnockback) > 0.01)
            {
                _knockbackTick     = new Vector2(xKnockback, yKnockback);
                _knockbackVelocity = new Vector2(diff * 60, -1000);
            }

            if (Math.Abs(yKnockback) < 0.001)
            {
                platformerObject.velocity.Y = platformerObject.collisionState.below ? -100 : -130;
            }

            if (screenShakeMagnitude > 0.0f)
            {
                (entity.scene as SceneMap)?.startScreenShake(screenShakeMagnitude, 100);
            }

            AudioManager.hit.Play(0.5f);

            Core.getGlobalManager <ScoreManager>().GetComboPoints(_playerComponent.CurrentDamageScale());
        }