コード例 #1
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 (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;
                                    }
                                }
                            }
                        }
                    }
                }
            }