Example #1
0
 public void Execute()
 {
     if (InputManager.AButtonDown())
     {
         //TheGameManager.Instance.ChangeState(TheGameManager.Instance.);
     }
 }
Example #2
0
    void Update()
    {
        player.SetDirectionalInput(new Vector2(InputManager.MainHorizontal(playerID), InputManager.MainVertical(playerID)), InputManager.RightBumper(playerID));

        if (InputManager.AButtonDown(playerID))
        {
            player.OnJumpInputDown();
        }
        if (InputManager.AButtonUp(playerID))
        {
            player.OnJumpInputUp();
        }
    }
Example #3
0
    void Update()
    {
        //Rotation

        transform.rotation = Quaternion.Euler(0f, 0f, 0f);


        // Movement

        float axisX = InputManager.MainHorizontal();

        transform.Translate(new Vector3(axisX, 0) * Time.deltaTime * speed);
        if (axisX < 0)
        {
            Player.flipX    = true;
            BodyCol.offset  = new Vector2(-0.1f, 0.05f);
            FeetCol.offset  = new Vector2(-0.15f, -0.5f);
            SwordCol.offset = new Vector2(-0.85f, 0);
        }
        else if (axisX > 0)
        {
            Player.flipX    = false;
            BodyCol.offset  = new Vector2(0.1f, 0.05f);
            FeetCol.offset  = new Vector2(0.15f, -0.5f);
            SwordCol.offset = new Vector2(0.85f, 0);
        }

        if (InputManager.RBButton())
        {
            if (countGranade != 0)
            {
                Instantiate(granada, transform.position + new Vector3(0f, 1f, 0f), Quaternion.identity);
            }
            else
            {
                Invoke("Counter", 18000);
            }
        }
        // Jump

        if (InputManager.AButtonDown() && Onfloor)
        {
            jumpKeyHeld = true;
            GetComponent <Rigidbody2D>().AddForce(Vector3.up * jumpImpulse, ForceMode2D.Impulse);
        }

        if (InputManager.AButtonUp())
        {
            countDown   = 0.3f;
            jumpKeyHeld = false;
        }

        else if (InputManager.AButton())
        {
            countDown -= Time.deltaTime;
            if (jumpKeyHeld && countDown > 0f)
            {
                GetComponent <Rigidbody2D>().AddForce(Vector3.up * 10 * jumpForce, ForceMode2D.Force);
            }
        }

        if (GetComponent <Rigidbody2D>().velocity.y < 0)
        {
            GetComponent <Rigidbody2D>().velocity += Vector2.up * Physics2D.gravity.y * (fall) * Time.deltaTime;
        }
    }
Example #4
0
    private void Update()
    {
        int startingIndex = cButtonIndex;
        int tempIndex     = cButtonIndex;

        if (joined && !justMoved && !ready)
        {
            // Horizontal
            if (InputManager.MainHorizontal(gameManager.players[playerNumber].controllerID) > 0.2f)
            {
                tempIndex += 1;

                if (tempIndex > lockIndex)
                {
                    tempIndex = lockIndex;
                }
                else if (tempIndex >= buttons.Length)
                {
                    tempIndex = buttons.Length - 1;
                }

                justMoved = true;
            }
            else if (InputManager.MainHorizontal(gameManager.players[playerNumber].controllerID) < -0.2f)
            {
                tempIndex -= 1;

                if (tempIndex < 0)
                {
                    tempIndex = 0;
                }
                justMoved = true;
            }

            // Vertical
            else if (InputManager.MainVertical(gameManager.players[playerNumber].controllerID) < -0.2f)
            {
                int temp = tempIndex + 5;

                if (temp > lockIndex)
                {
                    temp = lockIndex;
                }
                if (temp < buttons.Length)
                {
                    tempIndex = temp;
                    justMoved = true;
                }
            }
            else if (InputManager.MainVertical(gameManager.players[playerNumber].controllerID) > 0.2f)
            {
                int temp = tempIndex - 5;

                if (temp >= 0)
                {
                    tempIndex = temp;
                }
                justMoved = true;
            }


            if (justMoved)
            {
                buttons[cButtonIndex].transform.localScale = new Vector3(1, 1, 1);

                if (tempIndex == otherSelector.cButtonIndex)
                {
                    if (tempIndex > startingIndex)
                    {
                        tempIndex = AdjustIndex(tempIndex, true);
                    }
                    else
                    {
                        tempIndex = AdjustIndex(tempIndex, false);
                    }
                }

                cButtonIndex = tempIndex;

                buttons[cButtonIndex].Select();
                buttons[cButtonIndex].transform.localScale = new Vector3(1.35f, 1.35f, 1);

                Invoke("ResetJustMoved", 0.15f);
            }
        }

        if (InputManager.AButtonDown(gameManager.players[playerNumber].controllerID))
        {
            if (!joined)
            {
                buttonTrans.SetActive(true);
                instructions.text = chooseColorTxt;
                joined            = true;
            }
            else
            {
                gameManager.players[playerNumber].Color = colors[cButtonIndex];

                // tell game manager all players are ready
                ready = true;

                if (playerNumber == 1)
                {
                    SceneManager.LoadScene("Versus");
                }
            }
        }
    }