예제 #1
0
    private bool P3Playing, P4Playing;                                                                      // Determine if these players are playing

    // Use this for initialization
    void Start()
    {
        gameSettings = FindObjectOfType <InitializeStorage> ();

        labelFontSize                  = new GUIStyle();
        labelFontSize.fontSize         = 30;
        labelFontSize.normal.textColor = Color.white;

        xRightHealthOffset = -0.62f;
        xLeftHealthOffset  = -0.32f;
        yHealthOffset      = 2.14f;
        xRightTagOffset    = -0.75f;
        xLeftTagOffset     = -0.43f;
        yTagOffset         = 3.3f; // These are just where it looks good, they can be modified

        // Determine if P3 and P4 are playing
        InitializeStorage settings = (InitializeStorage)GameObject.Find("VariableStorage").GetComponent(typeof(InitializeStorage));

        if ((int)settings.P3Controller == 0)
        {
            P3Playing = false;
        }
        else
        {
            P3Playing = true;
        }
        if ((int)settings.P4Controller == 0)
        {
            P4Playing = false;
        }
        else
        {
            P4Playing = true;
        }
    }
예제 #2
0
    /*******\
    * START *
    \*******/
    void Start()
    {
        int buttonHeight = (int)(Screen.height * 0.15);
        int buttonWidth  = (int)((float)ControllerSlotTexture.width * ((float)buttonHeight / (float)ControllerSlotTexture.height));        // Set the width based on the height ratio
        int vertSpacing  = (int)(Screen.height * 0.08);
        int horzSpacing  = (int)((Screen.width - (buttonWidth * 4)) / 6);

        //Initialize the rect positions
        P1LabelRect = new Rect(horzSpacing, vertSpacing, buttonWidth, buttonHeight);
        P2LabelRect = new Rect(horzSpacing, vertSpacing * 2 + buttonHeight, buttonWidth, buttonHeight);
        P3LabelRect = new Rect(horzSpacing, vertSpacing * 3 + buttonHeight * 2, buttonWidth, buttonHeight);
        P4LabelRect = new Rect(horzSpacing, vertSpacing * 4 + buttonHeight * 3, buttonWidth, buttonHeight);

        P1SlotRect = new Rect(horzSpacing * 2 + buttonWidth, vertSpacing, buttonWidth, buttonHeight);
        P2SlotRect = new Rect(horzSpacing * 2 + buttonWidth, vertSpacing * 2 + buttonHeight, buttonWidth, buttonHeight);
        P3SlotRect = new Rect(horzSpacing * 2 + buttonWidth, vertSpacing * 3 + buttonHeight * 2, buttonWidth, buttonHeight);
        P4SlotRect = new Rect(horzSpacing * 2 + buttonWidth, vertSpacing * 4 + buttonHeight * 3, buttonWidth, buttonHeight);

        KB1SlotRect    = new Rect(horzSpacing * 4 + buttonWidth * 2, vertSpacing, buttonWidth, buttonHeight);
        C1SlotRect     = new Rect(horzSpacing * 4 + buttonWidth * 2, vertSpacing * 2 + buttonHeight, buttonWidth, buttonHeight);
        C3SlotRect     = new Rect(horzSpacing * 4 + buttonWidth * 2, vertSpacing * 3 + buttonHeight * 2, buttonWidth, buttonHeight);
        SaveButtonRect = new Rect(horzSpacing * 4 + buttonWidth * 2, vertSpacing * 4 + buttonHeight * 3, buttonWidth, buttonHeight);

        KB2SlotRect      = new Rect(horzSpacing * 5 + buttonWidth * 3, vertSpacing, buttonWidth, buttonHeight);
        C2SlotRect       = new Rect(horzSpacing * 5 + buttonWidth * 3, vertSpacing * 2 + buttonHeight, buttonWidth, buttonHeight);
        C4SlotRect       = new Rect(horzSpacing * 5 + buttonWidth * 3, vertSpacing * 3 + buttonHeight * 2, buttonWidth, buttonHeight);
        CancelButtonRect = new Rect(horzSpacing * 5 + buttonWidth * 3, vertSpacing * 4 + buttonHeight * 3, buttonWidth, buttonHeight);

        int errorHeight = Screen.height / 2;
        int errorWidth  = (int)((float)Error1.width * ((float)errorHeight / (float)Error1.height));

        ErrorRect = new Rect((Screen.width - errorWidth) / 2, (Screen.height - errorHeight) / 2, errorWidth, errorHeight);


        // Initialize the slot states by getting the storage object
        InitializeStorage storage = (InitializeStorage)GameObject.Find("VariableStorage").GetComponent(typeof(InitializeStorage));

        InitializeStorage.ControllerSelection storedP1Controller = storage.P1Controller;
        InitializeStorage.ControllerSelection storedP2Controller = storage.P2Controller;
        InitializeStorage.ControllerSelection storedP3Controller = storage.P3Controller;
        InitializeStorage.ControllerSelection storedP4Controller = storage.P4Controller;

        Slot1Selection = (ControllerSelectionState)((int)storedP1Controller);
        Slot2Selection = (ControllerSelectionState)((int)storedP2Controller);
        Slot3Selection = (ControllerSelectionState)((int)storedP3Controller);
        Slot4Selection = (ControllerSelectionState)((int)storedP4Controller);

        numOfControllers = storage.numOfControllers;

        // Initialize the what the player is currently selecting
        CurrentlySelecting = SelectingState.None;

        errorState = ErrorState.None;
    }
    // Use this for initialization
    void Start()
    {
        //Find the options.
        gameSettings = FindObjectOfType <InitializeStorage>();

        //Spawn the corresponding player.
        if (playerNum == 1 && gameSettings.P1Controller != 0)
        {
            Spawn(gameSettings.P1Character, gameSettings.P1Controller);
        }
        else if (playerNum == 2 && gameSettings.P2Controller != 0)
        {
            Spawn(gameSettings.P2Character, gameSettings.P2Controller);
        }
        else if (playerNum == 3 && gameSettings.P3Controller != 0)
        {
            Spawn(gameSettings.P3Character, gameSettings.P3Controller);
        }
        else if (playerNum == 4 && gameSettings.P4Controller != 0)
        {
            Spawn(gameSettings.P4Character, gameSettings.P4Controller);
        }
    }
예제 #4
0
    /*******\
    * START *
    \*******/
    void Start()
    {
        // Initialize the buttons
        int buttonHeight         = (int)(0.15 * Screen.height);
        int buttonWidth          = (int)((float)playButtonTexture.width * ((float)buttonHeight / (float)playButtonTexture.height)); //Adjust the width to the height
        int vertSpacing          = (int)(0.08 * Screen.height);
        int buttonXlocation      = ((int)(0.3 * Screen.width)) - buttonWidth;
        int buttonXlocationHover = ((int)(0.4 * Screen.width)) - buttonWidth;

        playRect     = new Rect(buttonXlocation, vertSpacing, buttonWidth, buttonHeight);
        controlsRect = new Rect(buttonXlocation, 2 * vertSpacing + buttonHeight, buttonWidth, buttonHeight);
        creditsRect  = new Rect(buttonXlocation, 3 * vertSpacing + 2 * buttonHeight, buttonWidth, buttonHeight);
        exitRect     = new Rect(buttonXlocation, 4 * vertSpacing + 3 * buttonHeight, buttonWidth, buttonHeight);

        playRectHover     = new Rect(buttonXlocationHover, vertSpacing, buttonWidth, buttonHeight);
        controlsRectHover = new Rect(buttonXlocationHover, 2 * vertSpacing + buttonHeight, buttonWidth, buttonHeight);
        creditsRectHover  = new Rect(buttonXlocationHover, 3 * vertSpacing + 2 * buttonHeight, buttonWidth, buttonHeight);
        exitRectHover     = new Rect(buttonXlocationHover, 4 * vertSpacing + 3 * buttonHeight, buttonWidth, buttonHeight);

        // Set the flags
        playHover     = false;
        controlsHover = false;
        creditsHover  = false;
        exitHover     = false;

        mouseActive       = false;
        lastMousePosition = Input.mousePosition;
        controllerState   = MenuState.Play;

        canMove = true;

        // Initialize the logo location
        int logoWidth     = (int)(0.35 * Screen.width);
        int logoHeight    = (int)((float)logoTexture.height * ((float)logoWidth / (float)logoTexture.width));
        int logoXposition = (int)(0.6 * Screen.width);

        logoRect = new Rect(logoXposition, vertSpacing, logoWidth, logoHeight);



        // Initialize the controller layouts
        InitializeStorage settings = (InitializeStorage)GameObject.Find("VariableStorage").GetComponent(typeof(InitializeStorage));

        switch ((int)settings.P1Controller)
        {
        case 1:
            P1Enter = KeyCode.Space;
            P1yAxis = "Keyboard1Y";
            break;

        case 2:
            P1Enter = KeyCode.Return;
            P1yAxis = "Keyboard2Y";
            break;

        case 3:
            P1Enter = KeyCode.Joystick1Button0;
            P1yAxis = "LeftJoystick1Y";
            break;

        case 4:
            P1Enter = KeyCode.Joystick2Button0;
            P1yAxis = "LeftJoystick2Y";
            break;

        case 5:
            P1Enter = KeyCode.Joystick3Button0;
            P1yAxis = "LeftJoystick3Y";
            break;

        case 6:
            P1Enter = KeyCode.Joystick4Button0;
            P1yAxis = "LeftJoystick4Y";
            break;
        }

        switch ((int)settings.P2Controller)
        {
        case 1:
            P2Enter = KeyCode.Space;
            P2yAxis = "Keyboard1Y";
            break;

        case 2:
            P2Enter = KeyCode.Return;
            P2yAxis = "Keyboard2Y";
            break;

        case 3:
            P2Enter = KeyCode.Joystick1Button0;
            P2yAxis = "LeftJoystick1Y";
            break;

        case 4:
            P2Enter = KeyCode.Joystick2Button0;
            P2yAxis = "LeftJoystick2Y";
            break;

        case 5:
            P2Enter = KeyCode.Joystick3Button0;
            P2yAxis = "LeftJoystick3Y";
            break;

        case 6:
            P2Enter = KeyCode.Joystick4Button0;
            P2yAxis = "LeftJoystick4Y";
            break;
        }

        P3Playing = true;
        switch ((int)settings.P3Controller)
        {
        case 0:
            P3Playing = false;
            break;

        case 1:
            P3Enter = KeyCode.Space;
            P3yAxis = "Keyboard1Y";
            break;

        case 2:
            P3Enter = KeyCode.Return;
            P3yAxis = "Keyboard2Y";
            break;

        case 3:
            P3Enter = KeyCode.Joystick1Button0;
            P3yAxis = "LeftJoystick1Y";
            break;

        case 4:
            P3Enter = KeyCode.Joystick2Button0;
            P3yAxis = "LeftJoystick2Y";
            break;

        case 5:
            P3Enter = KeyCode.Joystick3Button0;
            P3yAxis = "LeftJoystick3Y";
            break;

        case 6:
            P3Enter = KeyCode.Joystick4Button0;
            P3yAxis = "LeftJoystick4Y";
            break;
        }

        P4Playing = true;
        switch ((int)settings.P4Controller)
        {
        case 0:
            P4Playing = false;
            break;

        case 1:
            P4Enter = KeyCode.Space;
            P4yAxis = "Keyboard1Y";
            break;

        case 2:
            P4Enter = KeyCode.Return;
            P4yAxis = "Keyboard2Y";
            break;

        case 3:
            P4Enter = KeyCode.Joystick1Button0;
            P4yAxis = "LeftJoystick1Y";
            break;

        case 4:
            P4Enter = KeyCode.Joystick2Button0;
            P4yAxis = "LeftJoystick2Y";
            break;

        case 5:
            P4Enter = KeyCode.Joystick3Button0;
            P4yAxis = "LeftJoystick3Y";
            break;

        case 6:
            P4Enter = KeyCode.Joystick4Button0;
            P4yAxis = "LeftJoystick4Y";
            break;
        }
    }
    /*******\
    * START *
    \*******/
    void Start()
    {
        // Calculate the button sizes and spacing depending on the screen size
        int buttonWidth  = Screen.width / 4;
        int buttonHeight = (int)(buttonWidth * 0.7125);          // The height is multiplied by 0.7125 to match the aspect ratio of the button to 16:9
        int vertSpacing  = (Screen.height - 2 * buttonHeight) / 3;
        int horzSpacing  = (Screen.width - 3 * buttonWidth) / 4;

        // Initialize the buttons' rectangles
        TradRect         = new Rect(buttonWidth + 2 * horzSpacing, vertSpacing, buttonWidth, buttonHeight);
        BtleRect         = new Rect(2 * buttonWidth + 3 * horzSpacing, vertSpacing, buttonWidth, buttonHeight);
        LandRect         = new Rect(buttonWidth + 2 * horzSpacing, buttonHeight + 2 * vertSpacing, buttonWidth, buttonHeight);
        LavaRect         = new Rect(2 * buttonWidth + 3 * horzSpacing, buttonHeight + 2 * vertSpacing, buttonWidth, buttonHeight);
        RandRect         = new Rect(horzSpacing, buttonHeight + 2 * vertSpacing, buttonWidth, buttonHeight);
        MapSelectionRect = new Rect(horzSpacing, vertSpacing, buttonWidth, buttonHeight);

        // Calculate the token sizes based on the button sizes
        double tokenWidth  = (double)P1TokenTexture.width * ((double)buttonWidth / (double)TradSelectionButton.width);
        double tokenHeight = (double)P1TokenTexture.height * ((double)buttonHeight / (double)TradSelectionButton.height);
        int    xOffset1    = 1;
        int    xOffset2    = (int)(buttonWidth - tokenWidth);
        int    yOffset     = (int)(buttonHeight - tokenHeight);

        // Inititalize the tokens' rectangles
        P1TokenRect_Trad = new Rect((buttonWidth + 2 * horzSpacing) + xOffset1, vertSpacing, (int)tokenWidth, (int)tokenHeight);
        P1TokenRect_Btle = new Rect((2 * buttonWidth + 3 * horzSpacing) + xOffset1, vertSpacing, (int)tokenWidth, (int)tokenHeight);
        P1TokenRect_Land = new Rect((buttonWidth + 2 * horzSpacing) + xOffset1, buttonHeight + 2 * vertSpacing, (int)tokenWidth, (int)tokenHeight);
        P1TokenRect_Lava = new Rect((2 * buttonWidth + 3 * horzSpacing) + xOffset1, buttonHeight + 2 * vertSpacing, (int)tokenWidth, (int)tokenHeight);
        P1TokenRect_Rand = new Rect(horzSpacing + xOffset1, buttonHeight + 2 * vertSpacing, (int)tokenWidth, (int)tokenHeight);

        P2TokenRect_Trad = new Rect((buttonWidth + 2 * horzSpacing) + xOffset2, vertSpacing, (int)tokenWidth, (int)tokenHeight);
        P2TokenRect_Btle = new Rect((2 * buttonWidth + 3 * horzSpacing) + xOffset2, vertSpacing, (int)tokenWidth, (int)tokenHeight);
        P2TokenRect_Land = new Rect((buttonWidth + 2 * horzSpacing) + xOffset2, buttonHeight + 2 * vertSpacing, (int)tokenWidth, (int)tokenHeight);
        P2TokenRect_Lava = new Rect((2 * buttonWidth + 3 * horzSpacing) + xOffset2, buttonHeight + 2 * vertSpacing, (int)tokenWidth, (int)tokenHeight);
        P2TokenRect_Rand = new Rect(horzSpacing + xOffset2, buttonHeight + 2 * vertSpacing, (int)tokenWidth, (int)tokenHeight);

        P3TokenRect_Trad = new Rect((buttonWidth + 2 * horzSpacing) + xOffset1, vertSpacing + yOffset, (int)tokenWidth, (int)tokenHeight);
        P3TokenRect_Btle = new Rect((2 * buttonWidth + 3 * horzSpacing) + xOffset1, vertSpacing + yOffset, (int)tokenWidth, (int)tokenHeight);
        P3TokenRect_Land = new Rect((buttonWidth + 2 * horzSpacing) + xOffset1, buttonHeight + 2 * vertSpacing + yOffset, (int)tokenWidth, (int)tokenHeight);
        P3TokenRect_Lava = new Rect((2 * buttonWidth + 3 * horzSpacing) + xOffset1, buttonHeight + 2 * vertSpacing + yOffset, (int)tokenWidth, (int)tokenHeight);
        P3TokenRect_Rand = new Rect(horzSpacing + xOffset1, buttonHeight + 2 * vertSpacing + yOffset, (int)tokenWidth, (int)tokenHeight);

        P4TokenRect_Trad = new Rect((buttonWidth + 2 * horzSpacing) + xOffset2, vertSpacing + yOffset, (int)tokenWidth, (int)tokenHeight);
        P4TokenRect_Btle = new Rect((2 * buttonWidth + 3 * horzSpacing) + xOffset2, vertSpacing + yOffset, (int)tokenWidth, (int)tokenHeight);
        P4TokenRect_Land = new Rect((buttonWidth + 2 * horzSpacing) + xOffset2, buttonHeight + 2 * vertSpacing + yOffset, (int)tokenWidth, (int)tokenHeight);
        P4TokenRect_Lava = new Rect((2 * buttonWidth + 3 * horzSpacing) + xOffset2, buttonHeight + 2 * vertSpacing + yOffset, (int)tokenWidth, (int)tokenHeight);
        P4TokenRect_Rand = new Rect(horzSpacing + xOffset2, buttonHeight + 2 * vertSpacing + yOffset, (int)tokenWidth, (int)tokenHeight);

        // Initialize the player selection
        P1State = MapState.Trad;
        P2State = MapState.Trad;
        P3State = MapState.Trad;
        P4State = MapState.Trad;

        // Initialize whether the players have selected to false
        P1Selected = false;
        P2Selected = false;
        P3Selected = false;
        P4Selected = false;

        // Initialize whether the players can move their tokens
        P1canMove = true;
        P2canMove = true;
        P3canMove = true;
        P4canMove = true;


        // Initialize the controller layouts
        InitializeStorage settings = (InitializeStorage)GameObject.Find("VariableStorage").GetComponent(typeof(InitializeStorage));

        switch ((int)settings.P1Controller)
        {
        case 1:
            P1Enter = KeyCode.Space;
            P1Back  = KeyCode.Escape;
            P1xAxis = "Keyboard1X";
            P1yAxis = "Keyboard1Y";
            break;

        case 2:
            P1Enter = KeyCode.Return;
            P1Back  = KeyCode.Escape;
            P1xAxis = "Keyboard2X";
            P1yAxis = "Keyboard2Y";
            break;

        case 3:
            P1Enter = KeyCode.Joystick1Button0;
            P1Back  = KeyCode.Joystick1Button1;
            P1xAxis = "LeftJoystick1X";
            P1yAxis = "LeftJoystick1Y";
            break;

        case 4:
            P1Enter = KeyCode.Joystick2Button0;
            P1Back  = KeyCode.Joystick2Button1;
            P1xAxis = "LeftJoystick2X";
            P1yAxis = "LeftJoystick2Y";
            break;

        case 5:
            P1Enter = KeyCode.Joystick3Button0;
            P1Back  = KeyCode.Joystick3Button1;
            P1xAxis = "LeftJoystick3X";
            P1yAxis = "LeftJoystick3Y";
            break;

        case 6:
            P1Enter = KeyCode.Joystick4Button0;
            P1Back  = KeyCode.Joystick4Button1;
            P1xAxis = "LeftJoystick4X";
            P1yAxis = "LeftJoystick4Y";
            break;
        }

        switch ((int)settings.P2Controller)
        {
        case 1:
            P2Enter = KeyCode.Space;
            P2Back  = KeyCode.Escape;
            P2xAxis = "Keyboard1X";
            P2yAxis = "Keyboard1Y";
            break;

        case 2:
            P2Enter = KeyCode.Return;
            P2Back  = KeyCode.Escape;
            P2xAxis = "Keyboard2X";
            P2yAxis = "Keyboard2Y";
            break;

        case 3:
            P2Enter = KeyCode.Joystick1Button0;
            P2Back  = KeyCode.Joystick1Button1;
            P2xAxis = "LeftJoystick1X";
            P2yAxis = "LeftJoystick1Y";
            break;

        case 4:
            P2Enter = KeyCode.Joystick2Button0;
            P2Back  = KeyCode.Joystick2Button1;
            P2xAxis = "LeftJoystick2X";
            P2yAxis = "LeftJoystick2Y";
            break;

        case 5:
            P2Enter = KeyCode.Joystick3Button0;
            P2Back  = KeyCode.Joystick3Button1;
            P2xAxis = "LeftJoystick3X";
            P2yAxis = "LeftJoystick3Y";
            break;

        case 6:
            P2Enter = KeyCode.Joystick4Button0;
            P2Back  = KeyCode.Joystick4Button1;
            P2xAxis = "LeftJoystick4X";
            P2yAxis = "LeftJoystick4Y";
            break;
        }

        P3Playing = true;
        switch ((int)settings.P3Controller)
        {
        case 0:
            P3Playing = false;
            break;

        case 1:
            P3Enter = KeyCode.Space;
            P3Back  = KeyCode.Escape;
            P3xAxis = "Keyboard1X";
            P3yAxis = "Keyboard1Y";
            break;

        case 2:
            P3Enter = KeyCode.Return;
            P3Back  = KeyCode.Escape;
            P3xAxis = "Keyboard2X";
            P3yAxis = "Keyboard2Y";
            break;

        case 3:
            P3Enter = KeyCode.Joystick1Button0;
            P3Back  = KeyCode.Joystick1Button1;
            P3xAxis = "LeftJoystick1X";
            P3yAxis = "LeftJoystick1Y";
            break;

        case 4:
            P3Enter = KeyCode.Joystick2Button0;
            P3Back  = KeyCode.Joystick2Button1;
            P3xAxis = "LeftJoystick2X";
            P3yAxis = "LeftJoystick2Y";
            break;

        case 5:
            P3Enter = KeyCode.Joystick3Button0;
            P3Back  = KeyCode.Joystick3Button1;
            P3xAxis = "LeftJoystick3X";
            P3yAxis = "LeftJoystick3Y";
            break;

        case 6:
            P3Enter = KeyCode.Joystick4Button0;
            P3Back  = KeyCode.Joystick4Button1;
            P3xAxis = "LeftJoystick4X";
            P3yAxis = "LeftJoystick4Y";
            break;
        }

        P4Playing = true;
        switch ((int)settings.P4Controller)
        {
        case 0:
            P4Playing = false;
            break;

        case 1:
            P4Enter = KeyCode.Space;
            P4Back  = KeyCode.Escape;
            P4xAxis = "Keyboard1X";
            P4yAxis = "Keyboard1Y";
            break;

        case 2:
            P4Enter = KeyCode.Return;
            P4Back  = KeyCode.Escape;
            P4xAxis = "Keyboard2X";
            P4yAxis = "Keyboard2Y";
            break;

        case 3:
            P4Enter = KeyCode.Joystick1Button0;
            P4Back  = KeyCode.Joystick1Button1;
            P4xAxis = "LeftJoystick1X";
            P4yAxis = "LeftJoystick1Y";
            break;

        case 4:
            P4Enter = KeyCode.Joystick2Button0;
            P4Back  = KeyCode.Joystick2Button1;
            P4xAxis = "LeftJoystick2X";
            P4yAxis = "LeftJoystick2Y";
            break;

        case 5:
            P4Enter = KeyCode.Joystick3Button0;
            P4Back  = KeyCode.Joystick3Button1;
            P4xAxis = "LeftJoystick3X";
            P4yAxis = "LeftJoystick3Y";
            break;

        case 6:
            P4Enter = KeyCode.Joystick4Button0;
            P4Back  = KeyCode.Joystick4Button1;
            P4xAxis = "LeftJoystick4X";
            P4yAxis = "LeftJoystick4Y";
            break;
        }
    }
