Exemplo n.º 1
0
        public static void OnReceiveGetTrophyRewardRsp(CSPkg msg)
        {
            Singleton <CUIManager> .GetInstance().CloseSendMsgAlert();

            SCPKG_GET_TROPHYLVL_REWARD_RSP stGetTrophyLvlmentRewardRsp = msg.stPkgData.stGetTrophyLvlmentRewardRsp;

            if (stGetTrophyLvlmentRewardRsp.iResult < 0)
            {
                Singleton <CUIManager> .GetInstance().OpenTips(string.Format("奖励领取失败,请稍后再试 {0}", stGetTrophyLvlmentRewardRsp.iResult), false, 1.5f, null, new object[0]);

                return;
            }
            CAchieveInfo2 masterAchieveInfo = CAchieveInfo2.GetMasterAchieveInfo();
            int           num = (int)(stGetTrophyLvlmentRewardRsp.dwTrophyLvl - 1u);

            if (num < 0 || (long)num > (long)((ulong)masterAchieveInfo.TrophyRewardInfoArrCnt))
            {
                return;
            }
            CTrophyRewardInfo cTrophyRewardInfo = masterAchieveInfo.TrophyRewardInfoArr[num];

            CUseable[] trophyRewards = cTrophyRewardInfo.GetTrophyRewards();
            Singleton <CUIManager> .instance.OpenAwardTip(trophyRewards, null, false, enUIEventID.None, false, false, "Form_Award");

            cTrophyRewardInfo.State = TrophyState.GotRewards;
            Singleton <EventRouter> .GetInstance().BroadCastEvent(EventID.ACHIEVE_TROPHY_REWARD_INFO_STATE_CHANGE);
        }
