Пример #1
0
    void JoinRaceInProgress(string settingsStr)
    {
        //When joining a game in progress the racesetup wont be there already, so create a new one
        IsInLobby = false;
        RaceSetup rs = (RaceSetup)Instantiate(raceSetupObject);

        rs.settings = RaceSettings.ParseFromString(settingsStr);
        rs.JoinGameInProgress();         //Make the racesetup run on level load
    }
Пример #2
0
    void LoadRace(string settings)
    {
        IsInLobby = false;
        RaceSetup rs = GameObject.FindObjectOfType <RaceSetup>();       //Get the race setup object

        if (rs != null)
        {
            //ensure that the clientside settings are correct
            rs.settings = RaceSettings.ParseFromString(settings);
            rs.StartRace(false);
        }
        else
        {
            Debug.LogError("Tried to load race but no RaceSetup is present");
        }
    }
Пример #3
0
    void UpdateRaceSettings(string settingsStr)
    {
        if (Network.isServer)
        {
            return;
        }
        RaceSetup rs = GameObject.FindObjectOfType <RaceSetup>();

        if (rs != null)
        {
            rs.settings = RaceSettings.ParseFromString(settingsStr);
        }
        else
        {
            Debug.LogError("Couldn't update race settings: RaceSetup not found.");
        }
    }
Пример #4
0
    void Start()
    {
        if (Network.isServer)
        {
            raceSettingsVisible = true;
        }

        client = FindObjectOfType <Client>();
        if (GameSettings.music)
        {
            audio.Play();
        }
        if (client == null)
        {
            Destroy(this.gameObject);
        }
        raceSetup = FindObjectOfType <RaceSetup>();
        //Load race settings from playerprefs
        string settingsString = PlayerPrefs.GetString("RaceSettings", raceSetup.settings.ToString());

        raceSetup.settings = RaceSettings.ParseFromString(settingsString);
        //Set some things from the race settings
        totalCharacters   = Global.characters.Length;
        tempSettings      = new RaceSettings(raceSetup.settings);
        tempLapsF         = tempSettings.laps;
        tempAIBallsF      = tempSettings.aiBallCount;
        tempAIStupidnessF = tempSettings.aiStupidness;
        tempLapsStr       = tempSettings.laps.ToString();
        tempAIBallsStr    = tempSettings.aiBallCount.ToString();

        character = client.FindServerPlayer(Network.player).character;
        //Set stage records
        stageRecords = new float[Global.stages.Length];
        for (int i = 0; i < stageRecords.Length; i++)
        {
            Stage s = Global.stages[i];
            stageRecords[i] = PlayerPrefs.GetFloat(s.sceneName + "_lap", -1);
        }

        GameSettings.Apply(false);
    }