Ejemplo n.º 1
0
        public void Decrease_Negative(PositionComponent position)
        {
            var sut = new DecreaseHorizontalVelocity(position, 10);

            sut.Target.Velocity.X = -100;

            sut.Update();

            Assert.Equal(-90, sut.Target.Velocity.X);
        }
Ejemplo n.º 2
0
        private UpdateByState CreateUpdatesByState(Inputs Inputs)
        {
            var attackCooldwon = new CooldownTracker(20);
            var HurtCooldwon   = new CooldownTracker(10);

            var changesSpeed                = new IncreaseHorizontalVelocity(this, 10);
            var decreaseVelocity            = new DecreaseHorizontalVelocity(this, 5);
            var limitHorizontalVelocity     = new LimitHorizontalVelocity(this, 100);
            var gravityChangesVerticalSpeed = new GravityChangesVerticalSpeed(this);

            var ChangePlayerStateToFalling     = new ChangePlayerStateToFalling(this);
            var changePlayerToIdle             = new ChangePlayerStateToIdle(this);
            var changePlayerToWalking          = new ChangePlayerStateToWalking(this);
            var ChangePlayerToJumpingState     = new ChangePlayerStateToJumping(this);
            var changePlayerStateToCrouch      = new ChangePlayerStateToCrouch(this);
            var changePlayerStateToLookingUp   = new ChangePlayerStateToLookingUp(this);
            var ChangePlayerStateToAttack      = new ChangePlayerStateToAttack(this, attackCooldwon);
            var ChangePlayerStateToAfterAttack = new ChangePlayerStateToAfterAttack(this, attackCooldwon);
            var ChangePlayerStateToHurt        = new ChangePlayerStateToHurt(this, HurtCooldwon);
            var ChangePlayerStateToAfterHurt   = new ChangePlayerStateToAfterHurt(this, HurtCooldwon);

            var updateByState = new UpdateByState(this);

            updateByState.Add(PlayerState.IDLE, new UpdateAggregation(
                                  gravityChangesVerticalSpeed
                                  , decreaseVelocity
                                  , ChangePlayerStateToFalling
                                  , changePlayerToWalking
                                  , ChangePlayerToJumpingState
                                  , changePlayerStateToCrouch
                                  , changePlayerStateToLookingUp
                                  , ChangePlayerStateToAttack
                                  , ChangePlayerStateToHurt
                                  ));

            updateByState.Add(PlayerState.FALLING, new UpdateAggregation(
                                  gravityChangesVerticalSpeed
                                  , changePlayerToWalking
                                  , changePlayerToIdle
                                  , changePlayerStateToCrouch
                                  , changePlayerStateToLookingUp
                                  , ChangePlayerStateToHurt
                                  ));

            updateByState.Add(PlayerState.WALKING, new UpdateAggregation(
                                  gravityChangesVerticalSpeed
                                  , limitHorizontalVelocity
                                  , changesSpeed
                                  , changePlayerToWalking
                                  , ChangePlayerToJumpingState
                                  , ChangePlayerStateToFalling
                                  , changePlayerToIdle
                                  , changePlayerStateToCrouch
                                  , changePlayerStateToLookingUp
                                  , ChangePlayerStateToAttack
                                  , ChangePlayerStateToHurt
                                  ));

            updateByState.Add(PlayerState.JUMP, new UpdateAggregation(
                                  gravityChangesVerticalSpeed
                                  , ChangePlayerStateToFalling
                                  , ChangePlayerStateToHurt
                                  ));

            updateByState.Add(PlayerState.CROUCH, new UpdateAggregation(
                                  gravityChangesVerticalSpeed
                                  , decreaseVelocity
                                  , changePlayerToWalking
                                  , changePlayerToIdle
                                  , ChangePlayerStateToFalling
                                  , changePlayerStateToLookingUp
                                  , ChangePlayerStateToHurt
                                  ));

            updateByState.Add(PlayerState.LOOKING_UP, new UpdateAggregation(
                                  gravityChangesVerticalSpeed
                                  , decreaseVelocity
                                  , changePlayerToWalking
                                  , changePlayerToIdle
                                  , ChangePlayerStateToFalling
                                  , changePlayerStateToCrouch
                                  , ChangePlayerStateToHurt
                                  ));

            updateByState.Add(PlayerState.ATTACK, new UpdateAggregation(
                                  gravityChangesVerticalSpeed
                                  , decreaseVelocity
                                  , ChangePlayerStateToAfterAttack
                                  , ChangePlayerStateToHurt
                                  ));

            updateByState.Add(PlayerState.AFTER_ATTACK, new UpdateAggregation(
                                  gravityChangesVerticalSpeed
                                  , decreaseVelocity
                                  , changePlayerToIdle
                                  , changePlayerToWalking
                                  , ChangePlayerStateToFalling
                                  , changePlayerStateToCrouch
                                  , ChangePlayerStateToHurt
                                  ));

            updateByState.Add(PlayerState.HURT, new UpdateAggregation(
                                  gravityChangesVerticalSpeed
                                  , decreaseVelocity
                                  , ChangePlayerStateToAfterHurt
                                  ));

            updateByState.Add(PlayerState.AFTER_HURT, new UpdateAggregation(
                                  gravityChangesVerticalSpeed
                                  , decreaseVelocity
                                  , changePlayerToIdle
                                  , changePlayerToWalking
                                  , ChangePlayerStateToFalling
                                  , changePlayerStateToCrouch
                                  , ChangePlayerStateToHurt
                                  ));

            return(updateByState);
        }