예제 #6
0
    /*******\
    * START *
    \*******/
    void Start()
    {
        // Initialize the variables
        isPaused  = false;
        P3Playing = true;
        P4Playing = true;

        int width  = (int)((float)Screen.width * 0.7f);
        int height = (int)((float)PausedTexture.height * ((float)width / (float)PausedTexture.width));

        PausedRect = new Rect((int)((Screen.width - width) / 2), (int)((Screen.height - height) / 2), width, height);

        // Get controller information
        InitializeStorage settings = (InitializeStorage)GameObject.Find("VariableStorage").GetComponent(typeof(InitializeStorage));

        switch ((int)settings.P1Controller)
        {
        case 1:
            P1Pause = KeyCode.Escape;
            break;

        case 2:
            P1Pause = KeyCode.Escape;
            break;

        case 3:
            P1Pause = KeyCode.Joystick1Button7;
            break;

        case 4:
            P1Pause = KeyCode.Joystick2Button7;
            break;

        case 5:
            P1Pause = KeyCode.Joystick3Button7;
            break;

        case 6:
            P1Pause = KeyCode.Joystick4Button7;
            break;
        }
        switch ((int)settings.P2Controller)
        {
        case 1:
            P2Pause = KeyCode.Escape;
            break;

        case 2:
            P2Pause = KeyCode.Escape;
            break;

        case 3:
            P2Pause = KeyCode.Joystick1Button7;
            break;

        case 4:
            P2Pause = KeyCode.Joystick2Button7;
            break;

        case 5:
            P2Pause = KeyCode.Joystick3Button7;
            break;

        case 6:
            P2Pause = KeyCode.Joystick4Button7;
            break;
        }
        switch ((int)settings.P3Controller)
        {
        case 0:
            P3Playing = false;
            break;

        case 1:
            P3Pause = KeyCode.Escape;
            break;

        case 2:
            P3Pause = KeyCode.Escape;
            break;

        case 3:
            P3Pause = KeyCode.Joystick1Button7;
            break;

        case 4:
            P3Pause = KeyCode.Joystick2Button7;
            break;

        case 5:
            P3Pause = KeyCode.Joystick3Button7;
            break;

        case 6:
            P3Pause = KeyCode.Joystick4Button7;
            break;
        }
        switch ((int)settings.P4Controller)
        {
        case 0:
            P4Playing = false;
            break;

        case 1:
            P4Pause = KeyCode.Escape;
            break;

        case 2:
            P4Pause = KeyCode.Escape;
            break;

        case 3:
            P4Pause = KeyCode.Joystick1Button7;
            break;

        case 4:
            P4Pause = KeyCode.Joystick2Button7;
            break;

        case 5:
            P4Pause = KeyCode.Joystick3Button7;
            break;

        case 6:
            P4Pause = KeyCode.Joystick4Button7;
            break;
        }
    }
예제 #7
0
    /*******\
    * ONGUI *
    \*******/
    void OnGUI()
    {
        // Draw the slot buttons if they're not currently being selected (below the grey-out)
        if (CurrentlySelecting != SelectingState.P1)
        {
            drawP1Slot();
        }
        if (CurrentlySelecting != SelectingState.P2)
        {
            drawP2Slot();
        }
        if (CurrentlySelecting != SelectingState.P3)
        {
            drawP3Slot();
        }
        if (CurrentlySelecting != SelectingState.P4)
        {
            drawP4Slot();
        }


        // Draw the labels
        GUI.DrawTexture(P1LabelRect, P1LabelTexture);
        GUI.DrawTexture(P2LabelRect, P2LabelTexture);
        GUI.DrawTexture(P3LabelRect, P3LabelTexture);
        GUI.DrawTexture(P4LabelRect, P4LabelTexture);


        // Draw the Save and Cancel buttons
        if (GUI.Button(SaveButtonRect, SaveButtonTexture, ""))                              // if they click the save button
        {
            if (CurrentlySelecting == SelectingState.None && errorState == ErrorState.None) // and they're not selecting anything or in an error state
            {
                // check for the two kinds of errors
                if (Slot1Selection == ControllerSelectionState.None || Slot2Selection == ControllerSelectionState.None)           // if P1 or P2 don't have controllers assigned
                {
                    errorState    = ErrorState.Error1;                                                                            // put it in the correct error state
                    timeRemaining = 3f;                                                                                           // start the timer for 3 seconds
                }
                else if ((Slot3Selection == ControllerSelectionState.None) && !(Slot4Selection == ControllerSelectionState.None)) // if P3 doesn't have a controller but P4 does
                {
                    errorState    = ErrorState.Error2;                                                                            // put it in the correct error state
                    timeRemaining = 3f;                                                                                           // start the timer for 3 seconds
                }
                else                                                                                                              // otherwise the changes can be saved and go back to the main menu
                {
                    InitializeStorage storage = (InitializeStorage)GameObject.Find("VariableStorage").GetComponent(typeof(InitializeStorage));
                    storage.P1Controller = (InitializeStorage.ControllerSelection)((int)Slot1Selection);
                    storage.P2Controller = (InitializeStorage.ControllerSelection)((int)Slot2Selection);
                    storage.P3Controller = (InitializeStorage.ControllerSelection)((int)Slot3Selection);
                    storage.P4Controller = (InitializeStorage.ControllerSelection)((int)Slot4Selection);
                    Application.LoadLevel("mainmenu");
                }
            }
        }
        if (GUI.Button(CancelButtonRect, CancelButtonTexture, ""))                          // if they click the cancel button
        {
            if (CurrentlySelecting == SelectingState.None && errorState == ErrorState.None) // and they're not selecting anything or in an error state
            {
                Application.LoadLevel("mainmenu");                                          // go back to the main menu, discarding all changes (by not saving)
            }
        }


        // Draw the controller images if they are in a slot (below the grey-out)
        if (Slot1Selection == ControllerSelectionState.KB1 || Slot2Selection == ControllerSelectionState.KB1 ||
            Slot3Selection == ControllerSelectionState.KB1 || Slot4Selection == ControllerSelectionState.KB1)
        {
            drawKB1Icon();
        }
        if (Slot1Selection == ControllerSelectionState.KB2 || Slot2Selection == ControllerSelectionState.KB2 ||
            Slot3Selection == ControllerSelectionState.KB2 || Slot4Selection == ControllerSelectionState.KB2)
        {
            drawKB2Icon();
        }
        if (Slot1Selection == ControllerSelectionState.C1 || Slot2Selection == ControllerSelectionState.C1 ||
            Slot3Selection == ControllerSelectionState.C1 || Slot4Selection == ControllerSelectionState.C1)
        {
            drawC1Icon();
        }
        if (Slot1Selection == ControllerSelectionState.C2 || Slot2Selection == ControllerSelectionState.C2 ||
            Slot3Selection == ControllerSelectionState.C2 || Slot4Selection == ControllerSelectionState.C2)
        {
            drawC2Icon();
        }
        if (Slot1Selection == ControllerSelectionState.C3 || Slot2Selection == ControllerSelectionState.C3 ||
            Slot3Selection == ControllerSelectionState.C3 || Slot4Selection == ControllerSelectionState.C3)
        {
            drawC3Icon();
        }
        if (Slot1Selection == ControllerSelectionState.C4 || Slot2Selection == ControllerSelectionState.C4 ||
            Slot3Selection == ControllerSelectionState.C4 || Slot4Selection == ControllerSelectionState.C4)
        {
            drawC4Icon();
        }


        // Draw the grey-out texture
        if (CurrentlySelecting != SelectingState.None)
        {
            GUI.color = new Color(1.0f, 1.0f, 1.0f, 0.5f);             // Make it translucent
            GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), GreyOutTexture);
            GUI.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);             // Reset the colour
        }


        // Draw the slot buttons if they're currently being selected (above the grey-out)
        if (CurrentlySelecting == SelectingState.P1)
        {
            drawP1Slot();
        }
        if (CurrentlySelecting == SelectingState.P2)
        {
            drawP2Slot();
        }
        if (CurrentlySelecting == SelectingState.P3)
        {
            drawP3Slot();
        }
        if (CurrentlySelecting == SelectingState.P4)
        {
            drawP4Slot();
        }


        // Draw the controller images if they're not in a slot (on top of the grey-out)
        if (Slot1Selection != ControllerSelectionState.KB1 && Slot2Selection != ControllerSelectionState.KB1 &&
            Slot3Selection != ControllerSelectionState.KB1 && Slot4Selection != ControllerSelectionState.KB1)
        {
            drawKB1Icon();
        }
        if (Slot1Selection != ControllerSelectionState.KB2 && Slot2Selection != ControllerSelectionState.KB2 &&
            Slot3Selection != ControllerSelectionState.KB2 && Slot4Selection != ControllerSelectionState.KB2)
        {
            drawKB2Icon();
        }
        if (Slot1Selection != ControllerSelectionState.C1 && Slot2Selection != ControllerSelectionState.C1 &&
            Slot3Selection != ControllerSelectionState.C1 && Slot4Selection != ControllerSelectionState.C1)
        {
            drawC1Icon();
        }
        if (Slot1Selection != ControllerSelectionState.C2 && Slot2Selection != ControllerSelectionState.C2 &&
            Slot3Selection != ControllerSelectionState.C2 && Slot4Selection != ControllerSelectionState.C2)
        {
            drawC2Icon();
        }
        if (Slot1Selection != ControllerSelectionState.C3 && Slot2Selection != ControllerSelectionState.C3 &&
            Slot3Selection != ControllerSelectionState.C3 && Slot4Selection != ControllerSelectionState.C3)
        {
            drawC3Icon();
        }
        if (Slot1Selection != ControllerSelectionState.C4 && Slot2Selection != ControllerSelectionState.C4 &&
            Slot3Selection != ControllerSelectionState.C4 && Slot4Selection != ControllerSelectionState.C4)
        {
            drawC4Icon();
        }



        // Draw the error message if applicable
        if (errorState != ErrorState.None)
        {
            GUI.color = new Color(1.0f, 1.0f, 1.0f, 0.5f);             // Make it translucent
            GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), GreyOutTexture);
            GUI.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);             // Reset the colour
        }

        if (errorState == ErrorState.Error1)
        {
            GUI.DrawTexture(ErrorRect, Error1);
        }
        else if (errorState == ErrorState.Error2)
        {
            GUI.DrawTexture(ErrorRect, Error2);
        }
    }
