Пример #1
0
        // -------------------------------------------------------------------------------
        // Awake
        // -------------------------------------------------------------------------------
        void Awake()
        {
            singleton = this;

            debug = new DebugHelper();
            debug.Init();

            networkManager   = GetComponent <OpenMMO.Network.NetworkManager>();
            networkTransport = GetComponent <Mirror.TelepathyTransport>();

            originalPort = networkTransport.port;

            SceneManager.sceneLoaded += OnSceneLoaded;

            if (!active || GetIsMainZone || !GetCanSwitchZone)
            {
                currentZone = mainZone;
                debug.LogFormat(this.name, nameof(Awake), "mainZone");         //DEBUG
                return;
            }

            currentZone = subZones[zoneIndex];

            foreach (NetworkZoneTemplate template in subZones)
            {
                if (template == currentZone)
                {
                    InitAsSubZone(template);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// called when quitting the application by closing the window / pressing stop in the editor
        /// <para>virtual so that inheriting classes' OnApplicationQuit() can call base.OnApplicationQuit() too</para>
        /// </summary>
        public virtual void OnApplicationQuit()
        {
            // stop client first
            // (we want to send the quit packet to the server instead of waiting
            //  for a timeout)
            if (NetworkClient.isConnected)
            {
                StopClient();
                print("OnApplicationQuit: stopped client");
            }

            // stop server after stopping client (for proper host mode stopping)
            if (NetworkServer.active)
            {
                StopServer();
                print("OnApplicationQuit: stopped server");
            }

            // stop transport (e.g. to shut down threads)
            // (when pressing Stop in the Editor, Unity keeps threads alive
            //  until we press Start again. so if Transports use threads, we
            //  really want them to end now and not after next start)
            TelepathyTransport telepathy = GetComponent <TelepathyTransport>();

            telepathy.Shutdown();
        }
        // -------------------------------------------------------------------------------
        // Awake
        // -------------------------------------------------------------------------------
        void Awake()
        {
            singleton = this;

            debug = new DebugHelper();
            debug.Init();

            networkManager   = GetComponent <OpenMMO.Network.NetworkManager>();
            networkTransport = GetComponent <Mirror.TelepathyTransport>();

            if (!active || GetIsMainZone || networkManager == null || networkTransport == null)
            {
                return;
            }

            int tmpIndex = 0;

            foreach (NetworkZoneTemplate template in subZones)
            {
                tmpIndex++;

                if (zoneIndex == tmpIndex)
                {
                    InitAsSubZone(template, tmpIndex);
                }
            }
        }
Пример #4
0
    void Awake()
    {
        This = this;

        TeamOneColor = new Color(1, 0, 0, 1);
        TeamTwoColor = new Color(0, 0, 1, 1);

        NM = this.GetComponent <Mirror.NetworkManager>();
        TT = this.GetComponent <Mirror.TelepathyTransport>();
        ND = this.GetComponent <Mirror.Discovery.NetworkDiscovery>();
    }