Beispiel #1
0
        public override void OnActivate(int pinID)
        {
            if (!GameUtility.Config_UseAssetBundles.Value)
            {
                this.ActivateOutputLinks(100);
            }
            else
            {
                switch (pinID)
                {
                case 0:
                    MyPhoton pt = PunMonoSingleton <MyPhoton> .Instance;
                    if (UnityEngine.Object.op_Inequality((UnityEngine.Object)pt, (UnityEngine.Object)null))
                    {
                        List <MyPhoton.MyPlayer> roomPlayerList = pt.GetRoomPlayerList();
                        if (roomPlayerList != null && roomPlayerList.Count > 1)
                        {
                            MyPhoton.MyPlayer myPlayer = roomPlayerList.Find((Predicate <MyPhoton.MyPlayer>)(p => p.playerID != pt.GetMyPlayer().playerID));
                            if (myPlayer != null)
                            {
                                this.AddAssets(JSON_MyPhotonPlayerParam.Parse(myPlayer.json));
                                break;
                            }
                            break;
                        }
                        break;
                    }
                    break;

                case 1:
                    GameManager instance = MonoSingleton <GameManager> .Instance;
                    if (instance.AudienceRoom != null)
                    {
                        JSON_MyPhotonRoomParam myPhotonRoomParam = JSON_MyPhotonRoomParam.Parse(instance.AudienceRoom.json);
                        if (myPhotonRoomParam != null)
                        {
                            for (int index = 0; index < myPhotonRoomParam.players.Length; ++index)
                            {
                                if (myPhotonRoomParam.players[index] != null)
                                {
                                    myPhotonRoomParam.players[index].SetupUnits();
                                    this.AddAssets(myPhotonRoomParam.players[index]);
                                }
                            }
                            break;
                        }
                        break;
                    }
                    break;
                }
                this.StartCoroutine(this.AsyncDownload());
            }
        }
            public override void Begin(VersusDraftReady self)
            {
                MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance;
                List <JSON_MyPhotonPlayerParam> myPlayersStarted = instance.GetMyPlayersStarted();
                List <MyPhoton.MyPlayer>        roomPlayerList   = instance.GetRoomPlayerList();

                for (int index1 = 0; index1 < roomPlayerList.Count; ++index1)
                {
                    JSON_MyPhotonPlayerParam param = JSON_MyPhotonPlayerParam.Parse(roomPlayerList[index1].json);
                    int index2 = myPlayersStarted.FindIndex((Predicate <JSON_MyPhotonPlayerParam>)(sp => sp.playerID == param.playerID));
                    if (index2 > -1)
                    {
                        myPlayersStarted[index2] = param;
                    }
                }
                if (roomPlayerList.Count < 2)
                {
                    MyPhoton.MyPlayer        player            = instance.GetMyPlayer();
                    JSON_MyPhotonPlayerParam photonPlayerParam = myPlayersStarted.Find((Predicate <JSON_MyPhotonPlayerParam>)(sp => sp.playerID != player.playerID));
                    int num1 = 0;
                    int num2 = 0;
                    int num3 = 0;
                    List <JSON_MyPhotonPlayerParam.UnitDataElem> unitDataElemList = new List <JSON_MyPhotonPlayerParam.UnitDataElem>();
                    for (int index = 0; index < VersusDraftList.VersusDraftUnitDataListEnemy.Count && index < 3; ++index)
                    {
                        UnitData unitData = VersusDraftList.VersusDraftUnitDataListEnemy[index];
                        if (unitData != null)
                        {
                            unitDataElemList.Add(new JSON_MyPhotonPlayerParam.UnitDataElem()
                            {
                                slotID = num1,
                                place  = index,
                                unit   = unitData
                            });
                            num2 = num2 + (int)unitData.Status.param.atk + (int)unitData.Status.param.mag;
                            num3 = num3 + (int)((double)(int)unitData.Status.param.hp * (double)MonoSingleton <GameManager> .Instance.MasterParam.mStatusCoefficient.HP) + (int)((double)(int)unitData.Status.param.atk * (double)MonoSingleton <GameManager> .Instance.MasterParam.mStatusCoefficient.Attack) + (int)((double)(int)unitData.Status.param.def * (double)MonoSingleton <GameManager> .Instance.MasterParam.mStatusCoefficient.Defense) + (int)((double)(int)unitData.Status.param.mag * (double)MonoSingleton <GameManager> .Instance.MasterParam.mStatusCoefficient.MagAttack) + (int)((double)(int)unitData.Status.param.mnd * (double)MonoSingleton <GameManager> .Instance.MasterParam.mStatusCoefficient.MagDefense) + (int)((double)(int)unitData.Status.param.dex * (double)MonoSingleton <GameManager> .Instance.MasterParam.mStatusCoefficient.Dex) + (int)((double)(int)unitData.Status.param.spd * (double)MonoSingleton <GameManager> .Instance.MasterParam.mStatusCoefficient.Speed) + (int)((double)(int)unitData.Status.param.cri * (double)MonoSingleton <GameManager> .Instance.MasterParam.mStatusCoefficient.Critical) + (int)((double)(int)unitData.Status.param.luk * (double)MonoSingleton <GameManager> .Instance.MasterParam.mStatusCoefficient.Luck) + (int)((double)unitData.GetCombination() * (double)MonoSingleton <GameManager> .Instance.MasterParam.mStatusCoefficient.Combo) + (int)((double)(int)unitData.Status.param.mov * (double)MonoSingleton <GameManager> .Instance.MasterParam.mStatusCoefficient.Move) + (int)((double)(int)unitData.Status.param.jmp * (double)MonoSingleton <GameManager> .Instance.MasterParam.mStatusCoefficient.Jump);
                            ++num1;
                        }
                    }
                    photonPlayerParam.units       = unitDataElemList.ToArray();
                    photonPlayerParam.totalAtk    = num2;
                    photonPlayerParam.totalStatus = Mathf.FloorToInt((float)(num3 / unitDataElemList.Count));
                    photonPlayerParam.draft_id    = -1;
                }
                if (instance.IsOldestPlayer())
                {
                    instance.UpdateRoomParam("started", (object)new FlowNode_StartMultiPlay.PlayerList()
                    {
                        players = myPlayersStarted.ToArray()
                    }.Serialize());
                }
                FlowNode_GameObject.ActivateOutputLinks((Component)self, 3);
            }
 public override void OnActivate(int pinID)
 {
     if (pinID == 100)
     {
         GameManager instance          = MonoSingleton <GameManager> .Instance;
         JSON_MyPhotonPlayerParam data = (JSON_MyPhotonPlayerParam)null;
         if (instance.AudienceMode)
         {
             MyPhoton.MyRoom audienceRoom = instance.AudienceRoom;
             if (audienceRoom != null)
             {
                 JSON_MyPhotonRoomParam myPhotonRoomParam = JSON_MyPhotonRoomParam.Parse(audienceRoom.json);
                 if (myPhotonRoomParam != null && myPhotonRoomParam.players != null && myPhotonRoomParam.players.Length >= this.ROOM_MAX_PLAYERCNT)
                 {
                     data = myPhotonRoomParam.players[!this.MyPlayer ? 1 : 0];
                 }
             }
         }
         else
         {
             MyPhoton pt = PunMonoSingleton <MyPhoton> .Instance;
             List <MyPhoton.MyPlayer> roomPlayerList = pt.GetRoomPlayerList();
             if (roomPlayerList != null)
             {
                 if (this.MyPlayer)
                 {
                     data = JSON_MyPhotonPlayerParam.Create(0, 0);
                 }
                 else
                 {
                     MyPhoton.MyPlayer myPlayer = roomPlayerList.Find((Predicate <MyPhoton.MyPlayer>)(p => p.playerID != pt.GetMyPlayer().playerID));
                     if (myPlayer != null)
                     {
                         data = JSON_MyPhotonPlayerParam.Parse(myPlayer.json);
                     }
                 }
             }
         }
         if (data != null)
         {
             DataSource.Bind <JSON_MyPhotonPlayerParam>(this.BindObj, data);
         }
     }
     this.ActivateOutputLinks(200);
 }
 public override void OnSuccess(WWWResult www)
 {
     if (Network.IsError && Network.ErrCode == Network.EErrCode.VS_EnableTimeOutOfPriod)
     {
         MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance;
         Network.RemoveAPI();
         ((Behaviour)this).set_enabled(false);
         if (instance.IsConnectedInRoom() && instance.GetRoomPlayerList().Count > 1)
         {
             Network.ResetError();
             this.ActivateOutputLinks(this.PIN_SUCCESS);
         }
         else
         {
             this.ActivateOutputLinks(this.PIN_FAILURE);
         }
     }
     else
     {
         GlobalVars.VersusFreeMatchTime = TimeManager.FromDateTime(TimeManager.ServerTime);
         this.Success();
     }
 }
            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;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            public override void Update(FlowNode_StartMultiPlay self)
            {
                DebugUtility.Log("StartMultiPlay State_ResumeStart Update");
                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_MyPhotonPlayerParam photonPlayerParam1 = JSON_MyPhotonPlayerParam.Parse(instance.GetMyPlayer().json);
                        if (photonPlayerParam1.state != 2)
                        {
                            photonPlayerParam1.state = 2;
                            instance.SetMyPlayerParam(photonPlayerParam1.Serialize());
                        }
                        JSON_MyPhotonRoomParam myPhotonRoomParam = !string.IsNullOrEmpty(currentRoom.json) ? JSON_MyPhotonRoomParam.Parse(currentRoom.json) : (JSON_MyPhotonRoomParam)null;
                        if (myPhotonRoomParam == null)
                        {
                            self.Failure();
                        }
                        else
                        {
                            GlobalVars.SelectedQuestID  = myPhotonRoomParam.iname;
                            GlobalVars.SelectedFriendID = (string)null;
                            GlobalVars.SelectedFriend   = (FriendData)null;
                            GlobalVars.SelectedSupport.Set((SupportData)null);
                            self.Success();
                            DebugUtility.Log("StartMultiPlay: " + myPhotonRoomParam.Serialize());
                            List <MyPhoton.MyPlayer>        roomPlayerList        = instance.GetRoomPlayerList();
                            List <JSON_MyPhotonPlayerParam> photonPlayerParamList = new List <JSON_MyPhotonPlayerParam>();
                            for (int index = 0; index < roomPlayerList.Count; ++index)
                            {
                                JSON_MyPhotonPlayerParam photonPlayerParam2 = JSON_MyPhotonPlayerParam.Parse(roomPlayerList[index].json);
                                photonPlayerParam2.playerID = roomPlayerList[index].playerID;
                                photonPlayerParamList.Add(photonPlayerParam2);
                            }
                            photonPlayerParamList.Sort((Comparison <JSON_MyPhotonPlayerParam>)((a, b) => a.playerIndex - b.playerIndex));
                            List <JSON_MyPhotonPlayerParam> myPlayersStarted = instance.GetMyPlayersStarted();
                            myPlayersStarted.Clear();
                            string roomParam = instance.GetRoomParam("started");
                            if (roomParam != null)
                            {
                                foreach (JSON_MyPhotonPlayerParam player in JSONParser.parseJSONObject <FlowNode_StartMultiPlay.PlayerList>(roomParam).players)
                                {
                                    player.SetupUnits();
                                    myPlayersStarted.Add(player);
                                }
                            }
                            else
                            {
                                using (List <JSON_MyPhotonPlayerParam> .Enumerator enumerator = photonPlayerParamList.GetEnumerator())
                                {
                                    while (enumerator.MoveNext())
                                    {
                                        JSON_MyPhotonPlayerParam current = enumerator.Current;
                                        current.SetupUnits();
                                        myPlayersStarted.Add(current);
                                    }
                                }
                            }
                            photonPlayerParam1.state = 3;
                            instance.SetMyPlayerParam(photonPlayerParam1.Serialize());
                            instance.SetResumeMyPlayer(GlobalVars.ResumeMultiplayPlayerID);
                            instance.MyPlayerIndex = GlobalVars.ResumeMultiplaySeatID;
                        }
                    }
                }
            }
            public override void Update(FlowNode_StartMultiPlay self)
            {
                DebugUtility.Log("StartMultiPlay State_Start Update");
                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 if (this.mPlayerNum != currentRoom.playerCount)
                    {
                        self.FailureStartMulti();
                    }
                    else if (!instance.IsOldestPlayer() && !currentRoom.start)
                    {
                        self.Failure();
                    }
                    else
                    {
                        bool flag = true;
                        using (List <MyPhoton.MyPlayer> .Enumerator enumerator = instance.GetRoomPlayerList().GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(enumerator.Current.json);
                                if (photonPlayerParam.state != 2)
                                {
                                    flag = false;
                                    if (instance.IsOldestPlayer())
                                    {
                                        if (!instance.IsOldestPlayer(photonPlayerParam.playerID))
                                        {
                                            if (photonPlayerParam.state != 1)
                                            {
                                                self.FailureStartMulti();
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            continue;
                                        }
                                    }
                                    DebugUtility.Log("StartMultiPlay State_Start Update allStart is false");
                                    break;
                                }
                            }
                        }
                        if (flag)
                        {
                            DebugUtility.Log("StartMultiPlay State_Start Update change state to game start");
                            self.GotoState <FlowNode_StartMultiPlay.State_GameStart>();
                        }
                        else if (currentRoom.start)
                        {
                            DebugUtility.Log("StartMultiPlay State_Start Update room is closed");
                            JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(instance.GetMyPlayer().json);
                            if (photonPlayerParam.state == 2)
                            {
                                return;
                            }
                            photonPlayerParam.state = 2;
                            instance.SetMyPlayerParam(photonPlayerParam.Serialize());
                            DebugUtility.Log("StartMultiPlay State_Start Update update my state");
                        }
                        else
                        {
                            if (!instance.IsOldestPlayer())
                            {
                                return;
                            }
                            DebugUtility.Log("StartMultiPlay State_Start Update close room");
                            instance.CloseRoom();
                        }
                    }
                }
            }
