public bool StartConnect(string appID, bool autoJoin = false, string ver = "1.0") { if (this.mState != MyPhoton.MyState.NOP) { this.mError = MyPhoton.MyError.ILLEGAL_STATE; return(false); } this.CurrentAppID = appID; PhotonNetwork.autoJoinLobby = autoJoin; PhotonNetwork.PhotonServerSettings.AppID = appID; PhotonNetwork.PhotonServerSettings.Protocol = (ConnectionProtocol)1; bool flag = PhotonNetwork.ConnectUsingSettings(ver); if (flag) { this.mState = MyPhoton.MyState.CONNECTING; PhotonNetwork.NetworkStatisticsEnabled = true; } else { this.mState = MyPhoton.MyState.NOP; this.mError = MyPhoton.MyError.UNKNOWN; } this.Log("StartConnect:" + (object)flag); return(flag); }
public bool JoinRoom(string roomName, string playerJson, bool isResume = false) { if (this.mState != MyPhoton.MyState.LOBBY) { this.mError = MyPhoton.MyError.ILLEGAL_STATE; return(false); } PhotonNetwork.player.SetCustomProperties((Hashtable)null, (Hashtable)null, false); PhotonNetwork.SetPlayerCustomProperties((Hashtable)null); this.SetMyPlayerParam(playerJson); bool flag; if (isResume) { flag = PhotonNetwork.JoinRoom(roomName); } else { Hashtable expectedCustomRoomProperties = new Hashtable(); ((Dictionary <object, object>)expectedCustomRoomProperties).Add((object)"name", (object)roomName); ((Dictionary <object, object>)expectedCustomRoomProperties).Add((object)"start", (object)false); flag = PhotonNetwork.JoinRandomRoom(expectedCustomRoomProperties, (byte)0); } if (flag) { this.mState = MyPhoton.MyState.JOINING; } else { this.mError = MyPhoton.MyError.UNKNOWN; } return(flag); }
public bool OpenRoom() { if (this.mState != MyPhoton.MyState.ROOM) { this.mError = MyPhoton.MyError.ILLEGAL_STATE; return(false); } PhotonNetwork.room.IsVisible = true; string empty = string.Empty; if (((Dictionary <object, object>)PhotonNetwork.room.CustomProperties).Count > 0) { Hashtable customProperties = PhotonNetwork.room.CustomProperties; if (customProperties != null && ((Dictionary <object, object>)customProperties).Count > 0) { empty = (string)customProperties.get_Item((object)"json"); } } Hashtable hashtable = new Hashtable(); ((Dictionary <object, object>)hashtable).Add((object)"json", (object)empty); ((Dictionary <object, object>)hashtable).Add((object)"start", (object)false); Hashtable propertiesToSet = hashtable; PhotonNetwork.room.SetCustomProperties((Hashtable)null, (Hashtable)null, false); PhotonNetwork.room.SetCustomProperties(propertiesToSet, (Hashtable)null, false); return(true); }
public bool AddRoomParam(string key, string param) { if (this.mState != MyPhoton.MyState.ROOM) { this.mError = MyPhoton.MyError.ILLEGAL_STATE; return(false); } Room room = PhotonNetwork.room; if (room == null) { return(false); } Hashtable customProperties = room.CustomProperties; Hashtable propertiesToSet = new Hashtable(); if (customProperties != null) { ((Dictionary <object, object>)propertiesToSet).Add((object)"json", customProperties.get_Item((object)"json")); if (((Dictionary <object, object>)customProperties).ContainsKey((object)key)) { return(false); } } ((Dictionary <object, object>)propertiesToSet).Add((object)key, (object)param); room.SetCustomProperties((Hashtable)null, (Hashtable)null, false); room.SetCustomProperties(propertiesToSet, (Hashtable)null, false); return(true); }
public string GetRoomParam(string key) { if (this.mState != MyPhoton.MyState.ROOM) { this.mError = MyPhoton.MyError.ILLEGAL_STATE; return((string)null); } Room room = PhotonNetwork.room; if (room == null) { return((string)null); } Hashtable customProperties = room.CustomProperties; if (customProperties != null) { object obj = (object)null; if (((Dictionary <object, object>)customProperties).TryGetValue((object)key, out obj)) { return((string)obj); } } return((string)null); }
public bool JoinRandomRoom(byte maxplayer, string playerJson, string VersusHash, string roomName = null) { PhotonNetwork.player.SetCustomProperties((Hashtable)null, (Hashtable)null, false); PhotonNetwork.SetPlayerCustomProperties((Hashtable)null); this.SetMyPlayerParam(playerJson); Hashtable hashtable = new Hashtable(); ((Dictionary <object, object>)hashtable).Add((object)"MatchType", (object)VersusHash); Hashtable expectedCustomRoomProperties = hashtable; if (!string.IsNullOrEmpty(roomName)) { ((Dictionary <object, object>)expectedCustomRoomProperties).Add((object)"name", (object)roomName); } bool flag = PhotonNetwork.JoinRandomRoom(expectedCustomRoomProperties, maxplayer); if (flag) { this.mState = MyPhoton.MyState.JOINING; } else { this.mError = MyPhoton.MyError.UNKNOWN; } return(flag); }
public override void OnPhotonJoinRoomFailed(object[] codeAndMsg) { this.Log("Join Room failed."); if (codeAndMsg == null || codeAndMsg.Length < 2 || !(codeAndMsg[0] is IConvertible)) { this.mError = MyPhoton.MyError.UNKNOWN; } else { switch (((IConvertible)codeAndMsg[0]).ToInt32((IFormatProvider)null)) { case 32758: this.mError = MyPhoton.MyError.ROOM_IS_NOT_EXIST; break; case 32764: this.mError = MyPhoton.MyError.ROOM_IS_NOT_OPEN; break; case 32765: this.mError = MyPhoton.MyError.ROOM_IS_FULL; break; default: this.mError = MyPhoton.MyError.UNKNOWN; break; } string str = (string)codeAndMsg[1]; if (str != null) { this.Log("err:" + str); } } this.mState = MyPhoton.MyState.LOBBY; }
public override void OnConnectionFail(DisconnectCause cause) { this.Log("ConnectionFail." + cause.ToString()); if (cause == DisconnectCause.DisconnectByClientTimeout || cause == DisconnectCause.DisconnectByServerTimeout) { this.mError = MyPhoton.MyError.TIMEOUT; } if (cause == DisconnectCause.DisconnectByServerUserLimit) { this.mError = MyPhoton.MyError.FULL_CLIENTS; } this.mState = MyPhoton.MyState.NOP; }
public override void OnPhotonRandomJoinFailed(object[] codeAndMsg) { this.Log("Join Room failed."); if (codeAndMsg == null || codeAndMsg.Length < 2 || !(codeAndMsg[0] is IConvertible)) { this.mError = MyPhoton.MyError.UNKNOWN; } else { this.mError = ((IConvertible)codeAndMsg[0]).ToInt32((IFormatProvider)null) != 32760 ? MyPhoton.MyError.UNKNOWN : MyPhoton.MyError.ROOM_IS_NOT_EXIST; string str = (string)codeAndMsg[1]; if (str != null) { this.Log("err:" + str); } } this.mState = MyPhoton.MyState.LOBBY; }
public bool LeaveRoom() { if (this.mState != MyPhoton.MyState.ROOM) { this.mError = MyPhoton.MyError.ILLEGAL_STATE; return(false); } bool flag = PhotonNetwork.LeaveRoom(); if (flag) { this.mState = MyPhoton.MyState.LEAVING; } else { this.mError = MyPhoton.MyError.UNKNOWN; } return(flag); }
public override void OnPhotonCreateRoomFailed(object[] codeAndMsg) { this.Log("Create Room failed."); if (codeAndMsg == null || codeAndMsg.Length < 2 || !(codeAndMsg[0] is IConvertible)) { this.mError = MyPhoton.MyError.UNKNOWN; this.Log("codeAndMsg is null"); } else { this.mError = ((IConvertible)codeAndMsg[0]).ToInt32((IFormatProvider)null) != 32766 ? MyPhoton.MyError.UNKNOWN : MyPhoton.MyError.ROOM_NAME_DUPLICATED; string str = (string)codeAndMsg[1]; if (str != null) { this.Log("err:" + str); } } this.mState = MyPhoton.MyState.LOBBY; }
public bool SetRoomParam(string json) { if (this.mState != MyPhoton.MyState.ROOM) { this.mError = MyPhoton.MyError.ILLEGAL_STATE; return(false); } Hashtable hashtable = new Hashtable(); ((Dictionary <object, object>)hashtable).Add((object)nameof(json), (object)json); Hashtable propertiesToSet = hashtable; if (PhotonNetwork.room == null) { this.mError = MyPhoton.MyError.ILLEGAL_STATE; return(false); } PhotonNetwork.room.SetCustomProperties(propertiesToSet, (Hashtable)null, false); return(true); }
public bool SendRoomMessage(bool reliable, string msg, MyPhoton.SEND_TYPE eventcode = MyPhoton.SEND_TYPE.Normal) { if (this.mState != MyPhoton.MyState.ROOM) { return(false); } int num = 0; Hashtable hashtable1; if (num == 0) { Hashtable hashtable2 = new Hashtable(); ((Dictionary <object, object>)hashtable2).Add((object)"s", (object)num); ((Dictionary <object, object>)hashtable2).Add((object)"m", (object)msg); hashtable1 = hashtable2; } else { byte[] numArray = MyEncrypt.Encrypt(num + this.GetCryptKey(), msg, true); Hashtable hashtable2 = new Hashtable(); ((Dictionary <object, object>)hashtable2).Add((object)"s", (object)num); ((Dictionary <object, object>)hashtable2).Add((object)"m", (object)numArray); hashtable1 = hashtable2; } if (this.SortRoomMessage) { ((Dictionary <object, object>)hashtable1).Add((object)"sq", (object)this.mSendRoomMessageID); ++this.mSendRoomMessageID; } bool flag = PhotonNetwork.RaiseEvent((byte)eventcode, (object)hashtable1, reliable, (RaiseEventOptions)null); if (!this.DisconnectIfSendRoomMessageFailed || flag) { return(flag); } this.Disconnect(); this.mError = MyPhoton.MyError.RAISE_EVENT_FAILED; DebugUtility.LogError("SendRoomMessage failed!"); return(false); }
private void Update() { if (this.mState == MyPhoton.MyState.NOP) { return; } NetworkReachability internetReachability = Application.get_internetReachability(); if (this.mState != MyPhoton.MyState.NOP && internetReachability != this.mNetworkReach && this.mNetworkReach != null) { this.LogWarning("internet reach change to " + (object)internetReachability + "\n" + this.GetTrafficState()); } this.mNetworkReach = internetReachability; if (this.mState != MyPhoton.MyState.ROOM) { this.mDelaySec = -1f; this.mSendRoomMessageID = 0; } else if ((double)(SupportClass.GetTickCount() - PhotonNetwork.networkingPeer.get_TimestampOfLastSocketReceive()) < (double)this.TimeOutSec * 1000.0) { this.mDelaySec = -1f; } else { if ((double)this.mDelaySec < 0.0) { this.mDelaySec = 0.0f; this.LogWarning(PhotonNetwork.NetworkStatisticsToString() + "\n" + this.GetTrafficState()); } this.mDelaySec += Time.get_deltaTime(); if ((double)this.mDelaySec < (double)this.TimeOutSec) { return; } this.LogWarning("maybe connection lost."); this.LogWarning(PhotonNetwork.NetworkStatisticsToString() + "\n" + this.GetTrafficState()); this.Disconnect(); this.mError = MyPhoton.MyError.TIMEOUT2; } }
public bool JoinRoomCheckParam(string VersusHash, string playerJson, int lvRange, int floorRange, int lv, int floor) { if (this.mState != MyPhoton.MyState.LOBBY) { this.mError = MyPhoton.MyError.ILLEGAL_STATE; return(false); } string roomName = string.Empty; bool flag1 = false; PhotonNetwork.player.SetCustomProperties((Hashtable)null, (Hashtable)null, false); PhotonNetwork.SetPlayerCustomProperties((Hashtable)null); this.SetMyPlayerParam(playerJson); RoomInfo[] roomList = PhotonNetwork.GetRoomList(); List <RoomInfo> roomInfoList = new List <RoomInfo>(); foreach (RoomInfo roomInfo in roomList) { Hashtable customProperties = roomInfo.CustomProperties; if (((Dictionary <object, object>)customProperties).ContainsKey((object)"MatchType") && VersusHash == (string)customProperties.get_Item((object)"MatchType")) { roomInfoList.Add(roomInfo); } } if (lvRange != -1) { int num1 = lv - lvRange; int num2 = lv + lvRange; using (List <RoomInfo> .Enumerator enumerator = roomInfoList.GetEnumerator()) { while (enumerator.MoveNext()) { RoomInfo current = enumerator.Current; Hashtable customProperties = current.CustomProperties; if (((Dictionary <object, object>)customProperties).ContainsKey((object)"plv") && ((Dictionary <object, object>)customProperties).ContainsKey((object)nameof(floor))) { int num3 = (int)customProperties.get_Item((object)nameof(floor)); int num4 = (int)customProperties.get_Item((object)"plv"); if (num1 <= num4 && num4 <= num2 && num3 == floor) { roomName = current.Name; flag1 = true; break; } } } } } if (!flag1) { using (List <RoomInfo> .Enumerator enumerator = roomInfoList.GetEnumerator()) { while (enumerator.MoveNext()) { RoomInfo current = enumerator.Current; Hashtable customProperties = current.CustomProperties; if (((Dictionary <object, object>)customProperties).ContainsKey((object)nameof(floor)) && floor == (int)customProperties.get_Item((object)nameof(floor))) { roomName = current.Name; flag1 = true; break; } } } } if (floorRange != -1) { int num1 = floor - floorRange; int num2 = floor + floorRange; using (List <RoomInfo> .Enumerator enumerator = roomInfoList.GetEnumerator()) { while (enumerator.MoveNext()) { RoomInfo current = enumerator.Current; Hashtable customProperties = current.CustomProperties; if (((Dictionary <object, object>)customProperties).ContainsKey((object)nameof(floor))) { int num3 = (int)customProperties.get_Item((object)nameof(floor)); if (num1 <= num3 && num3 <= num2) { roomName = current.Name; flag1 = true; break; } } } } } bool flag2 = false; if (flag1) { flag2 = PhotonNetwork.JoinRoom(roomName); if (flag2) { this.mState = MyPhoton.MyState.JOINING; } else { this.mError = MyPhoton.MyError.UNKNOWN; } } return(flag2); }
public void ResetLastError() { this.mError = MyPhoton.MyError.NOP; }
public bool CreateRoom(int maxPlayerNum, string roomName, string roomJson, string playerJson, string VersusKey = null, int floor = -1, int plv = -1) { if (this.mState != MyPhoton.MyState.LOBBY) { this.mError = MyPhoton.MyError.ILLEGAL_STATE; return(false); } PhotonNetwork.player.SetCustomProperties((Hashtable)null, (Hashtable)null, false); PhotonNetwork.SetPlayerCustomProperties((Hashtable)null); this.SetMyPlayerParam(playerJson); RoomOptions roomOptions1 = new RoomOptions(); roomOptions1.MaxPlayers = (byte)maxPlayerNum; roomOptions1.IsVisible = true; roomOptions1.IsOpen = true; RoomOptions roomOptions2 = roomOptions1; Hashtable hashtable1 = new Hashtable(); ((Dictionary <object, object>)hashtable1).Add((object)"json", (object)roomJson); ((Dictionary <object, object>)hashtable1).Add((object)"name", (object)roomName); ((Dictionary <object, object>)hashtable1).Add((object)"start", (object)false); Hashtable hashtable2 = hashtable1; roomOptions2.CustomRoomProperties = hashtable2; roomOptions1.CustomRoomPropertiesForLobby = new string[3] { "json", "name", "start" }; if (!string.IsNullOrEmpty(VersusKey)) { int length = roomOptions1.CustomRoomPropertiesForLobby.Length; int num1 = roomOptions1.CustomRoomPropertiesForLobby.Length + 2; int num2; int num3 = plv == -1 ? num1 : (num2 = num1 + 1); int newSize = floor == -1 ? num3 : (num2 = num3 + 1); Array.Resize <string>(ref roomOptions1.CustomRoomPropertiesForLobby, newSize); ((Dictionary <object, object>)roomOptions1.CustomRoomProperties).Add((object)"MatchType", (object)VersusKey); string[] propertiesForLobby1 = roomOptions1.CustomRoomPropertiesForLobby; int index1 = length; int num4 = index1 + 1; string str1 = "MatchType"; propertiesForLobby1[index1] = str1; ((Dictionary <object, object>)roomOptions1.CustomRoomProperties).Add((object)"lobby", (object)"vs"); string[] propertiesForLobby2 = roomOptions1.CustomRoomPropertiesForLobby; int index2 = num4; int num5 = index2 + 1; string str2 = "lobby"; propertiesForLobby2[index2] = str2; if (plv != -1) { ((Dictionary <object, object>)roomOptions1.CustomRoomProperties).Add((object)nameof(plv), (object)plv); roomOptions1.CustomRoomPropertiesForLobby[num5++] = nameof(plv); } if (floor != -1) { ((Dictionary <object, object>)roomOptions1.CustomRoomProperties).Add((object)nameof(floor), (object)floor); string[] propertiesForLobby3 = roomOptions1.CustomRoomPropertiesForLobby; int index3 = num5; int num6 = index3 + 1; string str3 = nameof(floor); propertiesForLobby3[index3] = str3; } } else { ((Dictionary <object, object>)roomOptions1.CustomRoomProperties).Add((object)"lobby", (object)"coop"); Array.Resize <string>(ref roomOptions1.CustomRoomPropertiesForLobby, roomOptions1.CustomRoomPropertiesForLobby.Length + 1); roomOptions1.CustomRoomPropertiesForLobby[roomOptions1.CustomRoomPropertiesForLobby.Length - 1] = "lobby"; } bool room = PhotonNetwork.CreateRoom(roomName, roomOptions1, (TypedLobby)null); if (room) { this.mState = MyPhoton.MyState.JOINING; } else { this.mError = MyPhoton.MyError.UNKNOWN; } return(room); }