Exemple #1
0
        public void SetData(UserMissionVo vo, MissionRulePB missionPb)
        {
            _userMissionVo  = vo;
            _missionPb      = missionPb;              //missionModel.GetMissionById(vo.MissionId);
            _titleName.text = _missionPb.MissionDesc; //任务描述
//            _activityTime.text ="X"+missionPb.Award.Num.ToString();//这个应该是活力字段获取应该错误了。
            _activity.text = _missionPb.Weight.ToString();

//            Debug.LogError(_missionPb.MissionDesc);
            _taskBtn.onClick.RemoveAllListeners();
            switch (vo.Status)
            {
            case    MissionStatusPB.StatusUnfinished:
                //未完成的状态
                _taskState.text = I18NManager.Get("Common_Goto");
                _taskBtn.onClick.AddListener(JumpToOnClick);
                _task.sprite = AssetManager.Instance.GetSpriteAtlas("UIAtlas_Task_gotoBottom");
                _taskBtn.gameObject.Show();
                _finished.Hide();
                break;

            case    MissionStatusPB.StatusUnclaimed:
                //未领取
                _taskState.text = I18NManager.Get("Common_GetReward");
                _taskBtn.onClick.AddListener(ReceiveGifts);
                _task.sprite = AssetManager.Instance.GetSpriteAtlas("UIAtlas_Task_receiveBottom");
                _taskBtn.gameObject.Show();
                _finished.Hide();
                break;

            case    MissionStatusPB.StatusBeRewardedWith:
                //已完成
                _taskBtn.gameObject.Hide();
                _finished.Show();
                break;
            }

            //Debug.LogError(missionPb.Award.Count);
            for (int i = 0; i < _missionPb.Award.Count; i++)
            {
                RewardVo rewardVo = new RewardVo(_missionPb.Award[i]);
                if (rewardVo.Resource == ResourcePB.Gold)
                {
                    _gold.text = _missionPb.Award[i].Num.ToString();
                }
                else if (rewardVo.Resource == ResourcePB.Exp)
                {
                    _rewardName.text = rewardVo.Name;
                    _exp.text        = rewardVo.Num.ToString();
                }
            }

            _progressText.text        = (vo.Progress > vo.Finish?vo.Finish:vo.Progress) + "/" + vo.Finish;
            _taskProgressBar.DeltaX   = 0;
            _taskProgressBar.Progress = (int)((float)vo.Progress / vo.Finish * 100);

            //根据Vo的状态来修改按钮的显示。
        }
        private void OnReceiveReward(UserMissionVo vo)
        {
            if (vo.Status == MissionStatusPB.StatusUnclaimed)
            {
                LoadingOverlay.Instance.Show();
//            Debug.LogError("StatusUnclaimed");
                curMissionTypePb = vo.MissionType;
                // Debug.LogError(vo.MissionId+" "+vo.MissionType);
                var buffer = NetWorkManager.GetByteData(new MissionAwardsReq()
                {
                    MissionId = vo.MissionId, MissionType = vo.MissionType
                });
                NetWorkManager.Instance.Send <MissionAwardsRes>(CMD.MISSION_AWARDS, buffer, OnGetAwardCallBack);
            }
        }
//        private void OnGoBackToMain()
//        {
//            ModuleManager.Instance.GoBack();
//        }
//
//
//        private void OnJumpToBuyWindow(string str)
//        {
//            int temp = 0;
//
//            switch (str)
//            {
//                case "BuyEnergy":
//                    temp = PropConst.PowerIconId;
//                    QuickBuy.BuyGlodOrPorwer(temp, PropConst.GemIconId);
//                    break;
//                case "BuyGold":
//                    temp = PropConst.GoldIconId;
//                    QuickBuy.BuyGlodOrPorwer(temp, PropConst.GemIconId);
//                    break;
//                case "BuyEncouragePower":
//                    temp = PropConst.EncouragePowerId;
//                    QuickBuy.BuyGlodOrPorwer(temp, PropConst.GemIconId);
//                    break;
//
//            }
//
//            //要等待他们购买金币成功的时候才需要返回!
//
//        }


        private void ReceiveItemReward(UserMissionVo vo)
        {
            if (vo.Status == MissionStatusPB.StatusUnclaimed)
            {
                LoadingOverlay.Instance.Show();
//            Debug.LogError("StatusUnclaimed");
                _curPlayerPb = _missionModel.GetMissionById(vo.MissionId).Player;
//                Debug.LogError(vo.MissionId+" "+vo.MissionType);
                _replaceId = vo.MissionId;
                var buffer = NetWorkManager.GetByteData(new MissionAwardsReq()
                {
                    MissionId = vo.MissionId, MissionType = vo.MissionType
                });
                NetWorkManager.Instance.Send <MissionAwardsRes>(CMD.MISSION_AWARDS, buffer, OnGetAwardCallBack, OnGetAwardError);
            }
        }