Exemplo n.º 1
0
        public void InputValueMoreThanOneToDiminishingExponential_NegativeValue_OutputOne()
        {
            var inputValue     = -999f;
            var expectedValue  = -1f;
            var mathController = new MathController();

            Assert.AreEqual(expectedValue, mathController.DiminishingExponentialFunction(inputValue));
        }
Exemplo n.º 2
0
    public void DecelerateToRest()
    {
        float inverseHorizontalAmplitude = (1 - Mathf.Abs(joystick.Horizontal));
        float inverseVerticalAmplitude   = (1 - Mathf.Abs(joystick.Vertical));

        float HorizontalVelocity = -myBody.velocity.x;
        float VerticalVelocity   = -myBody.velocity.y;

        float xDecelerationToDefault = mathController.DiminishingExponentialFunction(inverseHorizontalAmplitude) *
                                       mathController.DefaultDecelerationToUse(HorizontalVelocity, baseMaxBrakeSpeed);

        float yDecelerationToDefault = mathController.DiminishingExponentialFunction(inverseVerticalAmplitude) *
                                       mathController.DefaultDecelerationToUse(VerticalVelocity, baseMaxBrakeSpeed);

        Vector2 decelerationToDefaultForce = new Vector2(xDecelerationToDefault, yDecelerationToDefault);

        AddForceToPlayer(decelerationToDefaultForce);
    }
Exemplo n.º 3
0
        public void InputZeroToDiminishingExponential_ZeroValue_OutputZero()
        {
            var mathController = new MathController();
            var inputValue     = 0f;
            var outputValue    = mathController.DiminishingExponentialFunction(inputValue);
            var expectedValue  = 0f;

            Assert.AreEqual(expectedValue, outputValue);
        }
Exemplo n.º 4
0
        public void InputOneToDiminishingExponential_PositiveValue_OutputOne()
        {
            var mathController = new MathController();
            var inputValue     = 1f;
            var outputValue    = mathController.DiminishingExponentialFunction(inputValue);
            var expectedValue  = 1f;

            Assert.AreEqual(expectedValue, outputValue);
        }
Exemplo n.º 5
0
        public void InputHalfToDiminishingExponential_05Value_OutputLessThan05()
        {
            var mathController = new MathController();
            var inputValue     = 0.5f;
            var outputValue    = mathController.DiminishingExponentialFunction(inputValue);
            var expectedValue  = Mathf.Pow(0.5f, 4);

            Assert.AreEqual(expectedValue, outputValue);
        }