Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public override void OnJoinedRoom()
 {
     this.Log("Joined Room.");
     this.mEvents.Clear();
     this.mState             = MyPhoton.MyState.ROOM;
     this.mSendRoomMessageID = 0;
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
 public override void OnJoinedLobby()
 {
     this.Log("Joined Lobby.");
     this.mState = MyPhoton.MyState.LOBBY;
     this.mEvents.Clear();
     this.IsRoomListUpdated = false;
 }
Esempio n. 6
0
 public override void OnConnectedToMaster()
 {
     this.Log("Joined Default Lobby.");
     this.mState = MyPhoton.MyState.LOBBY;
     this.mEvents.Clear();
     this.IsRoomListUpdated = false;
 }
Esempio n. 7
0
        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 override void Update(FlowNode_MultiPlayJoinRoom self)
            {
                MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance;

                MyPhoton.MyState currentState = instance.CurrentState;
                if (!((Behaviour)self).get_enabled())
                {
                    return;
                }
                switch (currentState)
                {
                case MyPhoton.MyState.LOBBY:
                    DebugUtility.Log("[PUN]joining failed, back to lobby." + (object)instance.LastError);
                    if (instance.LastError == MyPhoton.MyError.ROOM_IS_FULL)
                    {
                        self.FailureFullMember();
                        break;
                    }
                    self.FailureLobby();
                    break;

                case MyPhoton.MyState.JOINING:
                    break;

                case MyPhoton.MyState.ROOM:
                    GlobalVars.SelectedMultiPlayRoomName = instance.GetCurrentRoom().name;
                    self.GotoState <FlowNode_MultiPlayJoinRoom.State_DecidePlayerIndex>();
                    break;

                default:
                    self.Failure();
                    break;
                }
            }
Esempio n. 9
0
 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;
 }
Esempio n. 10
0
 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;
 }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
 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;
 }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
 public override void OnLeftRoom()
 {
     this.Log("Left Room.");
     this.mState = MyPhoton.MyState.LOBBY;
     this.mEvents.Clear();
 }
Esempio n. 16
0
 public override void OnDisconnectedFromPhoton()
 {
     this.Log("DisconnectedFromPhoton. LostPacket:" + (object)PhotonNetwork.PacketLossByCrcCheck + " MaxResendsBeforeDisconnect:" + (object)PhotonNetwork.MaxResendsBeforeDisconnect + " ResentReliableCommands" + (object)PhotonNetwork.ResentReliableCommands);
     this.mState = MyPhoton.MyState.NOP;
 }