public bool CheckExchange()
        {
            ExchangeActivity exchangeActivity = base.Owner as ExchangeActivity;
            uint             num  = 0u;
            uint             num2 = 0u;

            if (exchangeActivity != null)
            {
                num  = exchangeActivity.GetMaxExchangeCount((int)this.Config.bIdx);
                num2 = exchangeActivity.GetExchangeCount((int)this.Config.bIdx);
            }
            return(num2 < num);
        }
Exemple #2
0
        public bool CheckExchange()
        {
            ExchangeActivity owner            = base.Owner as ExchangeActivity;
            uint             maxExchangeCount = 0;
            uint             exchangeCount    = 0;

            if (owner != null)
            {
                maxExchangeCount = owner.GetMaxExchangeCount(this.Config.bIdx);
                exchangeCount    = owner.GetExchangeCount(this.Config.bIdx);
            }
            return(exchangeCount < maxExchangeCount);
        }
        public int GetMaxExchangeCount()
        {
            int             num              = 0;
            ResDT_Item_Info resDT_Item_Info  = null;
            ResDT_Item_Info resDT_Item_Info2 = null;

            if (this.Config.bColItemCnt > 0)
            {
                resDT_Item_Info = this.Config.astColItemInfo[0];
            }
            if (this.Config.bColItemCnt > 1)
            {
                resDT_Item_Info2 = this.Config.astColItemInfo[1];
            }
            CUseableContainer useableContainer = Singleton <CRoleInfoManager> .instance.GetMasterRoleInfo().GetUseableContainer(enCONTAINER_TYPE.ITEM);

            if (useableContainer != null)
            {
                if (resDT_Item_Info != null)
                {
                    uint   dwItemID          = resDT_Item_Info.dwItemID;
                    ushort wItemType         = resDT_Item_Info.wItemType;
                    int    useableStackCount = useableContainer.GetUseableStackCount((COM_ITEM_TYPE)wItemType, dwItemID);
                    ushort wItemCnt          = resDT_Item_Info.wItemCnt;
                    int    num2 = useableStackCount / (int)wItemCnt;
                    num = num2;
                }
                if (resDT_Item_Info2 != null)
                {
                    uint   dwItemID2          = resDT_Item_Info2.dwItemID;
                    ushort wItemType2         = resDT_Item_Info2.wItemType;
                    int    useableStackCount2 = useableContainer.GetUseableStackCount((COM_ITEM_TYPE)wItemType2, dwItemID2);
                    ushort wItemCnt2          = resDT_Item_Info2.wItemCnt;
                    int    num3 = useableStackCount2 / (int)wItemCnt2;
                    num = Math.Min(num, num3);
                }
                ExchangeActivity exchangeActivity = base.Owner as ExchangeActivity;
                if (exchangeActivity != null)
                {
                    uint maxExchangeCount = exchangeActivity.GetMaxExchangeCount((int)this.Config.bIdx);
                    uint exchangeCount    = exchangeActivity.GetExchangeCount((int)this.Config.bIdx);
                    if (maxExchangeCount > 0u)
                    {
                        num = Math.Min(num, (int)(maxExchangeCount - exchangeCount));
                    }
                }
            }
            return(num);
        }
