示例#1
0
    MapState mp;                        //State for map

    // Start is called before the first frame update
    void Start()
    {
        state1 = startState;
        state2 = startState;
        mp     = startMap;
        Char1.GetComponent <Image>().sprite = state1.GetStateSprite(); //These put the proper images on the select screen
        Char2.GetComponent <Image>().sprite = state2.GetStateSprite();
        MapIm.GetComponent <Image>().sprite = mp.GetStateSprite();
    }
示例#2
0
    private void ManageState()                   //Changes the states based on player input
    {
        var nextStates = state1.GetNextStates(); //Gets list of available character states for P1

        if (Input.GetKeyDown(KeyCode.A))
        {
            Debug.Log("Left Pressed");
            state1 = nextStates[1];
        }
        else if (Input.GetKeyDown(KeyCode.D))
        {
            Debug.Log("Right Pressed");
            state1 = nextStates[0];
        }

        nextStates = state2.GetNextStates(); //Gets list of available character states for P2

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            Debug.Log("A Pressed");
            state2 = nextStates[1];
        }
        else if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            Debug.Log("D Pressed");
            state2 = nextStates[0];
        }

        var mapnextStates = mp.GetNextStates(); //Gets list of available map states

        if (Input.GetKeyDown(KeyCode.R))
        {
            Debug.Log("R Pressed");
            mp = mapnextStates[0];
        }

        Char1.GetComponent <Image>().sprite = state1.GetStateSprite(); //Updates the images on the screen based on current state
        Char2.GetComponent <Image>().sprite = state2.GetStateSprite();
        MapIm.GetComponent <Image>().sprite = mp.GetStateSprite();
    }