Example #1
0
        private PlayerActionStateBase CreateStateByType(PlayerInputType wantedType)
        {
            PlayerActionStateBase wantedStage = null;

            switch (wantedType)
            {
            case PlayerInputType.None:
                wantedStage = gameObject.AddComponent <NoneState>();
                break;

            case PlayerInputType.Move:
                wantedStage = gameObject.AddComponent <MoveState>();
                break;

            case PlayerInputType.Dash:
                wantedStage = gameObject.AddComponent <DashState>();
                break;

            case PlayerInputType.Attack:
                wantedStage = gameObject.AddComponent <AttackState>();
                break;

            case PlayerInputType.Spellcast:
                wantedStage = gameObject.AddComponent <SpellcastState>();
                break;

            case PlayerInputType.Interact:
                wantedStage = gameObject.AddComponent <InteractState>();
                break;
            }

            return(wantedStage);
        }
Example #2
0
 public PlayerInput(GameState state, Paddle target, PlayerInputType key, float distance)
     : base(state)
 {
     Target = target;
       Request = key;
       Distance = Math.Abs(distance);
 }
Example #3
0
 private void SetInput(PlayerInputType input)
 {
     lock (this)
     {
         this._input = input;
     }
 }
Example #4
0
        private void CreateNewState(PlayerInputType type)
        {
            PlayerActionStateBase state;

            state = CreateStateByType(type);
            state.Init(this);
            playerActionStates.Add(state);
        }
Example #5
0
 void Awake()
 {
     Instance = this;
     if (PlayerPrefs.HasKey(PrefKey_InputType))
     {
         InputType = (PlayerInputType)PlayerPrefs.GetInt(PrefKey_InputType);
     }
 }
    private void OnPlayerInputTypeUpdated(PlayerInputType _playerInputType)
    {
        bool  _active      = _playerInputType == targetPlayerInputType;
        Color _targetColor = _active ? activeColor : inactiveColor;

        Button.targetGraphic.color         = _targetColor;
        Button.targetGraphic.raycastTarget = !_active;
        SetActiveState(_active);
    }
Example #7
0
    private void LogKeyPress(PlayerInputType inputType, bool pressedDown)
    {
        var inputEntry = new PlayerInputEntry
        {
            InputType      = inputType,
            TimeOffset     = GameManager.Instance.GetTimeSinceLevelStart(),
            WasPressedDown = pressedDown
        };

        _playerInputs.Add(inputEntry);
    }
Example #8
0
        protected bool AddTargetState(PlayerInputType targetState)
        {
            bool canAdd = !possibleStates.Contains(targetState);

            if (canAdd)
            {
                possibleStates.Add(targetState);
            }

            return(canAdd);
        }
Example #9
0
    public void KeyUp(PlayerInputType inputType)
    {
        switch (inputType)
        {
        case PlayerInputType.Charge:
            TargetCharacter.CancelCharge();
            break;

        default:
            break;
        }
    }
Example #10
0
 public void SetControlType(PlayerInputType type)
 {
     InputHandler.Instance.SetInputType(type);
     ControlsText.text = "Controls:\n";
     if (InputHandler.Instance.InputType == PlayerInputType.Keyboard)
     {
         ControlsText.text += " keyboard";
     }
     else
     {
         ControlsText.text += " keyboard & mouse";
     }
 }
Example #11
0
        private void DispatchPlayerInput(PlayerInputType playerInputType, InputState inputState)
        {
            Log("KeyboardInput.DispatchPlayerInput -- " + playerInputType + " : " + inputState);

            if (PlayerInputEvent != null)
            {
                playerInputArgs.playerInputType = playerInputType;

                playerInputArgs.inputState = inputState;

                PlayerInputEvent(this, playerInputArgs);
            }
        }
