Exemplo n.º 1
0
        public override void OnActivate(int pinID)
        {
            if (pinID != 0 && pinID != 3)
            {
                return;
            }
            MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance;

            instance.TimeOutSec           = this.TimeOutSec;
            instance.SendRoomMessageFlush = this.FlushRoomMsg;
            instance.DisconnectIfSendRoomMessageFailed = this.DisconnectIfSendFailed;
            instance.SortRoomMessage = this.SortRoomMsg;
            if (instance.CurrentState == MyPhoton.MyState.LOBBY)
            {
                DebugUtility.Log("already enter lobby");
                this.Success();
            }
            else
            {
                ((Behaviour)this).set_enabled(true);
                if (instance.CurrentState != MyPhoton.MyState.NOP)
                {
                    instance.Disconnect();
                }
                this.mStateMachine = new StateMachine <FlowNode_MultiPlayEnterLobby>(this);
                if (pinID == 0)
                {
                    this.mStateMachine.GotoState <FlowNode_MultiPlayEnterLobby.State_ConnectLobby>();
                }
                else
                {
                    this.mStateMachine.GotoState <FlowNode_MultiPlayEnterLobby.State_ConnectLobbyAuto>();
                }
            }
        }
 private void Failure()
 {
   ((Behaviour) this).set_enabled(false);
   MyPhoton instance = PunMonoSingleton<MyPhoton>.Instance;
   if (instance.CurrentState != MyPhoton.MyState.NOP)
     instance.Disconnect();
   this.ActivateOutputLinks(2);
   DebugUtility.Log("Create/Join Room Failure.");
 }
            public override void Update(FlowNode_StartMultiPlay self)
            {
                MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance;

                if (instance.CurrentState != MyPhoton.MyState.ROOM)
                {
                    self.Failure();
                }
                else
                {
                    MyPhoton.MyRoom currentRoom = instance.GetCurrentRoom();
                    if (currentRoom == null)
                    {
                        self.Failure();
                    }
                    else
                    {
                        JSON_MyPhotonRoomParam myPhotonRoomParam = !string.IsNullOrEmpty(currentRoom.json) ? JSON_MyPhotonRoomParam.Parse(currentRoom.json) : (JSON_MyPhotonRoomParam)null;
                        if (myPhotonRoomParam == null)
                        {
                            self.Failure();
                        }
                        else
                        {
                            if (myPhotonRoomParam.started == 0)
                            {
                                myPhotonRoomParam.started = 1;
                                instance.SetRoomParam(myPhotonRoomParam.Serialize());
                            }
                            if ((double)this.mStartWait > 0.0)
                            {
                                this.mStartWait -= Time.get_deltaTime();
                                if ((double)this.mStartWait > 0.0)
                                {
                                    return;
                                }
                                GlobalVars.SelectedQuestID  = myPhotonRoomParam.iname;
                                GlobalVars.SelectedFriendID = (string)null;
                                GlobalVars.SelectedFriend   = (FriendData)null;
                                GlobalVars.SelectedSupport.Set((SupportData)null);
                                self.Success();
                                DebugUtility.Log("StartMultiPlay: " + myPhotonRoomParam.Serialize());
                            }
                            else if ((double)this.mWait > 0.0)
                            {
                                this.mWait -= Time.get_deltaTime();
                            }
                            else
                            {
                                List <MyPhoton.MyPlayer> roomPlayerList = instance.GetRoomPlayerList();
                                if (this.mConfirm)
                                {
                                    using (List <MyPhoton.MyPlayer> .Enumerator enumerator = roomPlayerList.GetEnumerator())
                                    {
                                        while (enumerator.MoveNext())
                                        {
                                            if (JSON_MyPhotonPlayerParam.Parse(enumerator.Current.json).state != 3)
                                            {
                                                return;
                                            }
                                        }
                                    }
                                    this.mStartWait = 0.1f;
                                }
                                else
                                {
                                    MyPhoton.MyPlayer myPlayer = instance.GetMyPlayer();
                                    if (this.mRecvList.Count <= 0)
                                    {
                                        this.mSend.senderPlayerID = myPlayer.playerID;
                                        List <JSON_MyPhotonPlayerParam> photonPlayerParamList = new List <JSON_MyPhotonPlayerParam>();
                                        for (int index = 0; index < roomPlayerList.Count; ++index)
                                        {
                                            JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(roomPlayerList[index].json);
                                            photonPlayerParamList.Add(photonPlayerParam);
                                        }
                                        photonPlayerParamList.Sort((Comparison <JSON_MyPhotonPlayerParam>)((a, b) => a.playerIndex - b.playerIndex));
                                        this.mSend.playerListJson = new FlowNode_StartMultiPlay.PlayerList()
                                        {
                                            players = photonPlayerParamList.ToArray()
                                        }.Serialize();
                                        string msg = this.mSend.Serialize();
                                        DebugUtility.Log("[PUN] send started player list: " + msg);
                                        instance.SendRoomMessage(true, msg, MyPhoton.SEND_TYPE.Normal);
                                        this.mRecvList.Add(this.mSend);
                                    }
                                    List <MyPhoton.MyEvent> events = instance.GetEvents();
                                    for (int index = events.Count - 1; index >= 0; --index)
                                    {
                                        FlowNode_StartMultiPlay.State_GameStart.RecvData jsonObject = JSONParser.parseJSONObject <FlowNode_StartMultiPlay.State_GameStart.RecvData>(events[index].json);
                                        if (jsonObject == null || jsonObject.version < this.mSend.version)
                                        {
                                            DebugUtility.LogError("[PUN] started player list version error: " + events[index].json);
                                            instance.Disconnect();
                                            return;
                                        }
                                        if (jsonObject.version <= this.mSend.version)
                                        {
                                            jsonObject.senderPlayerID = events[index].playerID;
                                            DebugUtility.Log("[PUN] recv started player list: " + events[index].json);
                                            this.mRecvList.Add(jsonObject);
                                            events.Remove(events[index]);
                                        }
                                    }
                                    // ISSUE: object of a compiler-generated type is created
                                    // ISSUE: variable of a compiler-generated type
                                    FlowNode_StartMultiPlay.State_GameStart.\u003CUpdate\u003Ec__AnonStorey217 updateCAnonStorey217 = new FlowNode_StartMultiPlay.State_GameStart.\u003CUpdate\u003Ec__AnonStorey217();
                                    using (List <MyPhoton.MyPlayer> .Enumerator enumerator = roomPlayerList.GetEnumerator())
                                    {
                                        while (enumerator.MoveNext())
                                        {
                                            // ISSUE: reference to a compiler-generated field
                                            updateCAnonStorey217.p = enumerator.Current;
                                            // ISSUE: reference to a compiler-generated method
                                            if (this.mRecvList.FindIndex(new Predicate <FlowNode_StartMultiPlay.State_GameStart.RecvData>(updateCAnonStorey217.\u003C\u003Em__212)) < 0)
                                            {
                                                return;
                                            }
                                        }
                                    }
                                    bool flag = true;
                                    using (List <FlowNode_StartMultiPlay.State_GameStart.RecvData> .Enumerator enumerator = this.mRecvList.GetEnumerator())
                                    {
                                        while (enumerator.MoveNext())
                                        {
                                            if (!enumerator.Current.playerListJson.Equals(this.mSend.playerListJson))
                                            {
                                                flag = false;
                                                break;
                                            }
                                        }
                                    }
                                    if (!flag)
                                    {
                                        DebugUtility.Log("[PUN] started player list is not equal. ver:" + (object)this.mSend.version);
                                        this.mRecvList.Clear();
                                        ++this.mSend.version;
                                        this.mWait = 1f;
                                    }
                                    else
                                    {
                                        DebugUtility.Log("[PUN]started player list decided. ver:" + (object)this.mSend.version);
                                        List <JSON_MyPhotonPlayerParam> myPlayersStarted = instance.GetMyPlayersStarted();
                                        myPlayersStarted.Clear();
                                        foreach (JSON_MyPhotonPlayerParam player in JSONParser.parseJSONObject <FlowNode_StartMultiPlay.PlayerList>(this.mSend.playerListJson).players)
                                        {
                                            player.SetupUnits();
                                            myPlayersStarted.Add(player);
                                        }
                                        if (instance.IsOldestPlayer())
                                        {
                                            instance.AddRoomParam("started", this.mSend.playerListJson);
                                        }
                                        if (events.Count > 0)
                                        {
                                            DebugUtility.LogError("[PUN] event must be empty.");
                                        }
                                        events.Clear();
                                        JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(myPlayer.json);
                                        photonPlayerParam.state = 3;
                                        instance.SetMyPlayerParam(photonPlayerParam.Serialize());
                                        this.mConfirm = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
Exemplo n.º 4
0
            public override void Update(FlowNode_StartMultiPlay self)
            {
                MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance;

                if (instance.CurrentState != MyPhoton.MyState.ROOM)
                {
                    self.Failure();
                }
                else
                {
                    MyPhoton.MyRoom currentRoom = instance.GetCurrentRoom();
                    if (currentRoom == null)
                    {
                        self.Failure();
                    }
                    else
                    {
                        JSON_MyPhotonRoomParam myPhotonRoomParam = !string.IsNullOrEmpty(currentRoom.json) ? JSON_MyPhotonRoomParam.Parse(currentRoom.json) : (JSON_MyPhotonRoomParam)null;
                        if (myPhotonRoomParam == null)
                        {
                            self.Failure();
                        }
                        else
                        {
                            if (myPhotonRoomParam.started == 0)
                            {
                                myPhotonRoomParam.started = 1;
                                instance.SetRoomParam(myPhotonRoomParam.Serialize());
                            }
                            if ((double)this.mStartWait > 0.0)
                            {
                                this.mStartWait -= Time.get_deltaTime();
                                if ((double)this.mStartWait > 0.0)
                                {
                                    return;
                                }
                                GlobalVars.SelectedQuestID  = myPhotonRoomParam.iname;
                                GlobalVars.SelectedFriendID = (string)null;
                                GlobalVars.SelectedFriend   = (FriendData)null;
                                GlobalVars.SelectedSupport.Set((SupportData)null);
                                self.Success();
                                DebugUtility.Log("StartMultiPlay: " + myPhotonRoomParam.Serialize());
                            }
                            else if ((double)this.mWait > 0.0)
                            {
                                this.mWait -= Time.get_deltaTime();
                            }
                            else
                            {
                                List <MyPhoton.MyPlayer> roomPlayerList = instance.GetRoomPlayerList();
                                if ((myPhotonRoomParam.type == 1 || myPhotonRoomParam.type == 3) && roomPlayerList.Count == 1)
                                {
                                    self.FailureStartMulti();
                                }
                                else if (this.mConfirm)
                                {
                                    using (List <MyPhoton.MyPlayer> .Enumerator enumerator = roomPlayerList.GetEnumerator())
                                    {
                                        while (enumerator.MoveNext())
                                        {
                                            JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(enumerator.Current.json);
                                            if (photonPlayerParam.state != 3)
                                            {
                                                return;
                                            }
                                            if (photonPlayerParam.state < 2)
                                            {
                                                self.Failure();
                                                return;
                                            }
                                        }
                                    }
                                    this.mStartWait = 0.1f;
                                }
                                else
                                {
                                    MyPhoton.MyPlayer myPlayer = instance.GetMyPlayer();
                                    if (this.mRecvList.Count <= 0)
                                    {
                                        this.mSend.senderPlayerID = myPlayer.photonPlayerID;
                                        this.mSend.playerListJson = (string)null;
                                        List <JSON_MyPhotonPlayerParam> photonPlayerParamList = new List <JSON_MyPhotonPlayerParam>();
                                        for (int index = 0; index < roomPlayerList.Count; ++index)
                                        {
                                            JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(roomPlayerList[index].json);
                                            photonPlayerParamList.Add(photonPlayerParam);
                                        }
                                        photonPlayerParamList.Sort((Comparison <JSON_MyPhotonPlayerParam>)((a, b) => a.playerIndex - b.playerIndex));
                                        FlowNode_StartMultiPlay.PlayerList playerList = new FlowNode_StartMultiPlay.PlayerList();
                                        playerList.players = photonPlayerParamList.ToArray();
                                        Json_MyPhotonPlayerBinaryParam[] playerBinaryParamArray = new Json_MyPhotonPlayerBinaryParam[playerList.players.Length];
                                        for (int index = 0; index < playerList.players.Length; ++index)
                                        {
                                            playerList.players[index].CreateJsonUnitData();
                                            playerBinaryParamArray[index] = new Json_MyPhotonPlayerBinaryParam();
                                            playerBinaryParamArray[index].Set(playerList.players[index]);
                                        }
                                        this.mSend.playerList = playerBinaryParamArray;
                                        byte[] msg = GameUtility.Object2Binary <FlowNode_StartMultiPlay.RecvData>(this.mSend);
                                        instance.SendRoomMessageBinary(true, msg, MyPhoton.SEND_TYPE.Sync, false);
                                        this.mRecvList.Add(this.mSend);
                                        this.mSend.playerListJson = playerList.Serialize();
                                    }
                                    List <MyPhoton.MyEvent> events = instance.GetEvents();
                                    for (int index = events.Count - 1; index >= 0; --index)
                                    {
                                        FlowNode_StartMultiPlay.RecvData buffer = (FlowNode_StartMultiPlay.RecvData)null;
                                        if (!GameUtility.Binary2Object <FlowNode_StartMultiPlay.RecvData>(out buffer, events[index].binary))
                                        {
                                            DebugUtility.LogError("[PUN] started player list version error: " + events[index].json);
                                            instance.Disconnect();
                                            return;
                                        }
                                        if (buffer == null || buffer.version < this.mSend.version)
                                        {
                                            DebugUtility.LogError("[PUN] started player list version error: " + events[index].json);
                                            instance.Disconnect();
                                            return;
                                        }
                                        if (buffer.version <= this.mSend.version)
                                        {
                                            buffer.senderPlayerID = events[index].playerID;
                                            DebugUtility.Log("[PUN] recv started player list: " + events[index].json);
                                            this.mRecvList.Add(buffer);
                                            events.Remove(events[index]);
                                        }
                                    }
                                    using (List <MyPhoton.MyPlayer> .Enumerator enumerator = roomPlayerList.GetEnumerator())
                                    {
                                        while (enumerator.MoveNext())
                                        {
                                            MyPhoton.MyPlayer p = enumerator.Current;
                                            if (this.mRecvList.FindIndex((Predicate <FlowNode_StartMultiPlay.RecvData>)(r => r.senderPlayerID == p.photonPlayerID)) < 0)
                                            {
                                                return;
                                            }
                                        }
                                    }
                                    bool flag = true;
                                    using (List <FlowNode_StartMultiPlay.RecvData> .Enumerator enumerator = this.mRecvList.GetEnumerator())
                                    {
                                        while (enumerator.MoveNext())
                                        {
                                            FlowNode_StartMultiPlay.RecvData current = enumerator.Current;
                                            if (current.playerList.Length == this.mSend.playerList.Length)
                                            {
                                                for (int index = 0; index < this.mSend.playerList.Length; ++index)
                                                {
                                                    if (!Json_MyPhotonPlayerBinaryParam.IsEqual(current.playerList[index], this.mSend.playerList[index]))
                                                    {
                                                        flag = false;
                                                    }
                                                }
                                                if (!flag)
                                                {
                                                    break;
                                                }
                                            }
                                            else
                                            {
                                                flag = false;
                                                break;
                                            }
                                        }
                                    }
                                    if (!flag)
                                    {
                                        DebugUtility.Log("[PUN] started player list is not equal. ver:" + (object)this.mSend.version);
                                        this.mRecvList.Clear();
                                        ++this.mSend.version;
                                        this.mWait = 1f;
                                    }
                                    else
                                    {
                                        DebugUtility.Log("[PUN]started player list decided. ver:" + (object)this.mSend.version);
                                        List <JSON_MyPhotonPlayerParam> myPlayersStarted = instance.GetMyPlayersStarted();
                                        myPlayersStarted.Clear();
                                        foreach (JSON_MyPhotonPlayerParam player in JSONParser.parseJSONObject <FlowNode_StartMultiPlay.PlayerList>(this.mSend.playerListJson).players)
                                        {
                                            player.SetupUnits();
                                            myPlayersStarted.Add(player);
                                        }
                                        if (instance.IsOldestPlayer())
                                        {
                                            instance.UpdateRoomParam("started", (object)this.mSend.playerListJson);
                                        }
                                        if (events.Count > 0)
                                        {
                                            DebugUtility.LogError("[PUN] event must be empty.");
                                        }
                                        events.Clear();
                                        JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(myPlayer.json);
                                        photonPlayerParam.state = 3;
                                        instance.SetMyPlayerParam(photonPlayerParam.Serialize());
                                        this.mConfirm = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
Exemplo n.º 5
0
        private void Update()
        {
            MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance;

            if (this.mIgnore)
            {
                return;
            }
            if (instance.CurrentState != MyPhoton.MyState.ROOM)
            {
                if (instance.CurrentState != MyPhoton.MyState.NOP)
                {
                    instance.Disconnect();
                }
                this.ActivateOutputLinks(1);
            }
            else
            {
                List <MyPhoton.MyPlayer> roomPlayerList = instance.GetRoomPlayerList();
                bool flag1 = GlobalVars.SelectedMultiPlayRoomType == JSON_MyPhotonRoomParam.EType.RAID;
                bool flag2 = GlobalVars.SelectedMultiPlayRoomType == JSON_MyPhotonRoomParam.EType.VERSUS && GlobalVars.SelectedMultiPlayVersusType == VERSUS_TYPE.Friend;
                bool flag3 = GlobalVars.SelectedMultiPlayRoomType == JSON_MyPhotonRoomParam.EType.TOWER;
                if (roomPlayerList.Find((Predicate <MyPhoton.MyPlayer>)(p => p.playerID == 1)) == null && (flag1 || flag2 || flag3))
                {
                    this.ActivateOutputLinks(7);
                }
                else
                {
                    MyPhoton.MyRoom currentRoom = instance.GetCurrentRoom();
                    if (instance.IsUpdateRoomProperty)
                    {
                        if (currentRoom.start)
                        {
                            this.ActivateOutputLinks(5);
                            return;
                        }
                        instance.IsUpdateRoomProperty = false;
                    }
                    JSON_MyPhotonRoomParam myPhotonRoomParam = JSON_MyPhotonRoomParam.Parse(currentRoom.json);
                    string str1 = myPhotonRoomParam != null ? myPhotonRoomParam.comment : string.Empty;
                    if (!this.mRoomComment.Equals(str1))
                    {
                        DebugUtility.Log("change room comment");
                        this.ActivateOutputLinks(6);
                    }
                    this.mRoomComment = str1;
                    string str2 = myPhotonRoomParam != null ? myPhotonRoomParam.passCode : string.Empty;
                    if (!this.mRoomPass.Equals(str2))
                    {
                        DebugUtility.Log("change room pass");
                        this.ActivateOutputLinks(50);
                    }
                    this.mRoomPass = str2;
                    bool flag4 = false;
                    if (roomPlayerList == null)
                    {
                        instance.Disconnect();
                    }
                    else if (this.mPlayers == null)
                    {
                        flag4 = true;
                    }
                    else if (this.mPlayers.Count != roomPlayerList.Count)
                    {
                        flag4 = true;
                    }
                    else
                    {
                        for (int index = 0; index < this.mPlayers.Count; ++index)
                        {
                            if (this.mPlayers[index].playerID != roomPlayerList[index].playerID)
                            {
                                flag4 = true;
                                break;
                            }
                            if (!this.mPlayers[index].json.Equals(roomPlayerList[index].json))
                            {
                                flag4 = true;
                                break;
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(this.mQuestName) && !this.mQuestName.Equals(myPhotonRoomParam.iname))
                    {
                        DebugUtility.Log("change quest iname" + myPhotonRoomParam.iname);
                        this.ActivateOutputLinks(10);
                    }
                    this.mQuestName = myPhotonRoomParam.iname;
                    if (flag4)
                    {
                        this.mPlayers = new List <MyPhoton.MyPlayer>((IEnumerable <MyPhoton.MyPlayer>)roomPlayerList);
                        this.ActivateOutputLinks(2);
                        if (instance.IsOldestPlayer())
                        {
                            JSON_MyPhotonPlayerParam[] photonPlayerParamArray = new JSON_MyPhotonPlayerParam[roomPlayerList.Count];
                            for (int index = 0; index < photonPlayerParamArray.Length; ++index)
                            {
                                photonPlayerParamArray[index] = JSON_MyPhotonPlayerParam.Parse(roomPlayerList[index].json);
                            }
                            myPhotonRoomParam.players = photonPlayerParamArray;
                            instance.SetRoomParam(myPhotonRoomParam.Serialize());
                        }
                        bool flag5 = true;
                        using (List <MyPhoton.MyPlayer> .Enumerator enumerator = this.mPlayers.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(enumerator.Current.json);
                                if (photonPlayerParam.state == 0 || photonPlayerParam.state == 4 || photonPlayerParam.state == 5)
                                {
                                    flag5 = false;
                                    break;
                                }
                            }
                        }
                        if (flag5)
                        {
                            this.ActivateOutputLinks(3);
                        }
                        else
                        {
                            this.ActivateOutputLinks(4);
                        }
                    }
                    else
                    {
                        int count = instance.GetRoomPlayerList().Count;
                        if (count == 1 && this.mMemberCnt != count)
                        {
                            this.ActivateOutputLinks(9);
                        }
                        this.mMemberCnt = instance.GetRoomPlayerList().Count;
                        if (this.mIgnoreFullMember || instance.GetCurrentRoom().maxPlayers - 1 != count)
                        {
                            return;
                        }
                        this.ActivateOutputLinks(8);
                    }
                }
            }
        }