Exemple #4
0
            public void Validate()
            {
                if ((this.phase != null) && (this.uiItem != null))
                {
                    this.uiItem.CustomSetActive(true);
                    ResDT_Item_Info info          = null;
                    ResDT_Item_Info info2         = null;
                    ResDT_Item_Info stResItemInfo = null;
                    stResItemInfo = this.phase.Config.stResItemInfo;
                    if (this.phase.Config.bColItemCnt > 0)
                    {
                        info = this.phase.Config.astColItemInfo[0];
                    }
                    if (this.phase.Config.bColItemCnt > 1)
                    {
                        info2 = this.phase.Config.astColItemInfo[1];
                    }
                    CUseableContainer useableContainer = Singleton <CRoleInfoManager> .instance.GetMasterRoleInfo().GetUseableContainer(enCONTAINER_TYPE.ITEM);

                    if (useableContainer != null)
                    {
                        int num  = (info != null) ? useableContainer.GetUseableStackCount((COM_ITEM_TYPE)info.wItemType, info.dwItemID) : 0;
                        int num2 = (info2 != null) ? useableContainer.GetUseableStackCount((COM_ITEM_TYPE)info2.wItemType, info2.dwItemID) : 0;
                        if (stResItemInfo != null)
                        {
                            GameObject gameObject = this.uiItem.transform.FindChild("DuihuanBtn").gameObject;
                            gameObject.GetComponent <CUIEventScript>().m_onClickEventParams.commonUInt32Param1 = (uint)this.index;
                            bool isEnable = this.owner.view.activity.timeState == Activity.TimeState.Going;
                            CUICommonSystem.SetButtonEnable(gameObject.GetComponent <Button>(), isEnable, isEnable, true);
                            if (info != null)
                            {
                                CUseable   useable2 = CUseableManager.CreateUseable((COM_ITEM_TYPE)info.wItemType, info.dwItemID, 1);
                                GameObject obj3     = this.uiItem.transform.FindChild("Panel/ItemCell1").gameObject;
                                CUICommonSystem.SetItemCell(this.owner.view.form.formScript, obj3, useable2, true, false);
                                int    useableStackCount = useableContainer.GetUseableStackCount((COM_ITEM_TYPE)info.wItemType, info.dwItemID);
                                ushort wItemCnt          = info.wItemCnt;
                                Text   component         = this.uiItem.transform.FindChild("Panel/ItemCell1/ItemCount").gameObject.GetComponent <Text>();
                                if (useableStackCount < wItemCnt)
                                {
                                    component.text = string.Format(Singleton <CTextManager> .GetInstance().GetText("Exchange_ItemNotEnoughCount"), useableStackCount, wItemCnt);
                                    CUICommonSystem.SetButtonEnable(gameObject.GetComponent <Button>(), false, false, true);
                                }
                                else
                                {
                                    component.text = string.Format(Singleton <CTextManager> .GetInstance().GetText("Exchange_ItemCount"), useableStackCount, wItemCnt);
                                }
                            }
                            if (info2 != null)
                            {
                                CUseable   useable3 = CUseableManager.CreateUseable((COM_ITEM_TYPE)info2.wItemType, info2.dwItemID, 1);
                                GameObject obj4     = this.uiItem.transform.FindChild("Panel/ItemCell2").gameObject;
                                obj4.CustomSetActive(true);
                                CUICommonSystem.SetItemCell(this.owner.view.form.formScript, obj4, useable3, true, false);
                                int    num5  = useableContainer.GetUseableStackCount((COM_ITEM_TYPE)info2.wItemType, info2.dwItemID);
                                ushort num6  = info2.wItemCnt;
                                Text   text2 = this.uiItem.transform.FindChild("Panel/ItemCell2/ItemCount").gameObject.GetComponent <Text>();
                                if (num5 < num6)
                                {
                                    text2.text = string.Format(Singleton <CTextManager> .GetInstance().GetText("Exchange_ItemNotEnoughCount"), num5, num6);
                                    CUICommonSystem.SetButtonEnable(gameObject.GetComponent <Button>(), false, false, true);
                                }
                                else
                                {
                                    text2.text = string.Format(Singleton <CTextManager> .GetInstance().GetText("Exchange_ItemCount"), num5, num6);
                                }
                            }
                            else
                            {
                                this.uiItem.transform.FindChild("Panel/ItemCell2").gameObject.CustomSetActive(false);
                                this.uiItem.transform.FindChild("Panel/Add").gameObject.CustomSetActive(false);
                            }
                            CUseable   itemUseable = CUseableManager.CreateUseable((COM_ITEM_TYPE)stResItemInfo.wItemType, stResItemInfo.dwItemID, stResItemInfo.wItemCnt);
                            GameObject itemCell    = this.uiItem.transform.FindChild("Panel/GetItemCell").gameObject;
                            CUICommonSystem.SetItemCell(this.owner.view.form.formScript, itemCell, itemUseable, true, false);
                            ExchangeActivity activity = this.owner.view.activity as ExchangeActivity;
                            if (activity != null)
                            {
                                GameObject obj8             = this.uiItem.transform.FindChild("ExchangeCount").gameObject;
                                uint       maxExchangeCount = activity.GetMaxExchangeCount(this.phase.Config.bIdx);
                                uint       exchangeCount    = activity.GetExchangeCount(this.phase.Config.bIdx);
                                if (maxExchangeCount > 0)
                                {
                                    obj8.CustomSetActive(true);
                                    obj8.GetComponent <Text>().text = string.Format(Singleton <CTextManager> .GetInstance().GetText("Exchange_TimeLimit"), exchangeCount, maxExchangeCount);
                                    if (exchangeCount >= maxExchangeCount)
                                    {
                                        CUICommonSystem.SetButtonEnable(gameObject.GetComponent <Button>(), false, false, true);
                                    }
                                }
                                else
                                {
                                    obj8.CustomSetActive(false);
                                }
                            }
                        }
                    }
                }
            }
