Ejemplo n.º 1
0
        private void Start()
        {
            const string driverName       = "testDriver";
            const string boolDriverName   = "boolTestDriver";
            const string floatDriverName  = "floatTestDriver";
            const int    driverValue      = 1;
            const bool   boolDriverValue  = true;
            const float  floatDriverValue = 17.435f;

            Reanimator.Set(driverName, driverValue);
            Reanimator.Set(floatDriverName, floatDriverValue);
            Reanimator.Set(boolDriverName, boolDriverValue);

            bool willChange      = Reanimator.WillChange(driverName, driverValue);
            bool boolWillChange  = Reanimator.WillChange(boolDriverName);
            bool floatWillChange = Reanimator.WillChange(floatDriverName);

            Reanimator.ForceRerender();

            int   receivedValue      = Reanimator.State.Get(driverName);
            bool  receivedBoolValue  = Reanimator.State.GetBool(boolDriverName);
            float receivedFloatValue = Reanimator.State.GetFloat(floatDriverName);

            IsTestFinished = true;
            Assert.IsTrue(willChange);
            Assert.IsTrue(boolWillChange);
            Assert.IsTrue(floatWillChange);
            Assert.AreEqual(driverValue, receivedValue);
            Assert.AreEqual(boolDriverValue, receivedBoolValue);
            Assert.AreEqual(floatDriverValue, receivedFloatValue, 0.00001);
        }
Ejemplo n.º 2
0
        private void Update()
        {
            var  velocity = _controller.Velocity;
            bool isMoving = Mathf.Abs(_controller.DesiredDirection.x) > 0 && Mathf.Abs(velocity.x) > 0.01f;

            int   hitDirection;
            float speed             = velocity.magnitude;
            var   velocityDirection = velocity / speed;

            if (speed < 0.1f || velocityDirection.y < -0.65f)
            {
                hitDirection = 2;
            }
            else if (velocityDirection.y > 0.65f)
            {
                hitDirection = 1;
            }
            else
            {
                hitDirection = 0;
            }

            _reanimator.Flip = _controller.FacingDirection < 0;
            _reanimator.Set(Drivers.State, (int)_controller.State);
            _reanimator.Set(Drivers.IsGrounded, _controller.IsGrounded);
            _reanimator.Set(Drivers.IsMoving, isMoving);
            _reanimator.Set(Drivers.JumpDirection, velocity.y > 0);
            _reanimator.Set(Drivers.ShouldFlip, _controller.IsJumping && !_controller.IsFirstJump);
            _reanimator.Set(Drivers.FlipCompletion, _controller.JumpCompletion);
            _reanimator.Set(Drivers.AttackCompletion, _controller.AttackCompletion);
            _reanimator.Set(Drivers.HitDirection, hitDirection);

            bool didLandInThisFrame = _reanimator.WillChange(Drivers.IsGrounded, true);
            bool didDashInThisFrame = _reanimator.WillChange(Drivers.State, (int)JeffState.Attack);

            if (didLandInThisFrame)
            {
                PlayStepSound();
            }

            if (didLandInThisFrame || didDashInThisFrame)
            {
                _reanimator.ForceRerender();
            }
        }