예제 #8
0
    /*******\
    * START *
    \*******/
    void Start()
    {
        // Calculate the button sizes and spacing depending on the screen size
        int buttonWidth  = Screen.width * 2 / 7;
        int buttonHeight = (int)(buttonWidth * 0.7125);          // The height is multiplied by 0.7125 to match the aspect ratio of the button to 16:9
        int vertSpacing  = (Screen.height - 2 * buttonHeight) / 3;
        int horzSpacing  = (Screen.width - 2 * buttonWidth) / 3;

        // Initialize the buttons' rectangles
        CharacterSelectionRect = new Rect(horzSpacing, vertSpacing, buttonWidth, buttonHeight);
        VioletRect             = new Rect(horzSpacing, buttonHeight + 2 * vertSpacing, buttonWidth, buttonHeight);
        ZakirRect = new Rect(buttonWidth + 2 * horzSpacing, vertSpacing, buttonWidth, buttonHeight);
        NoirRect  = new Rect(buttonWidth + 2 * horzSpacing, buttonHeight + 2 * vertSpacing, buttonWidth, buttonHeight);

        // Calculate the token sizes based on the button sizes
        int tokenWidth  = (int)(P1TokenTexture.width * ((double)buttonWidth / (double)NoirSelectionButton.width));
        int tokenHeight = (int)(P1TokenTexture.height * ((double)buttonHeight / (double)NoirSelectionButton.height));
        int P1xOffset   = 1;
        int P2xOffset   = (int)(buttonWidth - tokenWidth);
        int P3xOffset   = 1;
        int P3yOffset   = (int)(buttonHeight - tokenHeight);
        int P4xOffset   = (int)(buttonWidth - tokenWidth);
        int P4yOffset   = (int)(buttonHeight - tokenHeight);

        // Initialize the tokens' rectangles
        P1TokenRectV = new Rect(horzSpacing + P1xOffset, buttonHeight + 2 * vertSpacing, tokenWidth, tokenHeight);
        P1TokenRectZ = new Rect((buttonWidth + 2 * horzSpacing) + P1xOffset, vertSpacing, tokenWidth, tokenHeight);
        P1TokenRectN = new Rect((buttonWidth + 2 * horzSpacing) + P1xOffset, buttonHeight + 2 * vertSpacing, tokenWidth, tokenHeight);

        P2TokenRectV = new Rect(horzSpacing + P2xOffset, buttonHeight + 2 * vertSpacing, tokenWidth, tokenHeight);
        P2TokenRectZ = new Rect((buttonWidth + 2 * horzSpacing) + P2xOffset, vertSpacing, tokenWidth, tokenHeight);
        P2TokenRectN = new Rect((buttonWidth + 2 * horzSpacing) + P2xOffset, buttonHeight + 2 * vertSpacing, tokenWidth, tokenHeight);

        P3TokenRectV = new Rect(horzSpacing + P3xOffset, buttonHeight + 2 * vertSpacing + P3yOffset, tokenWidth, tokenHeight);
        P3TokenRectZ = new Rect((buttonWidth + 2 * horzSpacing) + P3xOffset, vertSpacing + P3yOffset, tokenWidth, tokenHeight);
        P3TokenRectN = new Rect((buttonWidth + 2 * horzSpacing) + P3xOffset, buttonHeight + 2 * vertSpacing + P3yOffset, tokenWidth, tokenHeight);

        P4TokenRectV = new Rect(horzSpacing + P4xOffset, buttonHeight + 2 * vertSpacing + P4yOffset, tokenWidth, tokenHeight);
        P4TokenRectZ = new Rect((buttonWidth + 2 * horzSpacing) + P4xOffset, vertSpacing + P4yOffset, tokenWidth, tokenHeight);
        P4TokenRectN = new Rect((buttonWidth + 2 * horzSpacing) + P4xOffset, buttonHeight + 2 * vertSpacing + P4yOffset, tokenWidth, tokenHeight);

        // Initialize player selection
        P1State = CharState.Violet;
        P2State = CharState.Violet;
        P3State = CharState.Violet;
        P4State = CharState.Violet;

        // Initialize whether the players have selected to false
        P1Selected = false;
        P2Selected = false;
        P3Selected = false;
        P4Selected = false;


        // Initialize the controller layouts
        InitializeStorage settings = (InitializeStorage)GameObject.Find("VariableStorage").GetComponent(typeof(InitializeStorage));

        switch ((int)settings.P1Controller)
        {
        case 1:
            P1Enter = KeyCode.Space;
            P1Back  = KeyCode.Escape;
            P1xAxis = "Keyboard1X";
            P1yAxis = "Keyboard1Y";
            break;

        case 2:
            P1Enter = KeyCode.Return;
            P1Back  = KeyCode.Escape;
            P1xAxis = "Keyboard2X";
            P1yAxis = "Keyboard2Y";
            break;

        case 3:
            P1Enter = KeyCode.Joystick1Button0;
            P1Back  = KeyCode.Joystick1Button1;
            P1xAxis = "LeftJoystick1X";
            P1yAxis = "LeftJoystick1Y";
            break;

        case 4:
            P1Enter = KeyCode.Joystick2Button0;
            P1Back  = KeyCode.Joystick2Button1;
            P1xAxis = "LeftJoystick2X";
            P1yAxis = "LeftJoystick2Y";
            break;

        case 5:
            P1Enter = KeyCode.Joystick3Button0;
            P1Back  = KeyCode.Joystick3Button1;
            P1xAxis = "LeftJoystick3X";
            P1yAxis = "LeftJoystick3Y";
            break;

        case 6:
            P1Enter = KeyCode.Joystick4Button0;
            P1Back  = KeyCode.Joystick4Button1;
            P1xAxis = "LeftJoystick4X";
            P1yAxis = "LeftJoystick4Y";
            break;
        }

        switch ((int)settings.P2Controller)
        {
        case 1:
            P2Enter = KeyCode.Space;
            P2Back  = KeyCode.Escape;
            P2xAxis = "Keyboard1X";
            P2yAxis = "Keyboard1Y";
            break;

        case 2:
            P2Enter = KeyCode.Return;
            P2Back  = KeyCode.Escape;
            P2xAxis = "Keyboard2X";
            P2yAxis = "Keyboard2Y";
            break;

        case 3:
            P2Enter = KeyCode.Joystick1Button0;
            P2Back  = KeyCode.Joystick1Button1;
            P2xAxis = "LeftJoystick1X";
            P2yAxis = "LeftJoystick1Y";
            break;

        case 4:
            P2Enter = KeyCode.Joystick2Button0;
            P2Back  = KeyCode.Joystick2Button1;
            P2xAxis = "LeftJoystick2X";
            P2yAxis = "LeftJoystick2Y";
            break;

        case 5:
            P2Enter = KeyCode.Joystick3Button0;
            P2Back  = KeyCode.Joystick3Button1;
            P2xAxis = "LeftJoystick3X";
            P2yAxis = "LeftJoystick3Y";
            break;

        case 6:
            P2Enter = KeyCode.Joystick4Button0;
            P2Back  = KeyCode.Joystick4Button1;
            P2xAxis = "LeftJoystick4X";
            P2yAxis = "LeftJoystick4Y";
            break;
        }

        P3Playing = true;
        switch ((int)settings.P3Controller)
        {
        case 0:
            P3Playing = false;
            break;

        case 1:
            P3Enter = KeyCode.Space;
            P3Back  = KeyCode.Escape;
            P3xAxis = "Keyboard1X";
            P3yAxis = "Keyboard1Y";
            break;

        case 2:
            P3Enter = KeyCode.Return;
            P3Back  = KeyCode.Escape;
            P3xAxis = "Keyboard2X";
            P3yAxis = "Keyboard2Y";
            break;

        case 3:
            P3Enter = KeyCode.Joystick1Button0;
            P3Back  = KeyCode.Joystick1Button1;
            P3xAxis = "LeftJoystick1X";
            P3yAxis = "LeftJoystick1Y";
            break;

        case 4:
            P3Enter = KeyCode.Joystick2Button0;
            P3Back  = KeyCode.Joystick2Button1;
            P3xAxis = "LeftJoystick2X";
            P3yAxis = "LeftJoystick2Y";
            break;

        case 5:
            P3Enter = KeyCode.Joystick3Button0;
            P3Back  = KeyCode.Joystick3Button1;
            P3xAxis = "LeftJoystick3X";
            P3yAxis = "LeftJoystick3Y";
            break;

        case 6:
            P3Enter = KeyCode.Joystick4Button0;
            P3Back  = KeyCode.Joystick4Button1;
            P3xAxis = "LeftJoystick4X";
            P3yAxis = "LeftJoystick4Y";
            break;
        }

        P4Playing = true;
        switch ((int)settings.P4Controller)
        {
        case 0:
            P4Playing = false;
            break;

        case 1:
            P4Enter = KeyCode.Space;
            P4Back  = KeyCode.Escape;
            P4xAxis = "Keyboard1X";
            P4yAxis = "Keyboard1Y";
            break;

        case 2:
            P4Enter = KeyCode.Return;
            P4Back  = KeyCode.Escape;
            P4xAxis = "Keyboard2X";
            P4yAxis = "Keyboard2Y";
            break;

        case 3:
            P4Enter = KeyCode.Joystick1Button0;
            P4Back  = KeyCode.Joystick1Button1;
            P4xAxis = "LeftJoystick1X";
            P4yAxis = "LeftJoystick1Y";
            break;

        case 4:
            P4Enter = KeyCode.Joystick2Button0;
            P4Back  = KeyCode.Joystick2Button1;
            P4xAxis = "LeftJoystick2X";
            P4yAxis = "LeftJoystick2Y";
            break;

        case 5:
            P4Enter = KeyCode.Joystick3Button0;
            P4Back  = KeyCode.Joystick3Button1;
            P4xAxis = "LeftJoystick3X";
            P4yAxis = "LeftJoystick3Y";
            break;

        case 6:
            P4Enter = KeyCode.Joystick4Button0;
            P4Back  = KeyCode.Joystick4Button1;
            P4xAxis = "LeftJoystick4X";
            P4yAxis = "LeftJoystick4Y";
            break;
        }
    }
