/// <summary> /// 服务器回调 /// </summary> /// <param name="sCLucky"></param> private void ServerCallback(SCLucky sCLucky) { //抽奖获取数据失败 if (sCLucky == null) { _isLotteryState = false; return; } //界面更新 if (_isADLottery) { _defADNum -= 1; UpdateADButton(); } else { _curRemainingNum -= 1; UpdateRemainingNum(); } //物品返回 if (sCLucky != null && sCLucky.Info != null && sCLucky.Info.GoodsId != 0) { //加入临时表 ZillionairePlayerManager._instance.CurrentPlayer.AddPlayerRewards(sCLucky.Info.GoodsId, sCLucky.Info.Count); // SetBrizeIcon(sCLucky.Info.GoodsId); _lotteryItem = new GoodIDCount(); _lotteryItem.ID = sCLucky.Info.GoodsId; _lotteryItem.Count = sCLucky.Info.Count; } //播放效果 PlayEffec(); }
/// <summary> /// 领取奖励 /// </summary> /// <param name="define"></param> /// <param name="endAction"></param> public static void GetTaskAward(List <TaskDefine> defines, bool isOneKey, Action <bool, SCGetTaskAward> endAction) { List <CSWareHouseStruct> datas = new List <CSWareHouseStruct>(); Dictionary <int, CSWareHouseStruct> dataDic = new Dictionary <int, CSWareHouseStruct>(); for (int i = 0; i < defines.Count; i++) { TaskDefine taskDefine = defines[i]; for (int e = 0; e < taskDefine.TaskAward.Count; e++) { GoodIDCount data = taskDefine.TaskAward[e]; if (dataDic.ContainsKey(data.ID)) { dataDic[data.ID].GoodNum = dataDic[data.ID].GoodNum + (int)data.Count; } else { CSWareHouseStruct cSWareHouseStruct = new CSWareHouseStruct(); cSWareHouseStruct.GoodId = data.ID; cSWareHouseStruct.GoodNum = (int)data.Count; dataDic.Add(cSWareHouseStruct.GoodId, cSWareHouseStruct); } } } foreach (var item in dataDic) { datas.Add(item.Value); } StaticData.OpenCommonReceiveAwardTips(StaticData.GetMultilingual(120246), StaticData.GetMultilingual(120195), "", () => { GetTaskAwardAction(defines, isOneKey, endAction); }, null, datas); }
/// <summary> /// 创建item实列 /// </summary> public void CreationItem(GoodIDCount data) { Transform item = GameObject.Instantiate(_taskMinItemRect, _scrollRect.content); TaskPanelAwardItem taskPanelAwardItem = new TaskPanelAwardItem(); taskPanelAwardItem.Initial(item.GetComponent <RectTransform>(), data); _showAwardItems.Add(taskPanelAwardItem); }
/// <summary> /// 初始化itme /// </summary> /// <param name="tra"></param> /// <param name="data"></param> public void Initial(RectTransform tra, GoodIDCount data) { _thisRect = tra; _icon = _thisRect.Find("IconBox/Icon").GetComponent <Image>(); _numberText = _thisRect.Find("IconBox/Number").GetComponent <Text>(); _nameText = _thisRect.Find("Name").GetComponent <Text>(); _showData = data; ShowData(); }
/// <summary> /// 展示数据 /// </summary> public void ShowData() { _showTitleText.text = StaticData.GetMultilingual(_showData.TaskName); string showTipStr = StaticData.GetMultilingual(_showData.TaskDetails); showTipStr = string.Format(showTipStr, _showData.FinishNum); _showTipText.text = showTipStr; int currIndex = _controller.GetTaskFinishNumber(_showData); int maxIndex = _showData.FinishNum; _verifyBtn.onClick.RemoveAllListeners(); _verifyBtn.enabled = true; if (currIndex >= maxIndex) { //是否已领取 bool isGet = _controller.IsAlreadyGetAward(_showData); if (isGet) { _verifyBtnImage.sprite = _controller.GetBtnSprite(1); _verifyBtnNameText.text = "领取奖励"; _verifyBtn.onClick.AddListener(GetAward); } else { _verifyBtn.enabled = false; _verifyBtnImage.sprite = _controller.GetBtnSprite(2); _verifyBtnNameText.text = "已领取"; } _verifyBtnNumberText.text = currIndex + "/" + maxIndex; } else { _verifyBtnNumberText.text = "<color=red>" + currIndex + "</color>" + "/" + maxIndex; _verifyBtnImage.sprite = _controller.GetBtnSprite(0); _verifyBtnNameText.text = "前往"; _verifyBtn.onClick.AddListener(LeaveFor); } DisposeAllCurrShowItem(); for (int i = 0; i < _showData.TaskAward.Count; i++) { GoodIDCount goodIDCount = _showData.TaskAward[i]; CreationItem(goodIDCount); } if (_scrollRect.content.rect.width > _scrollRect.transform.GetComponent <RectTransform>().rect.width) { _scrollRect.enabled = true; } else { _scrollRect.enabled = false; } _thisRect.gameObject.SetActive(true); }
/// <summary> /// 发送请求到服务器 /// </summary> private void SendRequestServer() { _lotteryItem = null; ZillionaireToolManager.NotifyServerChooseOrLucky(LuckyTyep.LuckyProp, null, ServerCallback); }