Exemple #5
0
        private void UpdateOneElement(int index)
        {
            ListView <ActivityPhase> phaseList = base.view.activity.PhaseList;

            if ((index < phaseList.Count) && (this._elementsGo != null))
            {
                ExchangePhase phase = phaseList[index] as ExchangePhase;
                GameObject    obj2  = null;
                bool          flag  = this._elementsGo.TryGetValue(index, out obj2);
                if ((phase != null) && (obj2 != null))
                {
                    obj2.CustomSetActive(true);
                    ResDT_Item_Info info          = null;
                    ResDT_Item_Info info2         = null;
                    ResDT_Item_Info stResItemInfo = null;
                    stResItemInfo = phase.Config.stResItemInfo;
                    if (phase.Config.bColItemCnt > 0)
                    {
                        info = phase.Config.astColItemInfo[0];
                    }
                    if (phase.Config.bColItemCnt > 1)
                    {
                        info2 = phase.Config.astColItemInfo[1];
                    }
                    CUseableContainer useableContainer = Singleton <CRoleInfoManager> .instance.GetMasterRoleInfo().GetUseableContainer(enCONTAINER_TYPE.ITEM);

                    if (useableContainer != null)
                    {
                        int num  = (info != null) ? useableContainer.GetUseableStackCount((COM_ITEM_TYPE)info.wItemType, info.dwItemID) : 0;
                        int num2 = (info2 != null) ? useableContainer.GetUseableStackCount((COM_ITEM_TYPE)info2.wItemType, info2.dwItemID) : 0;
                        if (stResItemInfo != null)
                        {
                            GameObject gameObject = obj2.transform.FindChild("DuihuanBtn").gameObject;
                            gameObject.GetComponent <CUIEventScript>().m_onClickEventParams.commonUInt64Param1 = phase.Config.bIdx;
                            if (base.view.activity.timeState == Activity.TimeState.Close)
                            {
                                CUICommonSystem.SetButtonEnable(gameObject.GetComponent <Button>(), false, false, true);
                            }
                            if (info != null)
                            {
                                CUseable   useable2 = CUseableManager.CreateUseable((COM_ITEM_TYPE)info.wItemType, info.dwItemID, 1);
                                GameObject obj4     = obj2.transform.FindChild("Panel/ItemCell1").gameObject;
                                CUICommonSystem.SetItemCell(base.view.form.formScript, obj4, useable2, true, false);
                                int    useableStackCount = useableContainer.GetUseableStackCount((COM_ITEM_TYPE)info.wItemType, info.dwItemID);
                                ushort wItemCnt          = info.wItemCnt;
                                Text   component         = obj2.transform.FindChild("Panel/ItemCell1/ItemCount").gameObject.GetComponent <Text>();
                                if (useableStackCount < wItemCnt)
                                {
                                    component.text = string.Format(Singleton <CTextManager> .GetInstance().GetText("Exchange_ItemNotEnoughCount"), useableStackCount, wItemCnt);
                                    CUICommonSystem.SetButtonEnable(gameObject.GetComponent <Button>(), false, false, true);
                                }
                                else
                                {
                                    component.text = string.Format(Singleton <CTextManager> .GetInstance().GetText("Exchange_ItemCount"), useableStackCount, wItemCnt);
                                }
                            }
                            if (info2 != null)
                            {
                                CUseable   useable3 = CUseableManager.CreateUseable((COM_ITEM_TYPE)info2.wItemType, info2.dwItemID, 1);
                                GameObject obj5     = obj2.transform.FindChild("Panel/ItemCell2").gameObject;
                                obj5.CustomSetActive(true);
                                CUICommonSystem.SetItemCell(base.view.form.formScript, obj5, useable3, true, false);
                                int    num5  = useableContainer.GetUseableStackCount((COM_ITEM_TYPE)info2.wItemType, info2.dwItemID);
                                ushort num6  = info2.wItemCnt;
                                Text   text2 = obj2.transform.FindChild("Panel/ItemCell2/ItemCount").gameObject.GetComponent <Text>();
                                if (num5 < num6)
                                {
                                    text2.text = string.Format(Singleton <CTextManager> .GetInstance().GetText("Exchange_ItemNotEnoughCount"), num5, num6);
                                    CUICommonSystem.SetButtonEnable(gameObject.GetComponent <Button>(), false, false, true);
                                }
                                else
                                {
                                    text2.text = string.Format(Singleton <CTextManager> .GetInstance().GetText("Exchange_ItemCount"), num5, num6);
                                }
                            }
                            else
                            {
                                obj2.transform.FindChild("Panel/ItemCell2").gameObject.CustomSetActive(false);
                                obj2.transform.FindChild("Panel/Add").gameObject.CustomSetActive(false);
                            }
                            CUseable   itemUseable = CUseableManager.CreateUseable((COM_ITEM_TYPE)stResItemInfo.wItemType, stResItemInfo.dwItemID, 1);
                            GameObject itemCell    = obj2.transform.FindChild("Panel/GetItemCell").gameObject;
                            CUICommonSystem.SetItemCell(base.view.form.formScript, itemCell, itemUseable, true, false);
                            ExchangeActivity activity = base.view.activity as ExchangeActivity;
                            if (activity != null)
                            {
                                GameObject obj9             = obj2.transform.FindChild("ExchangeCount").gameObject;
                                uint       maxExchangeCount = activity.GetMaxExchangeCount(phase.Config.bIdx);
                                uint       exchangeCount    = activity.GetExchangeCount(phase.Config.bIdx);
                                if (maxExchangeCount > 0)
                                {
                                    obj9.CustomSetActive(true);
                                    obj9.GetComponent <Text>().text = string.Format(Singleton <CTextManager> .GetInstance().GetText("Exchange_TimeLimit"), exchangeCount, maxExchangeCount);
                                    if (exchangeCount >= maxExchangeCount)
                                    {
                                        CUICommonSystem.SetButtonEnable(gameObject.GetComponent <Button>(), false, false, true);
                                    }
                                }
                                else
                                {
                                    obj9.CustomSetActive(false);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #6
0
            public void Validate()
            {
                if (this.phase == null || this.uiItem == null)
                {
                    return;
                }
                this.uiItem.CustomSetActive(true);
                ResDT_Item_Info resDT_Item_Info  = null;
                ResDT_Item_Info resDT_Item_Info2 = null;
                ResDT_Item_Info stResItemInfo    = this.phase.Config.stResItemInfo;

                if (this.phase.Config.bColItemCnt > 0)
                {
                    resDT_Item_Info = this.phase.Config.astColItemInfo[0];
                }
                if (this.phase.Config.bColItemCnt > 1)
                {
                    resDT_Item_Info2 = this.phase.Config.astColItemInfo[1];
                }
                CRoleInfo masterRoleInfo = Singleton <CRoleInfoManager> .instance.GetMasterRoleInfo();

                CUseableContainer useableContainer = masterRoleInfo.GetUseableContainer(enCONTAINER_TYPE.ITEM);

                if (useableContainer == null)
                {
                    return;
                }
                int arg_CB_0 = (resDT_Item_Info == null) ? 0 : useableContainer.GetUseableStackCount((COM_ITEM_TYPE)resDT_Item_Info.wItemType, resDT_Item_Info.dwItemID);
                int arg_EC_0 = (resDT_Item_Info2 == null) ? 0 : useableContainer.GetUseableStackCount((COM_ITEM_TYPE)resDT_Item_Info2.wItemType, resDT_Item_Info2.dwItemID);

                if (stResItemInfo != null)
                {
                    GameObject gameObject = this.uiItem.transform.FindChild("DuihuanBtn").gameObject;
                    gameObject.GetComponent <CUIEventScript>().m_onClickEventParams.commonUInt32Param1 = (uint)this.index;
                    bool isEnable = this.owner.view.activity.timeState == Activity.TimeState.Going;
                    CUICommonSystem.SetButtonEnableWithShader(gameObject.GetComponent <Button>(), isEnable, true);
                    if (resDT_Item_Info != null)
                    {
                        CUseable   itemUseable = CUseableManager.CreateUseable((COM_ITEM_TYPE)resDT_Item_Info.wItemType, resDT_Item_Info.dwItemID, 1);
                        GameObject gameObject2 = this.uiItem.transform.FindChild("Panel/ItemCell1").gameObject;
                        CUICommonSystem.SetItemCell(this.owner.view.form.formScript, gameObject2, itemUseable, true, false, false, false);
                        int    useableStackCount = useableContainer.GetUseableStackCount((COM_ITEM_TYPE)resDT_Item_Info.wItemType, resDT_Item_Info.dwItemID);
                        ushort wItemCnt          = resDT_Item_Info.wItemCnt;
                        Text   component         = this.uiItem.transform.FindChild("Panel/ItemCell1/ItemCount").gameObject.GetComponent <Text>();
                        if (useableStackCount < (int)wItemCnt)
                        {
                            component.set_text(string.Format(Singleton <CTextManager> .GetInstance().GetText("Exchange_ItemNotEnoughCount"), useableStackCount, wItemCnt));
                            CUICommonSystem.SetButtonEnableWithShader(gameObject.GetComponent <Button>(), false, true);
                        }
                        else
                        {
                            component.set_text(string.Format(Singleton <CTextManager> .GetInstance().GetText("Exchange_ItemCount"), useableStackCount, wItemCnt));
                        }
                    }
                    if (resDT_Item_Info2 != null)
                    {
                        CUseable   itemUseable2 = CUseableManager.CreateUseable((COM_ITEM_TYPE)resDT_Item_Info2.wItemType, resDT_Item_Info2.dwItemID, 1);
                        GameObject gameObject3  = this.uiItem.transform.FindChild("Panel/ItemCell2").gameObject;
                        gameObject3.CustomSetActive(true);
                        CUICommonSystem.SetItemCell(this.owner.view.form.formScript, gameObject3, itemUseable2, true, false, false, false);
                        int    useableStackCount2 = useableContainer.GetUseableStackCount((COM_ITEM_TYPE)resDT_Item_Info2.wItemType, resDT_Item_Info2.dwItemID);
                        ushort wItemCnt2          = resDT_Item_Info2.wItemCnt;
                        Text   component2         = this.uiItem.transform.FindChild("Panel/ItemCell2/ItemCount").gameObject.GetComponent <Text>();
                        if (useableStackCount2 < (int)wItemCnt2)
                        {
                            component2.set_text(string.Format(Singleton <CTextManager> .GetInstance().GetText("Exchange_ItemNotEnoughCount"), useableStackCount2, wItemCnt2));
                            CUICommonSystem.SetButtonEnableWithShader(gameObject.GetComponent <Button>(), false, true);
                        }
                        else
                        {
                            component2.set_text(string.Format(Singleton <CTextManager> .GetInstance().GetText("Exchange_ItemCount"), useableStackCount2, wItemCnt2));
                        }
                    }
                    else
                    {
                        GameObject gameObject4 = this.uiItem.transform.FindChild("Panel/ItemCell2").gameObject;
                        gameObject4.CustomSetActive(false);
                        GameObject gameObject5 = this.uiItem.transform.FindChild("Panel/Add").gameObject;
                        gameObject5.CustomSetActive(false);
                    }
                    CUseable   cUseable    = CUseableManager.CreateUseable((COM_ITEM_TYPE)stResItemInfo.wItemType, stResItemInfo.dwItemID, (int)stResItemInfo.wItemCnt);
                    GameObject gameObject6 = this.uiItem.transform.FindChild("Panel/GetItemCell").gameObject;
                    bool       bActive     = false;
                    if (cUseable.m_type == COM_ITEM_TYPE.COM_OBJTYPE_HERO)
                    {
                        CHeroItem cHeroItem = (CHeroItem)cUseable;
                        if (cHeroItem != null)
                        {
                            CRoleInfo masterRoleInfo2 = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo();

                            if (masterRoleInfo2 != null)
                            {
                                bActive = masterRoleInfo2.IsHaveHero(cHeroItem.m_baseID, true);
                            }
                        }
                    }
                    else if (cUseable.m_type == COM_ITEM_TYPE.COM_OBJTYPE_HEROSKIN)
                    {
                        CHeroSkin cHeroSkin = (CHeroSkin)cUseable;
                        if (cHeroSkin != null)
                        {
                            CRoleInfo masterRoleInfo3 = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo();

                            if (masterRoleInfo3 != null)
                            {
                                bActive = masterRoleInfo3.IsHaveHeroSkin(cHeroSkin.m_heroId, cHeroSkin.m_skinId, false);
                            }
                        }
                    }
                    Transform transform = this.uiItem.transform.FindChild("Panel/GetItemCell/HaveItemFlag");
                    if (transform != null && transform.gameObject != null)
                    {
                        transform.gameObject.CustomSetActive(bActive);
                    }
                    if (cUseable.m_type == COM_ITEM_TYPE.COM_OBJTYPE_ITEMPROP)
                    {
                        CItem cItem = cUseable as CItem;
                        if (cItem != null && cItem.m_itemData.bIsView > 0)
                        {
                            CUICommonSystem.SetItemCell(this.owner.view.form.formScript, gameObject6, cUseable, true, false, false, true);
                        }
                        else
                        {
                            CUICommonSystem.SetItemCell(this.owner.view.form.formScript, gameObject6, cUseable, true, false, false, false);
                            if (gameObject6 != null)
                            {
                                CUIEventScript component3 = gameObject6.GetComponent <CUIEventScript>();
                                if (component3 != null)
                                {
                                    component3.SetUIEvent(enUIEventType.Click, enUIEventID.None);
                                }
                            }
                        }
                    }
                    else
                    {
                        CUICommonSystem.SetItemCell(this.owner.view.form.formScript, gameObject6, cUseable, true, false, false, false);
                        if (gameObject6 != null)
                        {
                            CUIEventScript component4 = gameObject6.GetComponent <CUIEventScript>();
                            if (component4 != null)
                            {
                                component4.SetUIEvent(enUIEventType.Click, enUIEventID.None);
                            }
                        }
                    }
                    ExchangeActivity exchangeActivity = this.owner.view.activity as ExchangeActivity;
                    if (exchangeActivity != null)
                    {
                        GameObject gameObject7      = this.uiItem.transform.FindChild("ExchangeCount").gameObject;
                        uint       maxExchangeCount = exchangeActivity.GetMaxExchangeCount((int)this.phase.Config.bIdx);
                        uint       exchangeCount    = exchangeActivity.GetExchangeCount((int)this.phase.Config.bIdx);
                        if (maxExchangeCount > 0u)
                        {
                            gameObject7.CustomSetActive(true);
                            gameObject7.GetComponent <Text>().set_text(string.Format(Singleton <CTextManager> .GetInstance().GetText("Exchange_TimeLimit"), exchangeCount, maxExchangeCount));
                            if (exchangeCount >= maxExchangeCount)
                            {
                                CUICommonSystem.SetButtonEnableWithShader(gameObject.GetComponent <Button>(), false, true);
                            }
                        }
                        else
                        {
                            gameObject7.CustomSetActive(false);
                        }
                    }
                }
            }