Пример #1
0
 public override void OnJoinRoomFailed(short returnCode, string message)
 {
     XDebug.Log("On Join Room Failed - code = " + returnCode + "\nMessage = " + message, XDebug.Mask.GameManager, XDebug.Color.Red);
     if (returnCode == (int)JoinRoomFailCode.GameFull)
     {
     }
 }
Пример #2
0
 public override void OnConnectedToMaster()
 {
     XDebug.Log("On Connected to master", XDebug.Mask.GameManager, null);
     //PhotonNetwork.NickName = "Player - " + UnityEngine.Random.Range(0, 9999);
     PhotonNetwork.AutomaticallySyncScene = true;
     MyEventManager.Instance.OnConnectedToMaster.Dispatch();
 }
Пример #3
0
        public void CreateOrJoinRoom()
        {
            Hashtable keyValuePairs = new Hashtable();

            keyValuePairs.Add(RoomPropertyKeys.Key_SkillLevel, GameData.Instance.MinimumSkillLevel);
            keyValuePairs.Add(RoomPropertyKeys.Key_MatchWaitTime, GameData.Instance.MatchWaitTime);
            keyValuePairs.Add(RoomPropertyKeys.Key_RoomCreateTime, PhotonNetwork.ServerTimestamp);
            XDebug.Log("Room Create Time if I create room = " + keyValuePairs[RoomPropertyKeys.Key_RoomCreateTime], XDebug.Mask.GameManager, XDebug.Color.Red);
            GameData.Instance.RoomOptions = DefaultRoomOptions(keyValuePairs);
            //keyValuePairs.Add("ServerTimeStamp", PhotonNetwork.Time);
            //keyValuePairs.Add("delayTime", time);
            //PhotonNetwork.JoinOrCreateRoom("Default Room-" + counter, roomOptions, TypedLobby.Default);
            if (PhotonNetwork.IsConnectedAndReady)
            {
                GameData.Instance.PlayerLevel = UnityEngine.Random.Range(1, 100);
                GameData.Instance.UpdateRoomLevel();
                XDebug.Log("Room Count = " + PhotonNetwork.CountOfRooms + "\nInitial Room Level = " + GameData.Instance.MinimumSkillLevel + "\nPlayer Level = " + GameData.Instance.PlayerLevel);
                if (PhotonNetwork.CountOfRooms < MaximumRoomsUnconditionalJoin)
                {
                    JoinRandomRoom(false);
                }
                else
                {
                    JoinRandomRoom(true);
                }
            }
            else
            {
                RuntimeDebug.Instance.AddLog("Not Ready to join yet");
            }
        }
Пример #4
0
 public override void OnPlayerEnteredRoom(Player newPlayer)
 {
     XDebug.Log("On Player Enter Room - " + newPlayer.NickName, XDebug.Mask.GameManager, XDebug.Color.Green);
     MyEventManager.Instance.OnPlayerJoined.Dispatch();
     if (PhotonNetwork.CurrentRoom.PlayerCount == GameData.Instance.MaxPlayers)
     {
         MyEventManager.Instance.OnGamePlayConditionsMet.Dispatch();
     }
 }
Пример #5
0
 public void OnGameStateUpdated()
 {
     XDebug.Log("Game state updated", XDebug.Mask.MiniMap);
     if (GameStateManager.Instance.GetCurrentGameState() == GameStateManager.GameState.Game)
     {
         ShipTransform = GameData.Instance.PlayerGO.transform;
         XDebug.Log("Ship transform attached", XDebug.Mask.MiniMap);
     }
 }
Пример #6
0
 public override void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged)
 {
     XDebug.Log("Room Properties Update", XDebug.Mask.GameManager, XDebug.Color.Yellow);
     if (propertiesThatChanged.ContainsKey(RoomPropertyKeys.Key_RoomCreateTime))
     {
         GameData.Instance.MatchWaitTime = (PhotonNetwork.ServerTimestamp - ((int)(propertiesThatChanged[RoomPropertyKeys.Key_RoomCreateTime]) / 1000));
     }
     else
     {
     }
 }
Пример #7
0
 public override void OnDisconnected(DisconnectCause cause)
 {
     XDebug.Log("On Disconnected " + cause.ToString(), XDebug.Mask.GameManager, XDebug.Color.Red);
     if (NetworkData.Instance.UserChoiceRegion != null)
     {
         PhotonNetwork.ConnectToRegion(NetworkData.Instance.UserChoiceRegion);
     }
     else
     {
         PhotonNetwork.ConnectUsingSettings();
     }
 }