예제 #9
0
    /********\
    * UPDATE *
    \********/
    void Update()
    {
        // If all players have selected, go to the next scene (Map Selection)
        if (P1Selected && P2Selected && ((P3Playing && P3Selected) || !P3Playing) && ((P4Playing && P4Selected) || !P4Playing))
        {
            InitializeStorage storage = (InitializeStorage)GameObject.Find("VariableStorage").GetComponent(typeof(InitializeStorage));
            storage.P1Character = (InitializeStorage.CharacterSelection)((int)P1State);
            storage.P2Character = (InitializeStorage.CharacterSelection)((int)P2State);
            if (P3Playing == true)
            {
                storage.P3Character = (InitializeStorage.CharacterSelection)((int)P3State);
            }
            if (P4Playing == true)
            {
                storage.P4Character = (InitializeStorage.CharacterSelection)((int)P4State);
            }


            Application.LoadLevel("MapSelectionMenu");
        }

        // Update the tokens based on any key input, if the players haven't selected yet
        if (P1Selected == false)
        {
            switch (P1State)
            {
            case CharState.Noir:
                if (Input.GetAxis(P1yAxis) < 0)                         // up
                {
                    P1State = CharState.Zakir;
                }
                else if (Input.GetAxis(P1xAxis) < 0)                         // left
                {
                    P1State = CharState.Violet;
                }
                break;

            case CharState.Violet:
                if (Input.GetAxis(P1yAxis) < 0)                         // up
                {
                    P1State = CharState.Zakir;
                }
                else if (Input.GetAxis(P1xAxis) > 0)                         // right
                {
                    P1State = CharState.Noir;
                }
                break;

            case CharState.Zakir:
                if (Input.GetAxis(P1yAxis) > 0)                         // down
                {
                    P1State = CharState.Noir;
                }
                else if (Input.GetAxis(P1xAxis) < 0)                         // left
                {
                    P1State = CharState.Violet;
                }
                break;
            }
        }
        // Check for the selection key being pressed
        if (Input.GetKeyUp(P1Enter))
        {
            // Toggle the selection
            if (P1Selected)
            {
                P1Selected = false;
            }
            else
            {
                P1Selected = true;
            }
        }

        // Same for P2
        if (P2Selected == false)
        {
            switch (P2State)
            {
            case CharState.Noir:
                if (Input.GetAxis(P2yAxis) < 0)                         // up
                {
                    P2State = CharState.Zakir;
                }
                else if (Input.GetAxis(P2xAxis) < 0)                         // left
                {
                    P2State = CharState.Violet;
                }
                break;

            case CharState.Violet:
                if (Input.GetAxis(P2yAxis) < 0)                         // up
                {
                    P2State = CharState.Zakir;
                }
                else if (Input.GetAxis(P2xAxis) > 0)                         // right
                {
                    P2State = CharState.Noir;
                }
                break;

            case CharState.Zakir:
                if (Input.GetAxis(P2yAxis) > 0)                         // down
                {
                    P2State = CharState.Noir;
                }
                else if (Input.GetAxis(P2xAxis) < 0)                         // left
                {
                    P2State = CharState.Violet;
                }
                break;
            }
        }
        if (Input.GetKeyUp(P2Enter))
        {
            // Toggle the selection
            if (P2Selected)
            {
                P2Selected = false;
            }
            else
            {
                P2Selected = true;
            }
        }

        // Same for P3, if P3 is playing
        if (P3Playing)
        {
            if (P3Selected == false)
            {
                switch (P3State)
                {
                case CharState.Noir:
                    if (Input.GetAxis(P3yAxis) < 0)                     // up
                    {
                        P3State = CharState.Zakir;
                    }
                    else if (Input.GetAxis(P3xAxis) < 0)                     // left
                    {
                        P3State = CharState.Violet;
                    }
                    break;

                case CharState.Violet:
                    if (Input.GetAxis(P3yAxis) < 0)                     // up
                    {
                        P3State = CharState.Zakir;
                    }
                    else if (Input.GetAxis(P3xAxis) > 0)                     // right
                    {
                        P3State = CharState.Noir;
                    }
                    break;

                case CharState.Zakir:
                    if (Input.GetAxis(P3yAxis) > 0)                     // down
                    {
                        P3State = CharState.Noir;
                    }
                    else if (Input.GetAxis(P3xAxis) < 0)                     // left
                    {
                        P3State = CharState.Violet;
                    }
                    break;
                }
            }
            if (Input.GetKeyUp(P3Enter))
            {
                // Toggle the selection
                if (P3Selected)
                {
                    P3Selected = false;
                }
                else
                {
                    P3Selected = true;
                }
            }
        }

        // Same for P4, if P4 is playing
        if (P4Playing)
        {
            if (P4Selected == false)
            {
                switch (P4State)
                {
                case CharState.Noir:
                    if (Input.GetAxis(P4yAxis) < 0)                     // up
                    {
                        P4State = CharState.Zakir;
                    }
                    else if (Input.GetAxis(P4xAxis) < 0)                     // left
                    {
                        P4State = CharState.Violet;
                    }
                    break;

                case CharState.Violet:
                    if (Input.GetAxis(P4yAxis) < 0)                     // up
                    {
                        P4State = CharState.Zakir;
                    }
                    else if (Input.GetAxis(P4xAxis) > 0)                     // right
                    {
                        P4State = CharState.Noir;
                    }
                    break;

                case CharState.Zakir:
                    if (Input.GetAxis(P4yAxis) > 0)                     // down
                    {
                        P4State = CharState.Noir;
                    }
                    else if (Input.GetAxis(P4xAxis) < 0)                     // left
                    {
                        P4State = CharState.Violet;
                    }
                    break;
                }
            }
            if (Input.GetKeyUp(P4Enter))
            {
                // Toggle the selection
                if (P4Selected)
                {
                    P4Selected = false;
                }
                else
                {
                    P4Selected = true;
                }
            }
        }

        // Check for the back button being pressed
        if (Input.GetKeyUp(P1Back) || Input.GetKeyUp(P2Back) || (P3Playing && Input.GetKeyUp(P3Back)) || (P4Playing && Input.GetKeyUp(P4Back)))
        {
            Application.LoadLevel("mainmenu");
        }
    }