Ejemplo n.º 1
0
        public void Setup()
        {
            // create private container
            container_ = new DiContainer();
            container_.Bind <Reducer>().AsSingle();

            // set up mock settings
            var mockSettings = new Settings {
            };

            container_.Bind <Settings>().FromInstance(mockSettings);

            // stub move action
            mockMoveAction_ = new Action.Move {
                inputVelocity  = Vector2.up.normalized,
                fixedDeltaTime = 1.0f
            };

            // stub turn action
            mockTurnAction_ = new Action.Turn {
                inputRotation  = Vector2.up,
                fixedDeltaTime = 1.0f
            };

            // stub state condition
            mockCharacterState_ = new CharacterState {
                isMoving         = false,
                isTurning        = false,
                moveDistance     = Vector3.zero,
                transformForward = Vector3.forward,
                transformRight   = Vector3.right,
                localRotation    = Quaternion.identity
            };
        }
Ejemplo n.º 2
0
        // TODO: get this to work
        private CharacterState Turn(CharacterState state, Action.Turn action)
        {
            Vector2 rotation = action.inputRotation;
            float   time     = action.fixedDeltaTime;

            // inputLook.x rotates the character around the vertical axis (with + being right)
            // multiply by lookSpeed to increase the speed
            Vector3 horizontalLook = rotation.x * time * Vector3.up * settings_.xLookSpeed;

            state.localRotation *= Quaternion.Euler(horizontalLook);
            state.isTurning      = true;
            state.isMoving       = false;
            // Debug.Log($"in Turn, returning state: {ObjectDumper.Dump(state)}");
            return(state);
        }