Example #12
0
        private PlayerActionStateBase GetStateByType(PlayerInputType nextMoveStageType)
        {
            PlayerActionStateBase nextState = null;

            foreach (PlayerActionStateBase state in playerActionStates)
            {
                if (state.Type == nextMoveStageType)
                {
                    nextState = state;
                    break;
                }
            }

            return(nextState);
        }
    private void StartInput(PlayerInputType _playerInputType)
    {
        PlayerBaseInput _playerInputBase = playerInputs.Find(x => x.PlayerInputType == _playerInputType);

        if (_playerInputBase == null)
        {
            Debug.LogError("No PlayerInput of type " + _playerInputType, gameObject);
            return;
        }

        StopCurrentInput();

        currentPlayerInputBase = _playerInputBase;
        currentPlayerInputBase.TargetPositionUpdatedEvent += OnTargetPositionUpdated;
        currentPlayerInputBase.Activate();
    }
Example #14
0
    public bool GetButtonInput(PlayerInputType playerInputType)
    {
        bool returnValue = false;

        switch (playerInputType)
        {
        case PlayerInputType.SECONDARY_BUTTON:
            device.TryGetFeatureValue(UnityEngine.XR.CommonUsages.secondaryButton, out returnValue);
            break;

        default:
            Debug.Log("Player input type not valid. Try using GetTriggerInput() instread?");
            break;
        }
        return(returnValue);
    }
Example #15
0
    public static MoveType TranslateInput(PlayerInputType i)
    {
        switch (i)
        {
        case PlayerInputType.Left: return(MoveType.Left);

        case PlayerInputType.Right: return(MoveType.Right);

        case PlayerInputType.Forward: return(MoveType.Forward);

        case PlayerInputType.Backward: return(MoveType.Backward);

        case PlayerInputType.Up: return(MoveType.Up);

        default: return(MoveType.Down);
        }
    }
        /*
         * public override void DaFixedUpdate()
         * {
         *  actionStateManager.PlayerRb.velocity = dashDir * dashVel * Time.fixedDeltaTime;
         * }
         */

        public override void HandleInput()
        {
            inputDir = mover.InputDir();
            if (Input.GetButtonDown(GlobalVariables.ATTACK))
            {
                nextState = PlayerInputType.Attack;
            }
            else if (Input.GetButtonDown(GlobalVariables.SPELLCAST))
            {
                nextState = PlayerInputType.Spellcast;
            }
            else if (inputDir.magnitude != 0f)
            {
                nextState = PlayerInputType.Move;
            }
            else if (inputDir.magnitude == 0f)
            {
                nextState = PlayerInputType.None;
            }
        }
Example #17
0
    public void KeyDown(PlayerInputType inputType)
    {
        if (TargetCharacter.IsDead == true)
        {
            return;
        }

        switch (inputType)
        {
        case PlayerInputType.Launch:
            TargetCharacter.DoLaunch();
            break;

        case PlayerInputType.Dodge:
            TargetCharacter.DoDodge();
            break;

        case PlayerInputType.Skill:
            TargetCharacter.DoUseSkill();
            break;
        }
    }
        public override void TransitionIn()
        {
            nextState = PlayerInputType.None;
            GameMan.Instance.CharController.CanMoveToDash = false;
            GameMan.Instance.CharController.PlayerAnim.SetInteger(GlobalVariables.UNIQUE_ANIM_VALUE, GlobalVariables.PLAYER_ANIM_DASH);
            //GetComponent<IHealth>().IsImmortal = true;
            dashDir = mover.GetCorrectMoverDir().normalized;
            if (dashDir == Vector3.zero)
            {
                dashDir = transform.forward;
            }

            particleManager.DashParticles.Play();
            Settings.Instance.Audio.PlayEffect(audioSource, Data.AudioContainer.PlayerSFX.Dash, 5f); // 1.5f if using Dash2, 5f if using DashEdited

            if (Dashed != null)
            {
                Dashed(dashCoolDownTime + dashHoldTime);
            }

            StartCoroutine(DashHoldTimer());
        }
        public virtual void BindWithActions(PlayerInputType type)
        {
            switch (type) {
                case PlayerInputType.MOUSE_AND_KEYBOARD:
                    _primaryLeft.AddDefaultBinding(Key.A);
                    _primaryRight.AddDefaultBinding(Key.D);
                    _primaryUp.AddDefaultBinding(Key.W);
                    _primaryDown.AddDefaultBinding(Key.S);
                    break;

                case PlayerInputType.CONTROLLER:
                    _primaryLeft.AddDefaultBinding(InputControlType.LeftStickLeft);
                    _primaryRight.AddDefaultBinding(InputControlType.LeftStickRight);
                    _primaryUp.AddDefaultBinding(InputControlType.LeftStickUp);
                    _primaryDown.AddDefaultBinding(InputControlType.LeftStickDown);

                    _secondaryLeft.AddDefaultBinding(InputControlType.RightStickLeft);
                    _secondaryRight.AddDefaultBinding(InputControlType.RightStickRight);
                    _secondaryUp.AddDefaultBinding(InputControlType.RightStickUp);
                    _secondaryDown.AddDefaultBinding(InputControlType.RightStickDown);
                    break;
            }
        }
