/*
     * DESCR: Spawns a player, assigning a character and controller scheme.
     * PRE: The controller and character data are sent in.
     * POST: A player with the correct character and controller are spawned on the map.
     */
    void Spawn(InitializeStorage.CharacterSelection character, InitializeStorage.ControllerSelection controller)
    {
        //Assign Character
        switch ((int)character)
        {
        case 1:                         //Violet
            newPlayer = Resources.Load("Violet") as GameObject;
            break;

        case 2:                         //Zakir
            newPlayer = Resources.Load("Zakir") as GameObject;
            break;

        case 3:                         //Noir
            newPlayer = Resources.Load("Noir") as GameObject;
            break;

        default:
            print("Error: Character not selected.");
            break;
        }

        //Assign Controller
        if (controller != 0)
        {
            newPlayer.GetComponent <Player>().layout = (int)controller;
        }

        //Spawn the player.
        Instantiate(newPlayer, transform.position, transform.rotation);
    }
예제 #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;
    }