示例#1
0
        protected virtual void OnEnable()
        {
            //Cache singletons
            if (m_NetManager == null)
            {
                m_NetManager = NetworkManager.s_Instance;
            }
            if (m_MenuUi == null)
            {
                m_MenuUi = MainMenuUI.s_Instance;
            }

            //Reset pages
            m_CurrentPage  = 0;
            m_PreviousPage = 0;

            ClearUi();

            m_NoServerFound.SetActive(false);
            m_NextRefreshTime = Time.time;

            if (m_NetManager != null)
            {
                m_NetManager.clientDisconnected += OnDisconnect;
                m_NetManager.clientError        += OnError;
                m_NetManager.serverError        += OnError;
                m_NetManager.matchDropped       += OnDrop;
            }
        }
        //Fired when player clicks join
        private void JoinMatch(NetworkID networkId, String matchName)
        {
            MainMenuUI menuUi = MainMenuUI.s_Instance;

            menuUi.ShowConnectingModal(true);

            m_NetManager.JoinMatchmakingGame(networkId, (success, matchInfo) =>
            {
                //Failure flow
                if (!success)
                {
                    menuUi.ShowInfoPopup("Failed to join game.", null);
                }
                //Success flow
                else
                {
                    menuUi.HideInfoPopup();
                    menuUi.ShowInfoPopup("Entering lobby...");
                    m_NetManager.gameModeUpdated += menuUi.ShowLobbyPanelForConnection;

                    // Agora.io Implimentation
                    var channelName       = matchName;                                  // testing --> prod use: matchName
                    IRtcEngine mRtcEngine = IRtcEngine.GetEngine(AgoraInterface.appId); // Get a reference to the Engine
                    mRtcEngine.JoinChannel(channelName, "extra", 0);                    // join the channel with given match name

                    // testing
                    string joinChannelMessage = string.Format("joining channel: {0}", channelName);
                    Debug.Log(joinChannelMessage);
                }
            }
                                             );
        }
示例#3
0
        protected virtual void OnDrop()
        {
            MainMenuUI menuUi = MainMenuUI.s_Instance;

            if (menuUi != null)
            {
                menuUi.ShowDefaultPanel();
                menuUi.ShowInfoPopup("Disconnected from server", null);
            }

            if (m_NetManager != null)
            {
                m_NetManager.Disconnect();
            }
        }
示例#4
0
        protected virtual void OnError(NetworkConnection conn, int errorCode)
        {
            MainMenuUI menuUi = MainMenuUI.s_Instance;

            if (menuUi != null)
            {
                menuUi.ShowDefaultPanel();
                menuUi.ShowInfoPopup("A connection error occurred", null);
            }

            if (m_NetManager != null)
            {
                m_NetManager.Disconnect();
            }
        }
示例#5
0
        protected virtual void OnEnable()
        {
            //Get fresh references to controllers
            m_NetManager = NetworkManager.s_Instance;
            m_MenuUi     = MainMenuUI.s_Instance;

            m_MedalCount.text = "";

            if (PlayerDataManager.s_Instance.lastLevelSelected < 0)
            {
                m_CurrentIndex = GetFirstUnplayedLevelIndex();
            }
            else
            {
                m_CurrentIndex = PlayerDataManager.s_Instance.lastLevelSelected;
            }

            AssignByIndex();
        }
示例#6
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();
        }
示例#7
0
        //Fired when player clicks join
        private void JoinMatch(NetworkID networkId)
        {
            MainMenuUI menuUi = MainMenuUI.s_Instance;

            menuUi.ShowConnectingModal(true);

            m_NetManager.JoinMatchmakingGame(networkId, (success, matchInfo) =>
            {
                if (!success)
                {
                    menuUi.ShowInfoPopup("Failed to join game.", null);
                }
                else
                {
                    menuUi.HideInfoPopup();
                    menuUi.ShowInfoPopup("Entering lobby...");
                    m_NetManager.gameModeUpdated += menuUi.ShowLobbyPanelForConnection;
                }
            });
        }
示例#8
0
        protected virtual void OnEnable()
        {
            //Get fresh references to controllers
            m_NetManager = NetworkManager.s_Instance;
            m_MenuUi     = MainMenuUI.s_Instance;

            //Get current medals earned from player data and assign to the counter on screen.
            m_TotalMedalCount = PlayerDataManager.s_Instance.GetTotalMedalCount();
            m_MedalCount.text = m_TotalMedalCount.ToString();

            if (PlayerDataManager.s_Instance.lastLevelSelected < 0)
            {
                //If our last level selected is -1, scan for the first unlocked level without medals earned.
                //(This will be on first run and when returning from a completed mission).
                m_CurrentIndex = GetFirstUnplayedLevelIndex();
            }
            else
            {
                //Otherwise set the current index to the last mission we had selected.
                m_CurrentIndex = PlayerDataManager.s_Instance.lastLevelSelected;
            }

            AssignByIndex();
        }
示例#9
0
        //Fired when player clicks join
        private void JoinMatch(NetworkID networkId, string channelName)
        {
            MainMenuUI menuUi = MainMenuUI.s_Instance;

            menuUi.ShowConnectingModal(true);

            m_NetManager.JoinMatchmakingGame(networkId, (success, matchInfo) =>
            {
                //Failure flow
                if (!success)
                {
                    menuUi.ShowInfoPopup("Failed to join game.", null);
                }
                //Success flow
                else
                {
                    menuUi.HideInfoPopup();
                    menuUi.ShowInfoPopup("Entering lobby...");
                    m_NetManager.gameModeUpdated += menuUi.ShowLobbyPanelForConnection;

                    AgoraVideoController.instance.JoinChannel(channelName);
                }
            });
        }
示例#10
0
 protected virtual void Start()
 {
     m_MenuUi     = MainMenuUI.s_Instance;
     m_NetManager = NetworkManager.s_Instance;
 }