Пример #1
0
    void Update()
    {
        var axisCharacter = new Vector2();

        axisCharacter.x = Input.GetAxisRaw("CharacterHorizontal");
        axisCharacter.y = Input.GetAxisRaw("CharacterVertical");

        _directionCharacter = _playerCursor.GetDirection(axisCharacter);
    }
Пример #2
0
            public void Update(Vector2 newInput)
            {
                LastRawInput    = CurrentRawInput;
                CurrentRawInput = newInput;

                SmashFramesRemaining = Mathf.Max(0, SmashFramesRemaining - 1);

                var lastInput    = InputUtil.EnforceDeadZone(LastRawInput);
                var currentInput = InputUtil.EnforceDeadZone(CurrentRawInput);

                if (InputUtil.OutsideDeadZone(lastInput))
                {
                    SmashValue = Vector2.zero;
                    return;
                }

                var diff = currentInput - lastInput;

                diff = InputUtil.EnforceDeadZone(diff, InputConfig.SmashThreshold);
                diff = InputUtil.MaxComponent(diff);

                if (SmashFramesRemaining > 0)
                {
                    // Has recently smashed, needs to be in a different direction to change
                    var currentDirection = DirectionalInput.GetDirection(SmashValue);
                    var newDirection     = DirectionalInput.GetDirection(diff);
                    if (currentDirection != newDirection)
                    {
                        RefreshSmashValue(diff);
                    }
                }
                else if (!InputUtil.OutsideDeadZone(diff, InputConfig.SmashThreshold))
                {
                    SmashValue = Vector2.zero;
                }
                else
                {
                    RefreshSmashValue(diff);
                }
            }