コード例 #1
0
    public void StartGame()
    {
        string s;

        if (GetGameIsReady(out s))
        {
            if (singleplayer)
            {
                PlayerPrefManager.SetInt("game_playercount", 1);
                PlayerPrefManager.SetString("game_p1_plane", p1Plane.ToString());
                PlayerPrefManager.SetString("game_p1_input", PlayerInput.InputType.DUAL.ToString());
            }
            else
            {
                PlayerPrefManager.SetInt("game_playercount", 2);
                PlayerPrefManager.SetString("game_p1_plane", p1Plane.ToString());
                PlayerPrefManager.SetString("game_p1_input", p1Input.ToString());
                PlayerPrefManager.SetString("game_p2_plane", p2Plane.ToString());
                PlayerPrefManager.SetString("game_p2_input", p2Input.ToString());
            }
            PlayerPrefManager.SetString("game_difficulty", difficulty.ToString());
            PlayerPrefManager.SetString("game_currentstage", stage.ToString());
            LevelLoader.current.LoadStage(stage);
        }
        else
        {
            Debug.LogError("this line shouldnt be reachable since the button should be disabled if the game cant be started");
        }
    }
コード例 #2
0
 public void CycleCPP2Input()
 {
     p2Input = NextFromArray <PlayerInput.InputType>(p2Input, inputs);
     coopP2InputText.text = p2Input.ToString();
     UpdateGameReadiness();
 }
コード例 #3
0
    void InstantiateAndInitializePlayer(int playerNumber, out Player player)
    {
        GameObject playerObject = Instantiate(playerPrefab) as GameObject;
        char       numberChar   = playerNumber.ToString().ToCharArray()[0];
        string     inputKey     = "game_p#_input".Replace('#', numberChar);
        string     planeKey     = "game_p#_plane".Replace('#', numberChar);

        PlayerInput.InputType input = PlayerInput.ParseInputType(PlayerPrefManager.GetString(inputKey));
        Player.PlaneType      plane = Player.ParsePlaneType(PlayerPrefManager.GetString(planeKey));
        playerObject.name = "Player " + playerNumber + " (" + plane.ToString() + ", " + input.ToString() + ")";
        player            = playerObject.GetComponent <Player>();
        player.Initialize(input, plane);
        player.SetFurtherInitData(playerNumber, this, gui.ActivateAndGetPlayerGUI(playerNumber), playArea, levelTrackFollower);
        player.transform.parent = playArea.transform;
    }