Example #1
0
    void Update()
    {
        UpdateFrames();

        AttackHandler.AttackInputType inputType = ProcessInput();

        if (inputType != AttackHandler.AttackInputType.None)
        {
            PlayerController.CurrentPlayerAttack = inputType;
        }
    }
Example #2
0
    void HandleInput()
    {
        // Up
        if (UpInputDown){
            moveUp = true;
            moveDown = false;
            playerInputManager.SendInput(PlayerInputManager.InputTypes.Up);
        }
        // Left
        else if (LeftInputDown){
            moveLeft = true;
            moveRight = false;
            if (PlayerFacingRight){
                playerInputManager.SendInput(PlayerInputManager.InputTypes.Right);
            }
            else{
                playerInputManager.SendInput(PlayerInputManager.InputTypes.Left);
            }
        }
        // Down
        else if (DownInputDown){
            moveUp = false;
            moveDown = true;
            playerInputManager.SendInput(PlayerInputManager.InputTypes.Down);
        }
        // Right
        else if (RightInputDown){
            moveLeft = false;
            moveRight = true;
            if (PlayerFacingRight){
                playerInputManager.SendInput(PlayerInputManager.InputTypes.Left);
            }
            else{
                playerInputManager.SendInput(PlayerInputManager.InputTypes.Right);
            }
        }
        // Attack1
        else if (Attack1InputDown){
            /*if (!attacking){
                PlayerAttack attack = attackHandler.GetAttack(AttackHandler.AttackInputType.Attack1);
                if (attack != null){
                    this.StartSafeCoroutine(Attack(attack));
                }
            }*/
            playerInputManager.SendInput(PlayerInputManager.InputTypes.Attack1);
        }
        //Attack2
        else if (Attack2InputDown){
            /*if (!attacking){
                PlayerAttack attack = attackHandler.GetAttack(AttackHandler.AttackInputType.Attack2);
                if (attack != null){
                    this.StartSafeCoroutine(Attack(attack));
                }
            }*/
            playerInputManager.SendInput(PlayerInputManager.InputTypes.Attack2);
        }

        if (!attacking && !damaged && !block){
            if (currentPlayerAttack != AttackHandler.AttackInputType.None){
                var attack = attackHandler.GetAttack(currentPlayerAttack);
                if (attack != null){
                    this.StartSafeCoroutine(Attack(attack));
                }
                currentPlayerAttack = AttackHandler.AttackInputType.None;
            }
        }

        // Help a player block if they are getting stomped
        if (BlockInput){
            this.StartSafeCoroutine(Block());
            playerInputManager.SendInput(PlayerInputManager.InputTypes.Block);
        }

        // Up
        if (UpInputUp){
            moveUp = false;
        }
        // Left
        else if (LeftInputUp){
            moveLeft = false;
        }
        // Down
        else if (DownInputUp){
            moveDown = false;
        }
        // Right
        else if (RightInputUp){
            moveRight = false;
        }
        else if (BlockInputUp){
            block = false;
        }
    }
Example #3
0
    void HandleInput()
    {
        // Up
        if (UpInputDown)
        {
            moveUp   = true;
            moveDown = false;
            playerInputManager.SendInput(PlayerInputManager.InputTypes.Up);
        }
        // Left
        else if (LeftInputDown)
        {
            moveLeft  = true;
            moveRight = false;
            if (PlayerFacingRight)
            {
                playerInputManager.SendInput(PlayerInputManager.InputTypes.Right);
            }
            else
            {
                playerInputManager.SendInput(PlayerInputManager.InputTypes.Left);
            }
        }
        // Down
        else if (DownInputDown)
        {
            moveUp   = false;
            moveDown = true;
            playerInputManager.SendInput(PlayerInputManager.InputTypes.Down);
        }
        // Right
        else if (RightInputDown)
        {
            moveLeft  = false;
            moveRight = true;
            if (PlayerFacingRight)
            {
                playerInputManager.SendInput(PlayerInputManager.InputTypes.Left);
            }
            else
            {
                playerInputManager.SendInput(PlayerInputManager.InputTypes.Right);
            }
        }
        // Attack1
        else if (Attack1InputDown)
        {
            /*if (!attacking){
             *  PlayerAttack attack = attackHandler.GetAttack(AttackHandler.AttackInputType.Attack1);
             *  if (attack != null){
             *      this.StartSafeCoroutine(Attack(attack));
             *  }
             * }*/
            playerInputManager.SendInput(PlayerInputManager.InputTypes.Attack1);
        }
        //Attack2
        else if (Attack2InputDown)
        {
            /*if (!attacking){
             *  PlayerAttack attack = attackHandler.GetAttack(AttackHandler.AttackInputType.Attack2);
             *  if (attack != null){
             *      this.StartSafeCoroutine(Attack(attack));
             *  }
             * }*/
            playerInputManager.SendInput(PlayerInputManager.InputTypes.Attack2);
        }

        if (!attacking && !damaged && !block)
        {
            if (currentPlayerAttack != AttackHandler.AttackInputType.None)
            {
                var attack = attackHandler.GetAttack(currentPlayerAttack);
                if (attack != null)
                {
                    this.StartSafeCoroutine(Attack(attack));
                }
                currentPlayerAttack = AttackHandler.AttackInputType.None;
            }
        }

        // Help a player block if they are getting stomped
        if (BlockInput)
        {
            this.StartSafeCoroutine(Block());
            playerInputManager.SendInput(PlayerInputManager.InputTypes.Block);
        }

        // Up
        if (UpInputUp)
        {
            moveUp = false;
        }
        // Left
        else if (LeftInputUp)
        {
            moveLeft = false;
        }
        // Down
        else if (DownInputUp)
        {
            moveDown = false;
        }
        // Right
        else if (RightInputUp)
        {
            moveRight = false;
        }
        else if (BlockInputUp)
        {
            block = false;
        }
    }