Ejemplo n.º 1
0
    /// <summary>
    /// General subscene loader
    /// </summary>
    /// <param name="sceneName"></param>
    /// <returns></returns>
    IEnumerator LoadSubScene(string sceneName, SubsceneLoadTimer loadTimer = null)
    {
        AsyncOperation AO = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);

        while (!AO.isDone)
        {
            if (loadTimer != null)
            {
                loadTimer.IncrementLoadBar();
            }
            yield return(WaitFor.EndOfFrame);
        }

        if (loadTimer != null)
        {
            loadTimer.IncrementLoadBar();
        }
        if (isServer)
        {
            NetworkServer.SpawnObjects();
        }
        else
        {
            ClientScene.PrepareToSpawnSceneObjects();
            yield return(WaitFor.Seconds(0.2f));

            RequestObserverRefresh.Send(sceneName);
        }
    }
Ejemplo n.º 2
0
    public override void OnStartLocalPlayer()
    {
        base.OnStartLocalPlayer();
        RequestObserverRefresh.Send(SceneManager.GetActiveScene().name);
        PlayerManager.SetViewerForControl(this);

        CmdServerSetupPlayer(GetNetworkInfo(),
                             PlayerManager.CurrentCharacterSettings.Username, DatabaseAPI.ServerData.UserID, GameData.BuildNumber,
                             DatabaseAPI.ServerData.IdToken);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Request to become an observer to networked objects in a
    /// particular scene
    /// </summary>
    /// <param name="newSceneNameContext"> The scene we are requesting to be observers of</param>
    /// <returns></returns>
    public static RequestObserverRefresh Send(string newSceneNameContext)
    {
        RequestObserverRefresh msg = new RequestObserverRefresh
        {
            NewSceneNameContext = newSceneNameContext
        };

        msg.Send();
        return(msg);
    }
    IEnumerator LoadClientScenesFromServer(List<SceneInfo> Scenes, string OriginalScene, Action OnFinish)
    {
        ClientSideFinishAction = OnFinish;
        var SubsceneLoadTimer = new SubsceneLoadTimer();
        //calculate load time:
        SubsceneLoadTimer.MaxLoadTime = Scenes.Count;

        clientIsLoadingSubscene = true;
        foreach (var Scene in Scenes)
        {
            yield return LoadClientSubScene(Scene, false, SubsceneLoadTimer, true );
            if (KillClientLoadingCoroutine)
            {
                yield return SceneManager.UnloadSceneAsync(Scene.SceneName);
                KillClientLoadingCoroutine = false;
                clientIsLoadingSubscene = false;
                yield break;
            }
            clientLoadedSubScenes.Add(Scene);
        }

        NetworkClient.PrepareToSpawnSceneObjects();
        RequestObserverRefresh.Send(OriginalScene);

        foreach (var Scene in Scenes)
        {
            yield return WaitFor.Seconds(0.1f); //For smooth FPS not necessary technically, but causes freeze For a little bit
            if (KillClientLoadingCoroutine)
            {
                KillClientLoadingCoroutine = false;
                clientIsLoadingSubscene = false;
                yield break;
            }
            RequestObserverRefresh.Send(Scene.SceneName);
        }

        clientIsLoadingSubscene = false;
        yield return WaitFor.Seconds(0.1f); //For smooth FPS not necessary technically, but causes freeze For a little bit
        if (KillClientLoadingCoroutine)
        {
            KillClientLoadingCoroutine = false;
            yield break;
        }
        UIManager.Display.preRoundWindow.CloseMapLoadingPanel();
        OnFinish.Invoke();
    }
Ejemplo n.º 5
0
    /// <summary>
    /// General subscene loader
    /// </summary>
    /// <param name="sceneName"></param>
    /// <returns></returns>
    IEnumerator LoadSubScene(string sceneName, SubsceneLoadTimer loadTimer = null, bool HandlSynchronising = true)
    {
        AsyncOperation AO = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);

        if (AO == null)
        {
            yield break;                     // Null if scene not found.
        }
        while (AO.isDone == false)
        {
            if (loadTimer != null)
            {
                loadTimer.IncrementLoadBar();
            }
            yield return(WaitFor.EndOfFrame);
        }

        if (loadTimer != null)
        {
            loadTimer.IncrementLoadBar();
        }
        if (isServer)
        {
            NetworkServer.SpawnObjects();
        }
        else
        {
            if (HandlSynchronising)
            {
                NetworkClient.PrepareToSpawnSceneObjects();
                yield return(WaitFor.Seconds(0.2f));

                RequestObserverRefresh.Send(sceneName);
            }
        }
    }