Пример #1
0
 //Load the network manager on enable
 protected virtual void OnEnable()
 {
     if (m_NetManager == null)
     {
         m_NetManager = TanksNetworkManager.s_Instance;
     }
 }
Пример #2
0
        /// <summary>
        /// Unity message: Awake
        /// </summary>
        private void Awake()
        {
            //Sets up the singleton instance
            s_Instance = this;

            //Sets up the lists
            m_CrateSpawnerList = new List <CrateSpawner>();
            m_PowerupList      = new List <PickupBase>();
            m_HazardList       = new List <LevelHazard>();

            //Handles instantiating the endgamemodal
            InstantiateEndGameModal(m_MultiplayerGameModal);

            //Cache the NetworkManager instance
            m_NetManager = TanksNetworkManager.s_Instance;

            //Subscribe to events on the Network Manager
            if (m_NetManager != null)
            {
                m_NetManager.clientDisconnected += OnDisconnect;
                m_NetManager.clientError        += OnError;
                m_NetManager.serverError        += OnError;
                m_NetManager.matchDropped       += OnDrop;
            }
        }
Пример #3
0
        public void Init(TanksNetworkPlayer netPlayer)
        {
            Debug.LogFormat("Initializing lobby player - Ready {0}", netPlayer.ready);
            this.m_NetPlayer = netPlayer;
            if (netPlayer != null)
            {
                netPlayer.syncVarsChanged += OnNetworkPlayerSyncvarChanged;
            }

            m_NetManager = TanksNetworkManager.s_Instance;
            if (m_NetManager != null)
            {
                m_NetManager.playerJoined += PlayerJoined;
                m_NetManager.playerLeft   += PlayerLeft;
            }

            m_ReadyLabel.gameObject.SetActive(false);
            m_WaitingLabel.gameObject.SetActive(false);
            m_ReadyButton.gameObject.SetActive(true);
            m_ReadyButton.interactable = m_NetManager.hasSufficientPlayers;

            if (m_NetManager.gameType == NetworkGameType.Singleplayer)
            {
                return;
            }

            MainMenuUI mainMenu = MainMenuUI.s_Instance;

            mainMenu.playerList.AddPlayer(this);
            mainMenu.playerList.DisplayDirectServerWarning(netPlayer.isServer && m_NetManager.matchMaker == null);

            if (netPlayer.hasAuthority)
            {
                SetupLocalPlayer();
            }
            else
            {
                SetupRemotePlayer();
            }

            UpdateValues();
        }
Пример #4
0
        protected virtual void OnEnable()
        {
            //Enable or disable map selection buttons based on whether this is the host or not.
            for (int i = 0; i < m_MapButtons.Length; i++)
            {
                m_MapButtons[i].SetActive(TanksNetworkManager.s_IsServer);
            }

            if (m_NetManager == null)
            {
                m_NetManager = TanksNetworkManager.s_Instance;
            }

            if (m_NetManager != null)
            {
                m_NetManager.clientDisconnected += OnDisconnect;
                m_NetManager.clientError        += OnError;
                m_NetManager.serverError        += OnError;
                m_NetManager.matchDropped       += OnDrop;
            }
        }
Пример #5
0
 protected virtual void Awake()
 {
     s_Instance       = this;
     connectedPlayers = new List <NetworkPlayer>();
     playerList       = new List <GameObject>();
 }