Example #20
0
        public bool ChangeState(PlayerInputType nextStateType)
        {
            // Let's check first if we can transition from current state to the target state or not
            if (!CurrentState.IsValidTargetState(nextStateType))
            {
                return(false);
            }

            // Fetch the next state object
            PlayerActionStateBase nextState = GetStateByType(nextStateType);

            if (nextState == null)
            {
                return(false);
            }

            CurrentState.TransitionOut();
            PreviousState = CurrentState;
            CurrentState  = nextState;
            CurrentState.TransitionIn();

            return(true);
        }
Example #21
0
        public virtual void BindWithActions(PlayerInputType type)
        {
            switch (type)
            {
            case PlayerInputType.MOUSE_AND_KEYBOARD:
                _primaryLeft.AddDefaultBinding(Key.A);
                _primaryRight.AddDefaultBinding(Key.D);
                _primaryUp.AddDefaultBinding(Key.W);
                _primaryDown.AddDefaultBinding(Key.S);
                break;

            case PlayerInputType.CONTROLLER:
                _primaryLeft.AddDefaultBinding(InputControlType.LeftStickLeft);
                _primaryRight.AddDefaultBinding(InputControlType.LeftStickRight);
                _primaryUp.AddDefaultBinding(InputControlType.LeftStickUp);
                _primaryDown.AddDefaultBinding(InputControlType.LeftStickDown);

                _secondaryLeft.AddDefaultBinding(InputControlType.RightStickLeft);
                _secondaryRight.AddDefaultBinding(InputControlType.RightStickRight);
                _secondaryUp.AddDefaultBinding(InputControlType.RightStickUp);
                _secondaryDown.AddDefaultBinding(InputControlType.RightStickDown);
                break;
            }
        }
Example #22
0
 public void ProcessKeyUp(PlayerInputType inputType)
 {
     TargetPlayer.KeyUp(inputType);
 }
Example #23
0
 public void BindAxis(PlayerInputType type, string axisName)
 {
     bindedAxes.Add(type, axisName);
 }
Example #24
0
 // 네트워크 상에서 상대 플레이어의 Input을 처리할 때?
 public void ProcesKey(PlayerInputType type)
 {
 }
Example #25
0
 public void BindKey(PlayerInputType type, string keyName)
 {
     bindedKeys.Add(type, keyName);
 }
Example #26
0
 public void ProcessAxis(PlayerInputType type)
 {
 }
Example #27
0
 public bool IsValidTargetState(PlayerInputType targetState)
 {
     return(possibleStates.Contains(targetState));
 }
Example #28
0
 public void SetInputType(PlayerInputType newType)
 {
     InputType = newType;
     PlayerPrefs.SetInt(PrefKey_InputType, (int)newType);
 }
Example #29
0
 protected bool RemoveTargetState(PlayerInputType targetState)
 {
     return(possibleStates.Remove(targetState));
 }