Пример #8
0
 public void UpdateRegionList(List <Region> regions)
 {
     if (regions != null)
     {
         Regions = new List <Region>(regions);
         MyEventManager.Instance.OnRegionListUpdated.Dispatch();
         //OnRegionListUpdated();
     }
     else
     {
         XDebug.Log("Null List Received\nNothing to Update", XDebug.Mask.NetworkData, XDebug.Color.Red);
     }
 }
Пример #9
0
 /// <summary>
 /// Connect to the Photon Server
 /// </summary>
 private void Connect()
 {
     if (!PhotonNetwork.IsConnected)
     {
         PhotonNetwork.GameVersion = m_GameVersion;
         PhotonNetwork.ConnectUsingSettings();
         XDebug.Log("Connected", null, XDebug.Color.Green);
     }
     else
     {
         XDebug.Log("Not Connected", null, XDebug.Color.Red);
     }
 }
Пример #10
0
        public string makeRequest(Dictionary <string, string> keyValuePairs)
        {
            foreach (string key in keyValuePairs.Keys)
            {
                XDebug.Log("Add param generation logic here");
            }
            HttpWebRequest  request      = (HttpWebRequest)WebRequest.Create(api);
            HttpWebResponse response     = (HttpWebResponse)request.GetResponse();
            StreamReader    reader       = new StreamReader(response.GetResponseStream());
            string          jsonResponse = reader.ReadToEnd();

            return(jsonResponse);
        }
Пример #11
0
 public void UpdateBestRegion()
 {
     if (UserChoiceRegion == null)
     {
         Region bestRegion = PhotonNetwork.NetworkingClient.RegionHandler.BestRegion;
         if (bestRegion != null)
         {
             BestRegion = bestRegion;
             MyEventManager.Instance.OnConnectedToBestRegion.Dispatch();
         }
         else
         {
             XDebug.Log("Null Region Received\nUnable to Update Best Region", XDebug.Mask.NetworkData, XDebug.Color.Red);
         }
     }
     //MainMenu.Instance.OnConnectedToBestRegion();
 }
Пример #12
0
        public override void OnJoinedRoom()
        {
            Room room = PhotonNetwork.CurrentRoom;

            if (room == null)
            {
                XDebug.Log("Implement Menu Manager and add functionality to show main menu again on fail to join room", XDebug.Mask.GameManager, XDebug.Color.Red);
                return;
            }
            if (room != null)
            {
                XDebug.Log("On Join Room - " + room.Name + "Skill Level = " + room.CustomProperties[RoomPropertyKeys.Key_SkillLevel], XDebug.Mask.GameManager, null);
                XDebug.Log("Joined Room Creation Time - " + (int)room.CustomProperties[RoomPropertyKeys.Key_RoomCreateTime], XDebug.Mask.GameManager, null);
                GameData.Instance.MatchWaitTime = (int)room.CustomProperties[RoomPropertyKeys.Key_MatchWaitTime];
                MyEventManager.Instance.OnCreatedOrJoinedRoom.Dispatch();
                //SceneManager.Instance.LoadScene(SceneManager.Scen,e.Game, UnityEngine.SceneManagement.LoadSceneMode.Single);
            }
        }
Пример #13
0
 private void JoinRandomRoom(bool SkillBasedMatchmaking)
 {
     if (!SkillBasedMatchmaking)
     {
         PhotonNetwork.JoinRandomRoom();
     }
     else
     {
         if (GameData.Instance.RoomOptions != null)
         {
             PhotonNetwork.JoinRandomRoom(GameData.Instance.RoomOptions.CustomRoomProperties, GameData.Instance.MaxPlayers);
         }
         else
         {
             XDebug.Log("Room Options Not Defined, Define Room Options First", XDebug.Mask.GameManager, XDebug.Color.Red);
         }
     }
 }
Пример #14
0
 public static void Init()
 {
     if (mInstance != null)
     {
         pStatus = mInstance.GetUnityStatus();
         if (mInstance.RemoteURL.Length > 0)
         {
             mInstance.enabled = true;
         }
         else
         {
             XDebug.Log("Remote URLs are empty, Checking for Unity status, status : " + pStatus, XDebug.Mask.ConnectivityMonitor, XDebug.Color.Yellow);
             pStatus = mInstance.GetUnityStatus();
         }
     }
     else
     {
         XDebug.Log("ConnectivityMonitor instance is null", XDebug.Mask.ConnectivityMonitor, XDebug.Color.Red);
     }
 }
