コード例 #1
0
    /// <summary>
    /// 设置进度
    /// </summary>
    private void SetProgress()
    {
        SetProgressData();

        for (int i = 0; i < _tabBarTran.childCount; i++)
        {
            int weight  = _missionModel.GetStarReceiveWeight(i);                   //ReceiveWeight(i);
            var frameBg = _tabBarTran.GetChild(i).Find("FrameBg");
            var icon    = frameBg.GetRawImage("Icon");
            var redDot  = frameBg.Find("RedDot");
            var num     = _tabBarTran.GetChild(i).GetText("WeightTxt");
            num.text = weight.ToString();
            var mask    = _tabBarTran.GetChild(i).Find("Mask");
            var iconNum = frameBg.GetText("IconNum");
            var rewards = _missionModel.GetStarActivityRewardPBByCount(weight);
            PointerClickListener.Get(icon.gameObject).onClick = null;
            bool isGift = rewards.Count > 1;
            if (!isGift)
            {
                RewardVo vo = new RewardVo(rewards[0]);
                icon.texture = ResourceManager.Load <Texture>(vo.IconPath);
                icon.gameObject.Show();
                icon.transform.GetChild(0).gameObject.SetActive(vo.Resource == ResourcePB.Puzzle);
                iconNum.text = vo.Num.ToString();
            }
            else
            {
                string path = "Prop/GiftPack/tongyong2";
                icon.texture = ResourceManager.Load <Texture>(path);
                icon.gameObject.Show();
                iconNum.transform.gameObject.Hide();
                icon.transform.GetChild(0).gameObject.Hide();
            }

            if (_missionModel.StarActivityInfoPb == null)
            {
                redDot.gameObject.Hide();
                mask.gameObject.Hide();
                PointerClickListener.Get(icon.gameObject).onClick = go =>
                {
                    if (!isGift)
                    {
                        FlowText.ShowMessage(ClientData.GetItemDescById(rewards[0].ResourceId, rewards[0].Resource).ItemDesc);
                    }
                    else
                    {
                        //打开奖励预览窗口
                        var window = PopupManager.ShowWindow <CommonAwardWindow>("GameMain/Prefabs/AwardWindow/CommonAwardWindow");
                        window.SetData(rewards.ToList(), true, ModuleConfig.MODULE_STAR_ACTIVITY);
                    }
                };
            }
            else
            {
                //是否领取过 isGet为true领取过,false未领取
                var isGet = _missionModel.StarActivityInfoPb.List.Contains(weight);
                //是否可以领取 isMayGet为true可以领,false未领取
                var isMayGet = _missionModel.StarActivityInfoPb.Progress >= weight;

                if (isMayGet && !isGet)                      //可以领,没领过
                {
                    redDot.gameObject.Show();
                    PointerClickListener.Get(icon.gameObject).onClick = go =>
                    {
                        var isNew = _missionModel.IsNewStarActivity();
                        var type  = isNew ? MissionTypePB.NewStarryCovenant : MissionTypePB.StarryCovenant;

                        SendMessage(new Message(MessageConst.CMD_STAR_ACTIVITY_ACTIVE_REWARD,
                                                Message.MessageReciverType.CONTROLLER, type, weight));
                    };
                }
                else if (isMayGet && isGet)                      //可以领,领过了
                {
                    frameBg.gameObject.Hide();
                    mask.gameObject.Show();
                }
                else if (!isMayGet)                         //不可以领
                {
                    redDot.gameObject.Hide();
                    mask.gameObject.Hide();
                    PointerClickListener.Get(icon.gameObject).onClick = go =>
                    {
                        if (!isGift)
                        {
                            FlowText.ShowMessage(ClientData.GetItemDescById(rewards[0].ResourceId, rewards[0].Resource).ItemDesc);
                        }
                        else
                        {
                            var window = PopupManager.ShowWindow <CommonAwardWindow>("GameMain/Prefabs/AwardWindow/CommonAwardWindow");
                            window.SetData(rewards.ToList(), true, ModuleConfig.MODULE_STAR_ACTIVITY);
                        }
                    };
                }
            }
        }
    }