Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }