コード例 #1
0
        // -------------------------------------------------------------------------------
        // 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);
                }
            }
        }
コード例 #2
0
ファイル: ZoneManager.cs プロジェクト: xyberviri/OpenMMO
        // -------------------------------------------------------------------------------
        // 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);
                }
            }
        }
コード例 #3
0
ファイル: NetworkManager.cs プロジェクト: DX4D/OpenMMO
        // -------------------------------------------------------------------------------
        // Awake
        // -------------------------------------------------------------------------------
        /// <summary>
        /// <c>Awake</c> function that sets the singleton and starts the network manager.
        /// </summary>
        public override void Awake()
        {
            singleton = this;
            base.Awake();                     // required

            AwakePriority();                  // must be first

            Invoke(nameof(AwakeLate), 0.25f); // delay a bit so other awakes are called first
        }
コード例 #4
0
        /// <summary>
        /// Removes event listeners from NetworkManager again and clears up NetworkManager reference.
        /// </summary>
        void OnDestroy()
        {
            if (networkManager == null)
            {
                return;
            }

            networkManager.eventListeners.OnStartServer.RemoveListener(OnStartServer);
            networkManager.eventListeners.OnStopServer.RemoveListener(OnStopServer);
            networkManager.eventListeners.OnStopClient.RemoveListener(OnStopClient);
            networkManager = null;
        }
コード例 #5
0
        /// <summary>
        /// Sets reference to NetworkManager and adds event listeners to it.
        /// </summary>
        void Awake()
        {
            singleton = this;

            debug = new DebugHelper();

            if (!GetIsActive)
            {
                return;
            }

            networkManager = FindObjectOfType <OpenMMO.Network.NetworkManager>();

            networkManager.eventListeners.OnStartServer.AddListener(OnStartServer);
            networkManager.eventListeners.OnStopServer.AddListener(OnStopServer);
            networkManager.eventListeners.OnStopClient.AddListener(OnStopClient);
        }
コード例 #6
0
        // -------------------------------------------------------------------------------
        // Awake
        // -------------------------------------------------------------------------------
        public override void Awake()
        {
            singleton = this;
            base.Awake();                                      // required

            this.InvokeInstanceDevExtMethods("AwakePriority"); // must be first

            // -- decide how to start
#if _SERVER && _CLIENT
            StartHost();
#elif _SERVER
            StartServer();
#else
            StartClient();
#endif

            this.InvokeInstanceDevExtMethods(nameof(Awake));             // must be last
        }
コード例 #7
0
        // -------------------------------------------------------------------------------
        // Awake
        // -------------------------------------------------------------------------------
        /// <summary>
        /// <c>Awake</c> function that sets the singleton and starts the network manager.
        /// </summary>
        public override void Awake()
        {
            singleton = this;
            base.Awake();    // required

            AwakePriority(); // must be first

            // -- decide how to start
#if _SERVER && _CLIENT
            StartHost();
#elif _SERVER
            if (GetComponent <PortalManager>() != null && GetComponent <PortalManager>().GetIsMainZone)
            {
                StartServer();
            }
#else
            StartClient();
#endif

            this.InvokeInstanceDevExtMethods(nameof(Awake));             //HOOK // must be last
        }