Exemplo n.º 2
0
        private void RefreshOverviewForm(CUIFormScript overviewForm = null)
        {
            if (overviewForm == null)
            {
                overviewForm = Singleton <CUIManager> .GetInstance().GetForm("UGUI/Form/System/Achieve/Form_Trophy_Overview.prefab");
            }
            if (overviewForm == null)
            {
                return;
            }
            CUIListScript component = overviewForm.GetWidget(1).GetComponent <CUIListScript>();

            if (component != null)
            {
                component.SetElementAmount(this.m_CurAchieveSeries.Count);
            }
            GameObject widget  = overviewForm.GetWidget(2);
            GameObject widget2 = overviewForm.GetWidget(3);
            GameObject widget3 = overviewForm.GetWidget(7);
            GameObject widget4 = overviewForm.GetWidget(8);
            GameObject widget5 = overviewForm.GetWidget(9);
            GameObject widget6 = overviewForm.GetWidget(10);
            GameObject widget7 = overviewForm.GetWidget(4);
            GameObject widget8 = overviewForm.GetWidget(5);
            GameObject widget9 = overviewForm.GetWidget(6);

            if (widget == null || widget2 == null || widget3 == null || widget4 == null || widget7 == null || widget8 == null || widget9 == null || widget5 == null || widget6 == null)
            {
                DebugHelper.Assert(false, "Some of Trophy overview form widgets is null");
                return;
            }
            Text          component2        = widget.GetComponent <Text>();
            Text          component3        = widget2.GetComponent <Text>();
            Image         component4        = widget6.GetComponent <Image>();
            Image         component5        = widget3.GetComponent <Image>();
            Text          component6        = widget4.GetComponent <Text>();
            CAchieveInfo2 masterAchieveInfo = CAchieveInfo2.GetMasterAchieveInfo();

            if (masterAchieveInfo.LastDoneTrophyRewardInfo != null)
            {
                component4.SetSprite(masterAchieveInfo.LastDoneTrophyRewardInfo.GetTrophyImagePath(), overviewForm, true, false, false, false);
            }
            component2.set_text((masterAchieveInfo.LastDoneTrophyRewardInfo == null) ? "0" : string.Format("{0}", masterAchieveInfo.LastDoneTrophyRewardInfo.Cfg.dwTrophyLvl));
            if (masterAchieveInfo.GetWorldRank() == 0u)
            {
                widget5.CustomSetActive(true);
                widget2.CustomSetActive(false);
            }
            else
            {
                widget5.CustomSetActive(false);
                widget2.CustomSetActive(true);
                component3.set_text(masterAchieveInfo.GetWorldRank().ToString());
            }
            uint num  = 0u;
            uint num2 = 0u;

            masterAchieveInfo.GetTrophyProgress(ref num, ref num2);
            CTrophyRewardInfo trophyRewardInfoByPoint = masterAchieveInfo.GetTrophyRewardInfoByPoint(num);
            CTrophyRewardInfo trophyRewardInfoByIndex = masterAchieveInfo.GetTrophyRewardInfoByIndex(trophyRewardInfoByPoint.Index + 1);

            component5.set_fillAmount(Utility.Divide(num - trophyRewardInfoByIndex.MinPoint, trophyRewardInfoByIndex.MaxPoint - trophyRewardInfoByIndex.MinPoint));
            component6.set_text(string.Format("{0}/{1}", num - trophyRewardInfoByIndex.MinPoint, trophyRewardInfoByIndex.MaxPoint - trophyRewardInfoByIndex.MinPoint));
            Text              component7 = widget7.GetComponent <Text>();
            CUIListScript     component8 = widget8.GetComponent <CUIListScript>();
            CUIEventScript    component9 = widget9.GetComponent <CUIEventScript>();
            CTrophyRewardInfo firstTrophyRewardInfoAwardNotGot = masterAchieveInfo.GetFirstTrophyRewardInfoAwardNotGot();

            if (firstTrophyRewardInfoAwardNotGot == null)
            {
                widget7.CustomSetActive(false);
                widget9.CustomSetActive(false);
                component8.SetElementAmount(0);
            }
            else
            {
                bool       flag          = false;
                CUseable[] trophyRewards = firstTrophyRewardInfoAwardNotGot.GetTrophyRewards();
                if (!firstTrophyRewardInfoAwardNotGot.HasGotAward() && firstTrophyRewardInfoAwardNotGot.IsFinish())
                {
                    flag = true;
                }
                widget7.CustomSetActive(true);
                component7.set_text(string.Format("{0}级奖励:", firstTrophyRewardInfoAwardNotGot.Cfg.dwTrophyLvl));
                component8.SetElementAmount(trophyRewards.Length);
                for (int i = 0; i < trophyRewards.Length; i++)
                {
                    CUIListElementScript elemenet = component8.GetElemenet(i);
                    CUICommonSystem.SetItemCell(overviewForm, elemenet.GetWidget(0), trophyRewards[i], false, false, false, false);
                }
                widget9.CustomSetActive(true);
                if (flag)
                {
                    CUICommonSystem.SetButtonEnableWithShader(widget9.GetComponent <Button>(), true, true);
                    component9.SetUIEvent(enUIEventType.Click, enUIEventID.Achievement_Get_Trophy_Reward, new stUIEventParams
                    {
                        tag = firstTrophyRewardInfoAwardNotGot.Index
                    });
                }
                else
                {
                    CUICommonSystem.SetButtonEnableWithShader(widget9.GetComponent <Button>(), false, true);
                }
            }
        }