Beispiel #8
0
        private void RefreshItems()
        {
            Transform transform = ((Component)this).get_transform();

            if (UnityEngine.Object.op_Equality((UnityEngine.Object) this.ItemTemplate, (UnityEngine.Object)null))
            {
                return;
            }
            MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance;

            MyPhoton.MyRoom          currentRoom        = instance.GetCurrentRoom();
            JSON_MyPhotonRoomParam   data1              = JSON_MyPhotonRoomParam.Parse(currentRoom.json);
            JSON_MyPhotonPlayerParam photonPlayerParam1 = data1 != null?data1.GetOwner() : (JSON_MyPhotonPlayerParam)null;

            int num1 = photonPlayerParam1 != null ? photonPlayerParam1.playerIndex : 0;
            List <MyPhoton.MyPlayer> roomPlayerList1 = instance.GetRoomPlayerList();

            for (int count = this.UIItemList.Count; count < currentRoom.maxPlayers; ++count)
            {
                this.UIItemList.Add((GameObject)UnityEngine.Object.Instantiate <GameObject>((M0)this.ItemTemplate));
                if (GlobalVars.SelectedMultiPlayRoomType == JSON_MyPhotonRoomParam.EType.TOWER)
                {
                    this.PlayerInfo.SetActive(false);
                    this.PlayerInfoList.Add((GameObject)UnityEngine.Object.Instantiate <GameObject>((M0)this.PlayerInfo));
                }
            }
            int maxPlayers = currentRoom.maxPlayers;

            if (GlobalVars.SelectedMultiPlayRoomType == JSON_MyPhotonRoomParam.EType.VERSUS)
            {
                --maxPlayers;
            }
            for (int index1 = 0; index1 < maxPlayers; ++index1)
            {
                JSON_MyPhotonPlayerParam data2 = (JSON_MyPhotonPlayerParam)null;
                int num2 = index1 + 1;
                if (num1 > 0)
                {
                    if (index1 == 0)
                    {
                        num2 = num1;
                    }
                    else if (index1 < num1)
                    {
                        num2 = index1;
                    }
                }
                using (List <MyPhoton.MyPlayer> .Enumerator enumerator = roomPlayerList1.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        MyPhoton.MyPlayer current = enumerator.Current;
                        if (current.json != null)
                        {
                            JSON_MyPhotonPlayerParam photonPlayerParam2 = JSON_MyPhotonPlayerParam.Parse(current.json);
                            if (photonPlayerParam2 != null && photonPlayerParam2.playerIndex == num2)
                            {
                                data2 = photonPlayerParam2;
                                break;
                            }
                        }
                    }
                }
                if (data2 == null)
                {
                    data2             = new JSON_MyPhotonPlayerParam();
                    data2.playerIndex = num2;
                }
                GameObject uiItem = this.UIItemList[index1];
                ((UnityEngine.Object)uiItem).set_hideFlags((HideFlags)52);
                DataSource.Bind <JSON_MyPhotonPlayerParam>(uiItem, data2);
                DataSource.Bind <JSON_MyPhotonRoomParam>(uiItem, data1);
                if (GlobalVars.SelectedMultiPlayRoomType == JSON_MyPhotonRoomParam.EType.TOWER)
                {
                    DataSource.Bind <JSON_MyPhotonPlayerParam>(this.PlayerInfoList[index1], data2);
                    DataSource.Bind <JSON_MyPhotonRoomParam>(this.PlayerInfoList[index1], data1);
                    this.PlayerInfoList[index1].get_transform().SetParent(this.PlayerInfo.get_transform().get_parent(), false);
                    this.PlayerInfoList[index1].get_gameObject().SetActive(true);
                }
                GameObjectID[] componentsInChildren = (GameObjectID[])uiItem.GetComponentsInChildren <GameObjectID>(true);
                if (data2 != null && data2.units != null && componentsInChildren != null)
                {
                    for (int index2 = 0; index2 < componentsInChildren.Length; ++index2)
                    {
                        GameObjectID gameObjectId = componentsInChildren[index2];
                        if (gameObjectId.ID != null)
                        {
                            DataSource.Bind <UnitData>(((Component)gameObjectId).get_gameObject(), (UnitData)null);
                        }
                    }
                    for (int index2 = 0; index2 < data2.units.Length; ++index2)
                    {
                        int      slotId = data2.units[index2].slotID;
                        bool     flag1  = data2.units[index2].sub == 1;
                        UnitData data3  = data2.units[index2].unit;
                        if (data3 != null)
                        {
                            if (GlobalVars.SelectedMultiPlayRoomType == JSON_MyPhotonRoomParam.EType.TOWER)
                            {
                                for (int index3 = 0; index3 < componentsInChildren.Length; ++index3)
                                {
                                    GameObjectID gameObjectId = componentsInChildren[index3];
                                    if (gameObjectId.ID != null && (gameObjectId.ID.Equals("unit" + (object)slotId) || flag1) && (!flag1 || index3 == componentsInChildren.Length - 1))
                                    {
                                        data3.TempFlags |= UnitData.TemporaryFlags.AllowJobChange;
                                        DataSource.Bind <UnitData>(((Component)gameObjectId).get_gameObject(), data3);
                                        UnitIcon component = (UnitIcon)((Component)gameObjectId).get_gameObject().GetComponent <UnitIcon>();
                                        if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component, (UnityEngine.Object)null) && data2.playerIndex > 0)
                                        {
                                            DataSource.Bind <PlayerPartyTypes>(((Component)gameObjectId).get_gameObject(), PlayerPartyTypes.MultiTower);
                                            bool flag2 = data2.playerIndex == PunMonoSingleton <MyPhoton> .Instance.MyPlayerIndex;
                                            component.AllowJobChange = flag2;
                                            if (flag2)
                                            {
                                                UnitData unitDataByUnitId = MonoSingleton <GameManager> .Instance.Player.FindUnitDataByUnitID(data3.UnitParam.iname);

                                                if (unitDataByUnitId != null)
                                                {
                                                    unitDataByUnitId.TempFlags |= UnitData.TemporaryFlags.AllowJobChange;
                                                    DataSource.Bind <UnitData>(((Component)gameObjectId).get_gameObject(), unitDataByUnitId);
                                                    data3 = unitDataByUnitId;
                                                }
                                            }
                                        }
                                        if (index3 == 0 && this.PlayerInfoList.Count > index1)
                                        {
                                            DataSource.Bind <UnitData>(this.PlayerInfoList[index1], data3);
                                            break;
                                        }
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                for (int index3 = 0; index3 < componentsInChildren.Length; ++index3)
                                {
                                    GameObjectID gameObjectId = componentsInChildren[index3];
                                    if (gameObjectId.ID != null && gameObjectId.ID.Equals("unit" + (object)slotId))
                                    {
                                        DataSource.Bind <UnitData>(((Component)gameObjectId).get_gameObject(), data3);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                ListItemEvents component1 = (ListItemEvents)uiItem.GetComponent <ListItemEvents>();
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component1, (UnityEngine.Object)null))
                {
                    component1.OnSelect      = new ListItemEvents.ListItemEvent(this.OnSelectItem);
                    component1.OnOpenDetail  = new ListItemEvents.ListItemEvent(this.OnOpenItemDetail);
                    component1.OnCloseDetail = new ListItemEvents.ListItemEvent(this.OnCloseItemDetail);
                }
                uiItem.get_transform().SetParent(transform, false);
                uiItem.get_gameObject().SetActive(true);
            }
            QuestParam quest = MonoSingleton <GameManager> .Instance.FindQuest(data1.iname);

            DataSource.Bind <QuestParam>(this.Root, quest);
            bool flag = false;

            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.SkillObj, (UnityEngine.Object)null) && quest != null)
            {
                if (quest.IsMultiLeaderSkill)
                {
                    List <MyPhoton.MyPlayer> roomPlayerList2 = instance.GetRoomPlayerList();
                    if (roomPlayerList2 != null)
                    {
                        MyPhoton.MyPlayer myPlayer = roomPlayerList2.Find((Predicate <MyPhoton.MyPlayer>)(member => member.playerID == 1));
                        if (myPlayer != null)
                        {
                            JSON_MyPhotonPlayerParam photonPlayerParam2 = JSON_MyPhotonPlayerParam.Parse(myPlayer.json);
                            if (photonPlayerParam2 != null && photonPlayerParam2.units != null && photonPlayerParam2.units.Length > 0)
                            {
                                UnitData data2 = new UnitData();
                                if (data2 != null)
                                {
                                    data2.Deserialize(photonPlayerParam2.units[0].unitJson);
                                    DataSource.Bind <UnitData>(this.SkillObj, data2);
                                    flag = data2.LeaderSkill != null;
                                }
                            }
                        }
                    }
                }
                SRPG_Button component = (SRPG_Button)this.SkillObj.GetComponent <SRPG_Button>();
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component, (UnityEngine.Object)null))
                {
                    ((Selectable)component).set_interactable(quest.IsMultiLeaderSkill && flag);
                }
            }
            GameParameter.UpdateAll(this.Root);
            FlowNode_GameObject.ActivateOutputLinks((Component)this, 1);
        }
            public override void Update(FlowNode_MultiPlayJoinRoom self)
            {
                MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance;

                if (instance.CurrentState != MyPhoton.MyState.ROOM)
                {
                    self.Failure();
                }
                else
                {
                    MyPhoton.MyPlayer        myPlayer       = instance.GetMyPlayer();
                    List <MyPhoton.MyPlayer> roomPlayerList = instance.GetRoomPlayerList();
                    using (List <MyPhoton.MyPlayer> .Enumerator enumerator = roomPlayerList.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            MyPhoton.MyPlayer        current           = enumerator.Current;
                            JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(current.json);
                            if (current.playerID < myPlayer.playerID && photonPlayerParam.playerIndex <= 0)
                            {
                                DebugUtility.Log("[PUN]waiting for player index turn..." + (object)current.playerID + " me:" + (object)myPlayer.playerID);
                                return;
                            }
                        }
                    }
                    MyPhoton.MyRoom currentRoom = instance.GetCurrentRoom();
                    if (currentRoom.maxPlayers == 0)
                    {
                        self.Failure();
                    }
                    else
                    {
                        bool[] flagArray = new bool[currentRoom.maxPlayers];
                        for (int index = 0; index < flagArray.Length; ++index)
                        {
                            flagArray[index] = false;
                        }
                        using (List <MyPhoton.MyPlayer> .Enumerator enumerator = roomPlayerList.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                MyPhoton.MyPlayer        current           = enumerator.Current;
                                JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(current.json);
                                if (current.playerID < myPlayer.playerID && photonPlayerParam.playerIndex > 0)
                                {
                                    flagArray[photonPlayerParam.playerIndex - 1] = true;
                                    DebugUtility.Log("[PUN]player index " + (object)photonPlayerParam.playerIndex + " is used. (room:" + (object)currentRoom.maxPlayers + ")");
                                }
                            }
                        }
                        for (int index = 0; index < currentRoom.maxPlayers; ++index)
                        {
                            if (!flagArray[index])
                            {
                                int num = index + 1;
                                DebugUtility.Log("[PUN]empty player index found: " + (object)num);
                                self.mJoinPlayerParam.playerID    = myPlayer.playerID;
                                self.mJoinPlayerParam.playerIndex = num;
                                instance.SetMyPlayerParam(self.mJoinPlayerParam.Serialize());
                                instance.MyPlayerIndex = num;
                                self.Success();
                                break;
                            }
                        }
                    }
                }
            }
