Example #1
0
    private void Update()
    {
        if (endSelect)
        {
            return;
        }
        GamepadState player_state = GamePad.GetState(player_idx);

        if (player_state.B)
        {
            PlayerPrefs.GetInt(player_idx.ToString(), selectNumber);
            PlayerPrefs.Save();
            endSelect = true;
        }
        else if (player_state.LeftStickAxis.x != 0 && !changed)
        {
            selectNumber += (player_state.LeftStickAxis.x > 0) ? 1 : -1;
            if (selectNumber < 0)
            {
                selectNumber = sprites.sprites.Length - 1;
            }
            else if (selectNumber >= sprites.sprites.Length)
            {
                selectNumber = 0;
            }
            characterImage.sprite = sprites.sprites[selectNumber];
            Debug.Log(selectNumber);
            changed = true;
            return;
        }
        if (player_state.LeftStickAxis.x == 0)
        {
            changed = false;
        }
    }
Example #2
0
    private void Start()
    {
        var character = PlayerPrefs.GetInt(player_idx.ToString(), 0);

        characterImage.sprite = spriteScriptable.sprites[character];
        GameObject obj = GameObject.Find("SceneHandler");

        if (obj == null)
        {
            Debug.Log("Missing SceneHandler");
            return;
        }

        var score = 0.0f;

        if (player_idx == GamePad.PlayerIndex.One)
        {
            score = obj.GetComponent <SceneScoringHandler>().P1_Score;
        }
        else
        {
            score = obj.GetComponent <SceneScoringHandler>().P2_Score;
        }

        scoreText.text = "Score :: " + score;
    }