コード例 #1
0
 // Use this for initialization
 void Start()
 {
     gameModeList = new List <GameMode>();
     for (int i = 0; i < modeNameList.Length; ++i)
     {
         gameModeList.Add(new GameMode(modeNameList[i], descriptionList[i], spriteList[i]));
     }
     gameModeLoop     = new UniqueLoop <GameMode>(gameModeList);
     selectedGameMode = gameModeLoop.GetNextItem(0);
     selectedGameMode = gameModeLoop.GetPreviousItem(0); // so that it always starts with the first item in the list
     UpdateUI();
 }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        float x = GameInput.Horizontal.GetRawDelayed();

        if (x == 1)
        {
            AudioController.instance.PlaySFX("ButtonSelectSound", 0.85f);
            selectedGameMode = gameModeLoop.GetNextItem(0);
            UpdateUI();
        }
        else if (x == -1)
        {
            AudioController.instance.PlaySFX("ButtonSelectSound", 0.85f);
            selectedGameMode = gameModeLoop.GetPreviousItem(0);
            UpdateUI();
        }
        if (GameInput.Submit.WasPressed())
        {
            PlayerPrefs.SetString("GameMode", selectedGameMode.mode);
            AudioController.instance.PlaySFX("ButtonPressSound", 0.85f);
            switch (selectedGameMode.mode)
            {
            case "Classic":
            case "King of the Hill":
                Navigator.instance.LoadLevel("CharacterReadyScene");
                break;

            case "Solo":
                PlayerPrefs.SetInt("NumberOfPlayers", 1);
                PlayerPrefs.SetInt("InfiniteLives", 0);
                PlayerPrefs.SetInt("NumberOfLives", 1);
                Navigator.instance.LoadLevel("Main");
                break;

            case "Training":
                PlayerPrefs.SetInt("InfiniteLives", 1);
                PlayerPrefs.SetInt("NumberOfPlayers", Input.GetJoystickNames().Length);
                Navigator.instance.LoadLevel("TrainingScene");
                break;
            }
        }
        if (GameInput.Cancel.WasPressed())
        {
            Navigator.instance.LoadLevel("TitleScene");
        }
    }