Exemplo n.º 1
0
    void Update()
    {
        if (Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.LeftArrow))
        {
            ChangeTeamColor(0, -1f);
        }

        if (Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.RightArrow))
        {
            ChangeTeamColor(0, 1f);
        }

        if (!Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.LeftArrow))
        {
            ChangeTeamColor(1, -1f);
        }

        if (!Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.RightArrow))
        {
            ChangeTeamColor(1, 1f);
        }

        // 1 -> 1
        // 2 -> 5
        // 3 -> 2
        // 4 -> 6
        // 5 -> 3
        // 6 -> 7
        // 7 -> 4
        // 8 -> 8

        for (int i = 0; i < 8; i++)
        {
            int evenTeamNum = WadeUtils.GetOrderedPlayerNum(i);

            if (playerInfos[evenTeamNum].inputTimer > inputTime)
            {
                // Join Game
                if (!playerInfos[evenTeamNum].joined && Input.GetButtonDown("Propel_P" + (i + 1) + WadeUtils.platformName))
                {
                    PlayerJoinGame(evenTeamNum, i);
                    playerInfos[evenTeamNum].inputTimer = 0f;
                }

                // Leave Game
                if (playerInfos[evenTeamNum].joined && Input.GetButtonDown("Leave_P" + (i + 1) + WadeUtils.platformName))
                {
                    PlayerLeaveGame(evenTeamNum);
                    playerInfos[evenTeamNum].inputTimer = 0f;
                }

                // Change Texure
                float scrollInput = Input.GetAxis("Horizontal_P" + (i + 1));
                if (playerInfos[evenTeamNum].joined && Mathf.Abs(scrollInput) > WadeUtils.SMALLNUMBER)
                {
                    PlayerChangeSprite(evenTeamNum, scrollInput);
                    playerInfos[evenTeamNum].inputTimer = 0f;
                }

                // Change Team Color
                float bumperInput = Input.GetAxis("Bumper_P" + (i + 1) + WadeUtils.platformName);
                if (playerInfos[evenTeamNum].joined & Mathf.Abs(bumperInput) > WadeUtils.SMALLNUMBER)
                {
                    ChangeTeamColor(evenTeamNum < 4 ? 0 : 1, bumperInput);
                    playerInfos[evenTeamNum].inputTimer = 0f;
                }
            }

            playerInfos[evenTeamNum].inputTimer += Time.deltaTime;
        }
    }