Beispiel #10
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);
                    }
                }
            }
        }
        private void SyncRoomPlayer()
        {
            bool     flag1    = false;
            bool     flag2    = false;
            MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance;
            List <MyPhoton.MyPlayer> roomPlayerList = instance.GetRoomPlayerList();

            if (this.m_Players == null)
            {
                flag2 = true;
            }
            else if (roomPlayerList.Count != this.m_Players.Count)
            {
                flag2 = true;
            }
            else
            {
                for (int index1 = 0; index1 < roomPlayerList.Count; ++index1)
                {
                    if (!roomPlayerList[index1].json.Equals(this.m_Players[index1].json))
                    {
                        JSON_MyPhotonPlayerParam photonPlayerParam1 = JSON_MyPhotonPlayerParam.Parse(this.m_Players[index1].json);
                        JSON_MyPhotonPlayerParam photonPlayerParam2 = JSON_MyPhotonPlayerParam.Parse(roomPlayerList[index1].json);
                        if (photonPlayerParam2 != null && photonPlayerParam1 != null && photonPlayerParam2.playerIndex != instance.MyPlayerIndex)
                        {
                            if (photonPlayerParam2.units.Length != photonPlayerParam1.units.Length)
                            {
                                flag2 = true;
                            }
                            else
                            {
                                for (int index2 = 0; index2 < photonPlayerParam2.units.Length; ++index2)
                                {
                                    UnitData unitData1 = new UnitData();
                                    UnitData unitData2 = new UnitData();
                                    unitData1.Deserialize(photonPlayerParam2.units[index2].unitJson);
                                    unitData2.Deserialize(photonPlayerParam1.units[index2].unitJson);
                                    if (unitData1.UnitParam.iname != unitData2.UnitParam.iname)
                                    {
                                        flag2 = true;
                                    }
                                    else if (photonPlayerParam2.units[index2].place != photonPlayerParam1.units[index2].place)
                                    {
                                        flag1 = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            this.m_Players = roomPlayerList;
            if (flag2)
            {
                this.CloseUnitStatus();
                this.m_SyncLoad = true;
                this.StartCoroutine(this.LoadUnit());
            }
            else if (flag1)
            {
                for (int index1 = 0; index1 < roomPlayerList.Count; ++index1)
                {
                    // ISSUE: object of a compiler-generated type is created
                    // ISSUE: variable of a compiler-generated type
                    MultiPlayVersusReady.\u003CSyncRoomPlayer\u003Ec__AnonStorey34E playerCAnonStorey34E = new MultiPlayVersusReady.\u003CSyncRoomPlayer\u003Ec__AnonStorey34E();
                    // ISSUE: reference to a compiler-generated field
                    playerCAnonStorey34E.param = JSON_MyPhotonPlayerParam.Parse(roomPlayerList[index1].json);
                    // ISSUE: reference to a compiler-generated field
                    if (playerCAnonStorey34E.param != null)
                    {
                        // ISSUE: reference to a compiler-generated field
                        for (int index2 = 0; index2 < playerCAnonStorey34E.param.units.Length; ++index2)
                        {
                            // ISSUE: object of a compiler-generated type is created
                            // ISSUE: variable of a compiler-generated type
                            MultiPlayVersusReady.\u003CSyncRoomPlayer\u003Ec__AnonStorey34D playerCAnonStorey34D = new MultiPlayVersusReady.\u003CSyncRoomPlayer\u003Ec__AnonStorey34D();
                            // ISSUE: reference to a compiler-generated field
                            playerCAnonStorey34D.\u003C\u003Ef__ref\u0024846 = playerCAnonStorey34E;
                            // ISSUE: reference to a compiler-generated field
                            playerCAnonStorey34D.unitData = new UnitData();
                            // ISSUE: reference to a compiler-generated field
                            if (playerCAnonStorey34D.unitData != null)
                            {
                                // ISSUE: reference to a compiler-generated field
                                // ISSUE: reference to a compiler-generated field
                                playerCAnonStorey34D.unitData.Deserialize(playerCAnonStorey34E.param.units[index2].unitJson);
                                // ISSUE: reference to a compiler-generated method
                                TacticsUnitController controller = this.m_Units.Find(new Predicate <TacticsUnitController>(playerCAnonStorey34D.\u003C\u003Em__3AF));
                                if (UnityEngine.Object.op_Inequality((UnityEngine.Object)controller, (UnityEngine.Object)null))
                                {
                                    // ISSUE: reference to a compiler-generated field
                                    OIntVector2 pos = this.CurrentMap.PartyUnitSettings[playerCAnonStorey34E.param.units[index2].place].pos;
                                    controller.Unit.x = (int)pos.x;
                                    controller.Unit.y = (int)pos.y;
                                    this.CalcPosition(controller);
                                }
                            }
                        }
                    }
                }
            }
            this.UpdateGridColor();
        }
        public void InitializeContentList()
        {
            this.ReleaseContentList();
            if (!UnityEngine.Object.op_Inequality((UnityEngine.Object) this.m_ContentController, (UnityEngine.Object)null))
            {
                return;
            }
            this.m_ContentSource = new MultiInvitationSendWindow.Content.ItemSource();
            List <FriendData> list     = new List <FriendData>((IEnumerable <FriendData>)MonoSingleton <GameManager> .Instance.Player.Friends);
            MyPhoton          instance = PunMonoSingleton <MyPhoton> .Instance;

            if (UnityEngine.Object.op_Inequality((UnityEngine.Object)instance, (UnityEngine.Object)null))
            {
                List <MyPhoton.MyPlayer> roomPlayerList = instance.GetRoomPlayerList();
                for (int index1 = 0; index1 < roomPlayerList.Count; ++index1)
                {
                    if (roomPlayerList[index1] != null && !string.IsNullOrEmpty(roomPlayerList[index1].json))
                    {
                        // ISSUE: object of a compiler-generated type is created
                        // ISSUE: variable of a compiler-generated type
                        MultiInvitationSendWindow.\u003CInitializeContentList\u003Ec__AnonStorey34A listCAnonStorey34A = new MultiInvitationSendWindow.\u003CInitializeContentList\u003Ec__AnonStorey34A();
                        // ISSUE: reference to a compiler-generated field
                        listCAnonStorey34A.param = JSON_MyPhotonPlayerParam.Parse(roomPlayerList[index1].json);
                        // ISSUE: reference to a compiler-generated field
                        if (listCAnonStorey34A.param != null)
                        {
                            // ISSUE: reference to a compiler-generated method
                            int index2 = list.FindIndex(new Predicate <FriendData>(listCAnonStorey34A.\u003C\u003Em__3AA));
                            if (index2 != -1)
                            {
                                list.RemoveAt(index2);
                            }
                        }
                    }
                }
            }
            for (int index = 0; index < list.Count; ++index)
            {
                // ISSUE: object of a compiler-generated type is created
                // ISSUE: variable of a compiler-generated type
                MultiInvitationSendWindow.\u003CInitializeContentList\u003Ec__AnonStorey34B listCAnonStorey34B = new MultiInvitationSendWindow.\u003CInitializeContentList\u003Ec__AnonStorey34B();
                // ISSUE: reference to a compiler-generated field
                listCAnonStorey34B.data = list[index];
                bool flag = false;
                // ISSUE: reference to a compiler-generated field
                if (listCAnonStorey34B.data != null)
                {
                    // ISSUE: reference to a compiler-generated method
                    if (MultiInvitationSendWindow.m_Invited.FindIndex(new Predicate <string>(listCAnonStorey34B.\u003C\u003Em__3AB)) != -1)
                    {
                        flag = true;
                    }
                    else
                    {
                        // ISSUE: reference to a compiler-generated field
                        if (!listCAnonStorey34B.data.MultiPush)
                        {
                            flag = true;
                        }
                        else
                        {
                            // ISSUE: reference to a compiler-generated field
                            if (TimeManager.GetUnixSec(DateTime.Now) - listCAnonStorey34B.data.LastLogin > 86400L)
                            {
                                flag = true;
                            }
                        }
                    }
                }
                else
                {
                    flag = true;
                }
                if (flag)
                {
                    list.RemoveAt(index);
                    --index;
                }
            }
            SortUtility.StableSort <FriendData>(list, (Comparison <FriendData>)((p1, p2) => (!p1.IsFavorite ? p1.LastLogin : long.MaxValue).CompareTo(!p2.IsFavorite ? p2.LastLogin : long.MaxValue)));
            list.Reverse();
            for (int index = 0; index < list.Count; ++index)
            {
                FriendData friend = list[index];
                if (friend != null)
                {
                    MultiInvitationSendWindow.Content.ItemSource.ItemParam itemParam = new MultiInvitationSendWindow.Content.ItemSource.ItemParam(friend);
                    if (itemParam.IsValid())
                    {
                        this.m_ContentSource.Add(itemParam);
                    }
                }
            }
            this.m_ContentController.Initialize((ContentSource)this.m_ContentSource, Vector2.get_zero());
        }
        public void InitializeContentList()
        {
            this.ReleaseContentList();
            if (!UnityEngine.Object.op_Inequality((UnityEngine.Object) this.m_ContentController, (UnityEngine.Object)null))
            {
                return;
            }
            this.m_ContentSource = new MultiInvitationSendWindow.Content.ItemSource();
            List <FriendData> list     = new List <FriendData>((IEnumerable <FriendData>)MonoSingleton <GameManager> .Instance.Player.Friends);
            MyPhoton          instance = PunMonoSingleton <MyPhoton> .Instance;

            if (UnityEngine.Object.op_Inequality((UnityEngine.Object)instance, (UnityEngine.Object)null))
            {
                List <MyPhoton.MyPlayer> roomPlayerList = instance.GetRoomPlayerList();
                for (int index1 = 0; index1 < roomPlayerList.Count; ++index1)
                {
                    if (roomPlayerList[index1] != null && !string.IsNullOrEmpty(roomPlayerList[index1].json))
                    {
                        JSON_MyPhotonPlayerParam param = JSON_MyPhotonPlayerParam.Parse(roomPlayerList[index1].json);
                        if (param != null)
                        {
                            int index2 = list.FindIndex((Predicate <FriendData>)(prop => prop.UID == param.UID));
                            if (index2 != -1)
                            {
                                list.RemoveAt(index2);
                            }
                        }
                    }
                }
            }
            for (int index = 0; index < list.Count; ++index)
            {
                FriendData data = list[index];
                bool       flag = false;
                if (data != null)
                {
                    if (MultiInvitationSendWindow.m_Invited.FindIndex((Predicate <string>)(prop => prop == data.UID)) != -1)
                    {
                        flag = true;
                    }
                    else if (!data.MultiPush)
                    {
                        flag = true;
                    }
                    else if (TimeManager.GetUnixSec(DateTime.Now) - data.LastLogin > 86400L)
                    {
                        flag = true;
                    }
                }
                else
                {
                    flag = true;
                }
                if (flag)
                {
                    list.RemoveAt(index);
                    --index;
                }
            }
            SortUtility.StableSort <FriendData>(list, (Comparison <FriendData>)((p1, p2) => (!p1.IsFavorite ? p1.LastLogin : long.MaxValue).CompareTo(!p2.IsFavorite ? p2.LastLogin : long.MaxValue)));
            list.Reverse();
            for (int index = 0; index < list.Count; ++index)
            {
                FriendData friend = list[index];
                if (friend != null)
                {
                    MultiInvitationSendWindow.Content.ItemSource.ItemParam itemParam = new MultiInvitationSendWindow.Content.ItemSource.ItemParam(friend);
                    if (itemParam.IsValid())
                    {
                        this.m_ContentSource.Add(itemParam);
                    }
                }
            }
            this.m_ContentController.Initialize((ContentSource)this.m_ContentSource, Vector2.get_zero());
        }
Beispiel #14
0
        private void RefreshItems()
        {
            Transform transform = ((Component)this).get_transform();

            if (Object.op_Equality((Object)this.ItemTemplate, (Object)null))
            {
                return;
            }
            MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance;

            MyPhoton.MyRoom          currentRoom        = instance.GetCurrentRoom();
            JSON_MyPhotonRoomParam   data1              = JSON_MyPhotonRoomParam.Parse(currentRoom.json);
            JSON_MyPhotonPlayerParam photonPlayerParam1 = data1 != null?data1.GetOwner() : (JSON_MyPhotonPlayerParam)null;

            int num1 = photonPlayerParam1 != null ? photonPlayerParam1.playerIndex : 0;
            List <MyPhoton.MyPlayer> roomPlayerList = instance.GetRoomPlayerList();

            for (int count = this.UIItemList.Count; count < currentRoom.maxPlayers; ++count)
            {
                this.UIItemList.Add((GameObject)Object.Instantiate <GameObject>((M0)this.ItemTemplate));
            }
            for (int index1 = 0; index1 < currentRoom.maxPlayers; ++index1)
            {
                JSON_MyPhotonPlayerParam data2 = (JSON_MyPhotonPlayerParam)null;
                int num2 = index1 + 1;
                if (num1 > 0)
                {
                    if (index1 == 0)
                    {
                        num2 = num1;
                    }
                    else if (index1 < num1)
                    {
                        num2 = index1;
                    }
                }
                using (List <MyPhoton.MyPlayer> .Enumerator enumerator = roomPlayerList.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        MyPhoton.MyPlayer current = enumerator.Current;
                        if (current.json != null)
                        {
                            JSON_MyPhotonPlayerParam photonPlayerParam2 = JSON_MyPhotonPlayerParam.Parse(current.json);
                            if (photonPlayerParam2 != null && photonPlayerParam2.playerIndex == num2)
                            {
                                data2 = photonPlayerParam2;
                                break;
                            }
                        }
                    }
                }
                if (data2 == null)
                {
                    data2             = new JSON_MyPhotonPlayerParam();
                    data2.playerIndex = num2;
                }
                GameObject uiItem = this.UIItemList[index1];
                ((Object)uiItem).set_hideFlags((HideFlags)52);
                DataSource.Bind <JSON_MyPhotonPlayerParam>(uiItem, data2);
                DataSource.Bind <JSON_MyPhotonRoomParam>(uiItem, data1);
                GameObjectID[] componentsInChildren = (GameObjectID[])uiItem.GetComponentsInChildren <GameObjectID>(true);
                if (data2 != null && data2.units != null && componentsInChildren != null)
                {
                    for (int index2 = 0; index2 < componentsInChildren.Length; ++index2)
                    {
                        GameObjectID gameObjectId = componentsInChildren[index2];
                        if (gameObjectId.ID != null)
                        {
                            DataSource.Bind <UnitData>(((Component)gameObjectId).get_gameObject(), (UnitData)null);
                        }
                    }
                    for (int index2 = 0; index2 < data2.units.Length; ++index2)
                    {
                        int      slotId = data2.units[index2].slotID;
                        UnitData unit   = data2.units[index2].unit;
                        if (unit != null)
                        {
                            for (int index3 = 0; index3 < componentsInChildren.Length; ++index3)
                            {
                                GameObjectID gameObjectId = componentsInChildren[index3];
                                if (gameObjectId.ID != null && gameObjectId.ID.Equals("unit" + (object)slotId))
                                {
                                    DataSource.Bind <UnitData>(((Component)gameObjectId).get_gameObject(), unit);
                                    break;
                                }
                            }
                        }
                    }
                }
                ListItemEvents component = (ListItemEvents)uiItem.GetComponent <ListItemEvents>();
                if (Object.op_Inequality((Object)component, (Object)null))
                {
                    component.OnSelect      = new ListItemEvents.ListItemEvent(this.OnSelectItem);
                    component.OnOpenDetail  = new ListItemEvents.ListItemEvent(this.OnOpenItemDetail);
                    component.OnCloseDetail = new ListItemEvents.ListItemEvent(this.OnCloseItemDetail);
                }
                uiItem.get_transform().SetParent(transform, false);
                uiItem.get_gameObject().SetActive(true);
            }
            DataSource.Bind <QuestParam>(this.Root, MonoSingleton <GameManager> .Instance.FindQuest(data1.iname));
            GameParameter.UpdateAll(this.Root);
            FlowNode_GameObject.ActivateOutputLinks((Component)this, 1);
        }
        private void SyncRoomPlayer()
        {
            bool     flag1    = false;
            bool     flag2    = false;
            MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance;
            List <MyPhoton.MyPlayer> roomPlayerList = instance.GetRoomPlayerList();

            if (this.m_Players == null)
            {
                flag2 = true;
            }
            else if (roomPlayerList.Count != this.m_Players.Count)
            {
                flag2 = true;
            }
            else
            {
                for (int index1 = 0; index1 < roomPlayerList.Count; ++index1)
                {
                    if (!roomPlayerList[index1].json.Equals(this.m_Players[index1].json))
                    {
                        JSON_MyPhotonPlayerParam photonPlayerParam1 = JSON_MyPhotonPlayerParam.Parse(this.m_Players[index1].json);
                        JSON_MyPhotonPlayerParam photonPlayerParam2 = JSON_MyPhotonPlayerParam.Parse(roomPlayerList[index1].json);
                        if (photonPlayerParam2 != null && photonPlayerParam1 != null && photonPlayerParam2.playerIndex != instance.MyPlayerIndex)
                        {
                            if (photonPlayerParam1.playerID != photonPlayerParam2.playerID)
                            {
                                flag2 = true;
                                break;
                            }
                            if (photonPlayerParam2.units.Length != photonPlayerParam1.units.Length)
                            {
                                flag2 = true;
                                break;
                            }
                            for (int index2 = 0; index2 < photonPlayerParam2.units.Length; ++index2)
                            {
                                UnitData unitData1 = new UnitData();
                                UnitData unitData2 = new UnitData();
                                unitData1.Deserialize(photonPlayerParam2.units[index2].unitJson);
                                unitData2.Deserialize(photonPlayerParam1.units[index2].unitJson);
                                if (unitData1.UnitParam.iname != unitData2.UnitParam.iname)
                                {
                                    flag2 = true;
                                    break;
                                }
                                if (photonPlayerParam2.units[index2].place != photonPlayerParam1.units[index2].place)
                                {
                                    flag1 = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            this.m_Players = roomPlayerList;
            if (flag2)
            {
                this.CloseUnitStatus();
                this.m_SyncLoad = true;
                this.StartCoroutine(this.LoadUnit());
            }
            else if (flag1)
            {
                for (int index1 = 0; index1 < roomPlayerList.Count; ++index1)
                {
                    JSON_MyPhotonPlayerParam param = JSON_MyPhotonPlayerParam.Parse(roomPlayerList[index1].json);
                    if (param != null)
                    {
                        for (int index2 = 0; index2 < param.units.Length; ++index2)
                        {
                            UnitData unitData = new UnitData();
                            if (unitData != null)
                            {
                                unitData.Deserialize(param.units[index2].unitJson);
                                TacticsUnitController controller = this.m_Units.Find((Predicate <TacticsUnitController>)(data =>
                                {
                                    if (data.Unit.UnitParam.iname == unitData.UnitParam.iname)
                                    {
                                        return(data.Unit.OwnerPlayerIndex == param.playerIndex);
                                    }
                                    return(false);
                                }));
                                if (UnityEngine.Object.op_Inequality((UnityEngine.Object)controller, (UnityEngine.Object)null))
                                {
                                    OIntVector2 pos = this.CurrentMap.PartyUnitSettings[param.units[index2].place].pos;
                                    controller.Unit.x = (int)pos.x;
                                    controller.Unit.y = (int)pos.y;
                                    this.CalcPosition(controller);
                                }
                            }
                        }
                    }
                }
            }
            this.UpdateGridColor();
        }
Beispiel #16
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;
                                    }
                                }
                            }
                        }
                    }
                }
            }
Beispiel #17
0
            public override void Update(FlowNode_MultiPlayJoinRoom self)
            {
                MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance;

                if (instance.CurrentState != MyPhoton.MyState.ROOM)
                {
                    self.Failure();
                }
                else
                {
                    MyPhoton.MyPlayer        myPlayer       = instance.GetMyPlayer();
                    List <MyPhoton.MyPlayer> roomPlayerList = instance.GetRoomPlayerList();
                    using (List <MyPhoton.MyPlayer> .Enumerator enumerator = roomPlayerList.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            MyPhoton.MyPlayer        current           = enumerator.Current;
                            JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(current.json);
                            if (current.playerID < myPlayer.playerID && photonPlayerParam.playerIndex <= 0)
                            {
                                DebugUtility.Log("[PUN]waiting for player index turn..." + (object)current.playerID + " me:" + (object)myPlayer.playerID);
                                return;
                            }
                        }
                    }
                    MyPhoton.MyRoom currentRoom = instance.GetCurrentRoom();
                    if (currentRoom.maxPlayers == 0)
                    {
                        Debug.LogError((object)("Invalid Room:" + currentRoom.name));
                        PhotonNetwork.room.IsOpen = false;
                        self.Failure();
                    }
                    else
                    {
                        bool[] flagArray = new bool[currentRoom.maxPlayers];
                        for (int index = 0; index < flagArray.Length; ++index)
                        {
                            flagArray[index] = false;
                        }
                        using (List <MyPhoton.MyPlayer> .Enumerator enumerator = roomPlayerList.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                MyPhoton.MyPlayer        current           = enumerator.Current;
                                JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(current.json);
                                if (current.playerID < myPlayer.playerID && photonPlayerParam.playerIndex > 0)
                                {
                                    flagArray[photonPlayerParam.playerIndex - 1] = true;
                                    DebugUtility.Log("[PUN]player index " + (object)photonPlayerParam.playerIndex + " is used. (room:" + (object)currentRoom.maxPlayers + ")");
                                }
                            }
                        }
                        for (int index = 0; index < currentRoom.maxPlayers; ++index)
                        {
                            if (!flagArray[index])
                            {
                                int num = index + 1;
                                DebugUtility.Log("[PUN]empty player index found: " + (object)num);
                                if (instance.IsMultiVersus && num >= 3)
                                {
                                    foreach (PhotonPlayer player in PhotonNetwork.playerList)
                                    {
                                        new MyPhoton.MyPlayer().playerID = player.ID;
                                        Hashtable customProperties = player.CustomProperties;
                                        if (customProperties != null && ((Dictionary <object, object>)customProperties).Count > 0 && ((Dictionary <object, object>)customProperties).ContainsKey((object)"json"))
                                        {
                                            string buffer;
                                            GameUtility.Binary2Object <string>(out buffer, (byte[])customProperties.get_Item((object)"json"));
                                            Debug.Log((object)("player json : " + buffer));
                                        }
                                    }
                                    Debug.LogError((object)"MultiVersus is playerindex over : 3");
                                }
                                self.mJoinPlayerParam.playerID    = myPlayer.playerID;
                                self.mJoinPlayerParam.playerIndex = num;
                                self.mJoinPlayerParam.UpdateMultiTowerPlacement(true);
                                instance.SetMyPlayerParam(self.mJoinPlayerParam.Serialize());
                                instance.MyPlayerIndex = num;
                                self.Success();
                                break;
                            }
                        }
                    }
                }
            }