Exemplo n.º 3
0
        private void OnTrophyRewardInfoEnable(CUIEvent uiEvent)
        {
            int srcWidgetIndexInBelongedList = uiEvent.m_srcWidgetIndexInBelongedList;
            int num = (this.m_TrophyRewardInfoWithRewardList == null) ? 0 : this.m_TrophyRewardInfoWithRewardList.Count;

            if (srcWidgetIndexInBelongedList < 0 || srcWidgetIndexInBelongedList >= num)
            {
                return;
            }
            CTrophyRewardInfo    cTrophyRewardInfo    = this.m_TrophyRewardInfoWithRewardList[srcWidgetIndexInBelongedList];
            CUIListElementScript cUIListElementScript = uiEvent.m_srcWidgetScript as CUIListElementScript;

            if (cUIListElementScript == null)
            {
                DebugHelper.Assert(false, "achievement reward enable elementscript is null");
                return;
            }
            GameObject widget   = cUIListElementScript.GetWidget(0);
            GameObject widget2  = cUIListElementScript.GetWidget(1);
            GameObject widget3  = cUIListElementScript.GetWidget(2);
            GameObject widget4  = cUIListElementScript.GetWidget(3);
            GameObject widget5  = cUIListElementScript.GetWidget(4);
            GameObject widget6  = cUIListElementScript.GetWidget(5);
            GameObject widget7  = cUIListElementScript.GetWidget(6);
            GameObject widget8  = cUIListElementScript.GetWidget(7);
            GameObject widget9  = cUIListElementScript.GetWidget(8);
            GameObject widget10 = cUIListElementScript.GetWidget(9);
            GameObject widget11 = cUIListElementScript.GetWidget(10);

            if (cTrophyRewardInfo.HasGotAward())
            {
                widget.CustomSetActive(false);
                widget2.CustomSetActive(true);
                widget5.CustomSetActive(false);
                widget8.CustomSetActive(false);
                widget6.CustomSetActive(true);
                Text component = widget6.GetComponent <Text>();
                component.set_text(Singleton <CTextManager> .GetInstance().GetText("Achievement_Trophy_Reward_Status_Got"));
                widget9.CustomSetActive(false);
            }
            else if (cTrophyRewardInfo.IsFinish())
            {
                uint num2 = 0u;
                for (int i = 0; i < 3; i++)
                {
                    if (cTrophyRewardInfo.Cfg.astReqReward[i].dwRewardNum != 0u)
                    {
                        num2 += 1u;
                    }
                }
                if (num2 == 0u)
                {
                    widget.CustomSetActive(false);
                    widget2.CustomSetActive(true);
                    widget5.CustomSetActive(false);
                    widget8.CustomSetActive(false);
                    widget6.CustomSetActive(true);
                    Text component2 = widget6.GetComponent <Text>();
                    component2.set_text(Singleton <CTextManager> .GetInstance().GetText("Achievement_Trophy_Reward_Status_Done"));
                }
                else
                {
                    widget.CustomSetActive(true);
                    widget2.CustomSetActive(false);
                    widget5.CustomSetActive(false);
                    widget8.CustomSetActive(true);
                    widget6.CustomSetActive(false);
                    CUIEventScript component3 = widget8.GetComponent <CUIEventScript>();
                    if (component3 != null)
                    {
                        component3.SetUIEvent(enUIEventType.Click, enUIEventID.Achievement_Get_Trophy_Reward, new stUIEventParams
                        {
                            tag = cTrophyRewardInfo.Index
                        });
                    }
                }
                widget9.CustomSetActive(false);
            }
            else
            {
                widget.CustomSetActive(true);
                widget2.CustomSetActive(false);
                widget5.CustomSetActive(false);
                widget8.CustomSetActive(false);
                widget6.CustomSetActive(true);
                Text component4 = widget6.GetComponent <Text>();
                if (component4 != null)
                {
                    component4.set_text((cTrophyRewardInfo.State == TrophyState.OnGoing) ? Singleton <CTextManager> .GetInstance().GetText("Achievement_Trophy_Reward_Status_OnGoing") : Singleton <CTextManager> .GetInstance().GetText("Achievement_Trophy_Reward_Status_Not_Done"));
                }
                widget9.CustomSetActive(false);
            }
            Image component5 = widget3.GetComponent <Image>();

            component5.SetSprite(cTrophyRewardInfo.GetTrophyImagePath(), cUIListElementScript.m_belongedFormScript, true, false, false, false);
            Text component6 = widget4.GetComponent <Text>();

            if (component6 != null)
            {
                component6.set_text(cTrophyRewardInfo.Cfg.szTrophyDesc);
            }
            CUIListScript component7 = widget7.GetComponent <CUIListScript>();

            if (component7 != null)
            {
                CUseable[] trophyRewards = cTrophyRewardInfo.GetTrophyRewards();
                component7.SetElementAmount(trophyRewards.Length);
                for (int j = 0; j < trophyRewards.Length; j++)
                {
                    CUIListElementScript elemenet = component7.GetElemenet(j);
                    GameObject           widget12 = elemenet.GetWidget(0);
                    if (widget12 != null)
                    {
                        CUseable cUseable = trophyRewards[j];
                        if (cUseable == null)
                        {
                            component7.SetElementAmount(0);
                            return;
                        }
                        if (trophyRewards.Length >= 5)
                        {
                            CUICommonSystem.SetItemCell(component7.m_belongedFormScript, widget12, cUseable, false, false, false, false);
                        }
                        else
                        {
                            CUICommonSystem.SetItemCell(component7.m_belongedFormScript, widget12, cUseable, true, false, false, false);
                        }
                        if (cUseable.m_stackCount == 1)
                        {
                            Utility.FindChild(widget12, "cntBg").CustomSetActive(false);
                            Utility.FindChild(widget12, "lblIconCount").CustomSetActive(false);
                        }
                        else
                        {
                            Utility.FindChild(widget12, "cntBg").CustomSetActive(true);
                            Utility.FindChild(widget12, "lblIconCount").CustomSetActive(true);
                        }
                    }
                }
            }
        }