Esempio n. 1
0
        protected override void Update()
        {
            base.Update();
            if (IsServer)
            {
                CentralAppServerRegister.Update();
                if (CentralAppServerRegister.IsRegisteredToCentralServer)
                {
                    if (mainThreadActions.Count > 0)
                    {
                        lock (mainThreadLock)
                        {
                            foreach (Action actions in mainThreadActions)
                            {
                                actions.Invoke();
                            }

                            mainThreadActions.Clear();
                        }
                    }
                    if (restartingScenes.Count > 0)
                    {
                        foreach (string scene in restartingScenes)
                        {
                            SpawnMap(scene, true);
                        }
                        restartingScenes.Clear();
                    }
                }
            }
        }
Esempio n. 2
0
 protected override void FixedUpdate()
 {
     base.FixedUpdate();
     if (IsServer)
     {
         CentralAppServerRegister.Update();
         if (CentralAppServerRegister.IsRegisteredToCentralServer)
         {
             if (restartingScenes.Count > 0)
             {
                 string tempRestartingScenes;
                 while (restartingScenes.TryDequeue(out tempRestartingScenes))
                 {
                     SpawnMap(tempRestartingScenes, true);
                 }
             }
         }
         if (mainThreadActions.Count > 0)
         {
             Action tempMainThreadAction;
             while (mainThreadActions.TryDequeue(out tempMainThreadAction))
             {
                 if (tempMainThreadAction != null)
                 {
                     tempMainThreadAction.Invoke();
                 }
             }
         }
     }
 }
 protected override void Update()
 {
     base.Update();
     if (IsServer)
     {
         CentralAppServerRegister.Update();
     }
 }
        protected override void FixedUpdate()
        {
            base.FixedUpdate();
#if UNITY_STANDALONE && !CLIENT_BUILD
            float tempTime = Time.fixedTime;
            if (IsServer)
            {
                CentralAppServerRegister.Update();
                if (tempTime - lastSaveTime > autoSaveDuration)
                {
                    lastSaveTime = tempTime;
                    SaveCharactersRoutine().Forget();
                    if (!IsInstanceMap())
                    {
                        // Don't save building if it's instance map
                        SaveBuildingsRoutine().Forget();
                    }
                }
                if (IsInstanceMap())
                {
                    // Quitting application when no players
                    if (Players.Count > 0)
                    {
                        terminatingTime = tempTime;
                    }
                    else if (tempTime - terminatingTime >= TERMINATE_INSTANCE_DELAY)
                    {
                        Application.Quit();
                    }
                }

                if (pendingSpawnPlayerCharacters.Count > 0 && IsReadyToInstantiateObjects())
                {
                    // Spawn pending player characters
                    LiteNetLibPlayer player;
                    foreach (PendingSpawnPlayerCharacter spawnPlayerCharacter in pendingSpawnPlayerCharacters)
                    {
                        if (!Players.TryGetValue(spawnPlayerCharacter.connectionId, out player))
                        {
                            continue;
                        }
                        player.IsReady = true;
                        SetPlayerReadyRoutine(spawnPlayerCharacter.connectionId, spawnPlayerCharacter.userId, spawnPlayerCharacter.selectCharacterId).Forget();
                    }
                    pendingSpawnPlayerCharacters.Clear();
                }
            }
#endif
        }
        protected override void Update()
        {
            base.Update();
            var tempUnscaledTime = Time.unscaledTime;

            if (IsServer)
            {
                CentralAppServerRegister.Update();
                if (tempUnscaledTime - lastSaveCharacterTime > autoSaveDuration)
                {
                    StartCoroutine(SaveCharactersRoutine());
                    lastSaveCharacterTime = tempUnscaledTime;
                }
                if (tempUnscaledTime - lastSaveBuildingTime > autoSaveDuration)
                {
                    StartCoroutine(SaveBuildingsRoutine());
                    lastSaveBuildingTime = tempUnscaledTime;
                }
            }
        }
Esempio n. 6
0
        protected override void Update()
        {
            base.Update();
            if (IsServer && CentralAppServerRegister.IsRegisteredToCentralServer)
            {
                if (mainThreadActions.Count > 0)
                {
                    lock (mainThreadLock)
                    {
                        foreach (var actions in mainThreadActions)
                        {
                            actions.Invoke();
                        }

                        mainThreadActions.Clear();
                    }
                }
            }
            if (IsServer)
            {
                CentralAppServerRegister.Update();
            }
        }