Пример #15
0
 public void UpdateUI()
 {
     Debug.Log("Updating UI");
     if (NetworkData.Instance.RoomList != null && NetworkData.Instance.RoomList.Count > 0)
     {
         int i = 1;
         foreach (RoomInfo roomInfo in NetworkData.Instance.RoomList)
         {
             GameObject matchItem = Instantiate(MatchItemTemplate, parentTransform);
             matchItem.GetComponent <MatchItemTemplate>().TxtSerial.text   = "" + i++;
             matchItem.GetComponent <MatchItemTemplate>().TxtRoomName.text = roomInfo.Name;
             matchItem.GetComponent <MatchItemTemplate>().TxtSize.text     = roomInfo.MaxPlayers.ToString();
             matchItem.GetComponent <MatchItemTemplate>().TxtVacancy.text  = (roomInfo.MaxPlayers - roomInfo.PlayerCount).ToString();
         }
     }
     else
     {
         XDebug.Log("No Rooms Found", XDebug.Mask.MatchList, XDebug.Color.Red);
     }
 }
Пример #16
0
        private IEnumerator CheckConnection(string url)
        {
            m_IsChecking = true;
            using (UnityWebRequest request = UnityWebRequest.Get(url))
            {
                request.timeout = 30;
                yield return(request.SendWebRequest());

                m_IsChecking = false;
                m_Timer      = m_UpdateFrequency;
                if (request.isNetworkError || request.isHttpError || ForceInternetDown)
                {
                    UnityEngine.Debug.LogErrorFormat("Response URL : {0}, Error : {1}, Response Code : {2}", request.url, request.error, request.responseCode);
                    m_RetryCount++;
                    if (m_RetryCount >= MaxRetries)
                    {
                        OnConnectionVerified(false);
                    }
                }
                else
                {
                    XDebug.Log("Response URL : " + request.url + "\nText : " + request.downloadHandler.text + "\nResponse Code : " + request.responseCode, XDebug.Mask.ConnectivityMonitor, XDebug.Color.Yellow);

                    //Call succeeded, now check if the data returned is what we expect.
                    if (request.downloadHandler.text.Equals("true") || request.downloadHandler.text.Equals("true\n"))
                    {
                        OnConnectionVerified(true);
                    }
                    else
                    {
                        //The call was successfull, but content was wrong, this happens in case of ISP login.
                        m_RetryCount++;
                        if (m_RetryCount >= MaxRetries)
                        {
                            OnConnectionVerified(false);
                        }
                    }
                }
            }
        }
Пример #17
0
 public void UpdateGameState(GameState gameState)
 {
     XDebug.Log("Updating Game State", XDebug.Mask.GameStateManager, XDebug.Color.Yellow);
     this.CurrentGameState = gameState;
     MyEventManager.Instance.OnGameStateUpdated.Dispatch();
 }
Пример #18
0
 public override void OnJoinedLobby()
 {
     XDebug.Log("On Joined Lobby", XDebug.Mask.GameManager, null);
 }
Пример #19
0
 public override void OnLobbyStatisticsUpdate(List <TypedLobbyInfo> lobbyStatistics)
 {
     XDebug.Log("On Lobby Statistics Update\nCount = " + lobbyStatistics[0].RoomCount, XDebug.Mask.GameManager, XDebug.Color.Yellow);
 }
Пример #20
0
 public override void OnRoomListUpdate(List <RoomInfo> roomList)
 {
     XDebug.Log("Updated room list", XDebug.Mask.GameManager, XDebug.Color.Yellow);
     NetworkData.Instance.UpdateRoomList(roomList);
 }
Пример #21
0
 public override void OnPlayerLeftRoom(Player otherPlayer)
 {
     XDebug.Log("On Player Left Room - " + otherPlayer.NickName + "\nTotal Player Count = " + PhotonNetwork.CurrentRoom.PlayerCount, XDebug.Mask.GameManager, XDebug.Color.Red);
     MyEventManager.Instance.OnPlayerLeft.Dispatch();
 }
Пример #22
0
 public override void OnConnected()
 {
     base.OnConnected();
     XDebug.Log("On Connected", XDebug.Mask.GameManager, null);
 }
Пример #23
0
 public override void OnCreateRoomFailed(short returnCode, string message)
 {
     XDebug.Log("On Create Room Failed - code = " + returnCode + "\nMessage = " + message, XDebug.Mask.GameManager, XDebug.Color.Red);
 }
Пример #24
0
 public void OnCreatedOrJoinedRoom()
 {
     XDebug.Log("Loading finished...Waiting Scene will be loaded now", XDebug.Mask.MainMenu);
     SceneManager.Instance.LoadScene(SceneManager.Scene.WaitScene, UnityEngine.SceneManagement.LoadSceneMode.Single);
 }
Пример #25
0
 private void Awake()
 {
     XDebug.EnableAllMasks();
 }