// -----------------------------------------------------------------------------------
    //
    // -----------------------------------------------------------------------------------
    private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        UnityEngine.Debug.LogWarning("OnSceneLoaded: " + scene.name);

        // server started and loaded the requested scene?
        int index = ParseSceneIndexFromArgs();

        // Server
        if (NetworkServer.active && scenesToSpawn[index] == scene.name)
        {
            // write online time every few seconds and check main zone alive every few seconds
            print("[Zones]: starting online alive check for zone: " + scene.name);
            InvokeRepeating("AliveCheck", timeoutInterval, timeoutInterval);
        }

        // Client
        // client started and needs to automatically connect?
        if (autoConnectClient)
        {
            int sceneIndex = scenesToSpawn.ToList().FindIndex(x => x.SceneName == scene.name);
            transport.port = (ushort)(originalPort + sceneIndex);
            print("[Zones]: automatically connecting client to new server at port: " + transport.port);
            //manager.onlineScene = scene.name; DO NOT DO THIS! will cause client to reload scene again, causing unet bugs
            manager.StartClient(); // loads new scene automatically
            UCE_UI_Tools.FadeInScreen(1.0f);
            autoConnectClient = false;
        }
    }
    // -----------------------------------------------------------------------------------
    //
    // -----------------------------------------------------------------------------------
    public void OnClientSwitchServerRequested(NetworkConnection connection, SwitchServerMsg message)
    {
        print("OnClientSwitchServerRequested: " + message.scenePath);

        // only on client
        if (!NetworkServer.active)
        {
            UCE_UI_Tools.FadeOutScreen(false);

            print("[Zones]: disconnecting from current server");
            manager.StopClient();

            NetworkClient.Shutdown();
            NetworkManager.Shutdown();          // clears singleton too
            NetworkManager.singleton = manager; // setup singleton again

            print("[Zones]: loading required scene: " + message.scenePath);
            autoSelectCharacter = message.characterName;

            string sceneName = Path.GetFileNameWithoutExtension(message.scenePath);

            SceneManager.LoadScene(sceneName);
            autoConnectClient = true;
        }
    }
    // -----------------------------------------------------------------------------------
    // Show
    // -----------------------------------------------------------------------------------
    public void Show()
    {
        Player player = Player.localPlayer;

        if (!player)
        {
            return;
        }

        for (int i = 0; i < content.childCount; ++i)
        {
            Destroy(content.GetChild(i).gameObject);
        }

        UCE_Area_Timegate Timegate = player.UCE_myTimegate;

        if (Timegate)
        {
            validateTimegate();
            if (okTimegate)
            {
                TimegateButton.GetComponentInChildren <Text>().text = MSG_TIMEGATE + Timegate.teleportationTarget.name;
            }

            TimegateButton.interactable = okTimegate;

            TimegateButton.onClick.SetListener(() =>
            {
                UCE_UI_Tools.FadeOutScreen();
                player.Cmd_UCE_SimpleTimegate();
            });
        }

        updateTextbox();
        panel.SetActive(true);
    }
Пример #4
0
 public override void OnInteractClient(Player player)
 {
     UCE_UI_Tools.FadeOutScreen(false, 0.25f);
 }