Beispiel #1
0
    int GetFreeSlotOrOldestExisting()
    {
        using (new Util.ProfileBlock("GetFreeSlotOrOldestExisting"))
        {
            int             oldest          = -1;
            System.DateTime oldestWriteTime = System.DateTime.Now;

            for (int i = 0; i < maxSlots; i++)
            {
                string     bundleId = GetSlotBundleId(i);
                GameBundle bundle   = bundleLibrary.GetBundle(bundleId);
                string     voosPath = bundle.GetVoosPath();

                if (!File.Exists(voosPath))
                {
                    return(i);
                }

                System.DateTime writeTime = System.IO.File.GetLastWriteTime(voosPath);
                if (oldest == -1 || writeTime < oldestWriteTime)
                {
                    oldest          = i;
                    oldestWriteTime = writeTime;
                }
            }

            return(oldest);
        }
    }
    void MasterClientInit()
    {
        SaveGameToLoad saveGameToLoad = FindObjectOfType <SaveGameToLoad>();
        string         bundleId       = GameBuilderApplication.CurrentGameOptions.bundleIdToLoad;

        if (saveGameToLoad)
        {
            Debug.Log("Loading saved game!");
            saveLoad.Load(saveGameToLoad.saved, saveGameToLoad.voosFilePath);
            GameObject.Destroy(saveGameToLoad.gameObject);
        }
        else if (!bundleId.IsNullOrEmpty())
        {
            Debug.Log($"Loading game bundle {bundleId}");
            string voosPath = gameBundleLibrary.GetBundle(bundleId).GetVoosPath();
            saveLoad.Load(SaveLoadController.ReadSaveGame(voosPath), voosPath);
#if !USE_STEAMWORKS
            workshop.Load(gameBundleLibrary.GetBundle(bundleId).GetAssetsPath());
#endif
            lastLoadedBundleId = bundleId;
        }
        else
        {
            SaveLoadController.SaveGame save = SaveLoadController.ReadSaveGame(GameBuilderSceneController.GetMinimalScenePath(mode == Mode.Online));
            saveLoad.Load(save);
        }

        using (Util.Profile("SpawnLocalobjects"))
            SpawnLocalObjects();
        StartCoroutine(LoadingSequence());
    }