/// <summary> /// 返回true,应用数据成功,返回false,应用数据失败。 /// </summary> /// <param name="data"></param> /// <returns></returns> public bool ApplyData(HintItem data) { _data = data; if (_data == null) { return(false); } if (!ContentImage) { return(false); } var resourcePath = GetAssetBundleByPicNameMap.GetAssetBundleName(data.content_pic); ContentImage.SetTargetPic(data.content_pic, resourcePath, data.content_pic_url, true); var eventId = string.Format( "hintitem_{0}_{1}_show", HintItemPos.IdOfPos(data.pos), HintItemType.IdOf(data.type)); GetAnalyticManager().Event(eventId); return(true); }
public void SetJianMeng(JianMengItem jianMeng) { if (jianMeng == null) { Image.Reset(); if (!Text.gameObject.activeSelf) { Text.gameObject.SetActive(true); } Text.text = "#%?~"; return; } if (!Text.gameObject.activeSelf) { Text.gameObject.SetActive(true); } Text.text = jianMeng.display_msg; Image.SetTargetPic( jianMeng.pic, ResourcePath.JianMeng, jianMeng.pic_url, true, null, () => { if (Text.gameObject.activeSelf) { Text.gameObject.SetActive(false); } }); }
private void RefreshContent() { if (_refreshTime >= _user.Timestamp) { return; } _refreshTime = _user.Timestamp; var user = _user.Read(); if (user == null) { ResetContent(); return; } Nickname.text = user.nickname; Level.text = string.Format("{0}级 {1}", user.level, user.title); float rate = user.round_count != 0 ? ((float)user.win_count / user.round_count) : 0; WinRate.text = string.Format("胜率 {0}", DataUtil.FormatWinRate(rate)); SecondMoney.text = "" + user.second_money; Money.text = "" + user.money; if (string.IsNullOrEmpty(user.headicon_url)) { HeadIcon.gameObject.SetActive(false); } else { var myUser = _user.Read(); HeadIcon.SetTargetPic(myUser.HeadIconPic(), null, user.headicon_url); } WechatTag.SetActive(user.type == UserType.Wechat); }
public override void BindData(int currentIndex, CheckinCondition data) { _data = data; if (data == null) { Reset(currentIndex); return; } if (!AwardImage.gameObject.activeSelf) { AwardImage.gameObject.SetActive(true); } AwardImage.SetTargetPic(data.pic, ResourcePath.CheckinPath, data.pic_url); if (!DayCount.gameObject.activeSelf) { DayCount.gameObject.SetActive(true); } DayCount.text = "连续签到" + data.day_count + "天"; if (!AwardDescription.gameObject.activeSelf) { AwardDescription.gameObject.SetActive(true); } AwardDescription.text = data.description; if (FinishTag.activeSelf != data.awarded) { FinishTag.SetActive(data.awarded); } }
public void ApplyData(UserTaskState data, TaskItem item) { _data = data; _item = item; if (data == null) { return; } if (item == null) { return; } float progress = (float)data.current_progress / data.total_progress; GoToBtn.gameObject.SetActive(false); GetAwardBtn.gameObject.SetActive(false); HasGet.SetActive(false); if (progress >= 0 && progress < 1) { GoToBtn.gameObject.SetActive(true); } else { if (data.award_posted) { HasGet.SetActive(true); } else { GetAwardBtn.gameObject.SetActive(true); } } AwardIcon.SetTargetPic(data.pic, null, data.pic_url); AwardName.text = CurrencyType.LabelOf(data.display_currency_type); var currencyList = data.currency; if (currencyList == null || currencyList.Count <= 0) { AwardDescription.text = ""; return; } var awards = ""; for (int i = 0; i < currencyList.Count; i++) { awards = awards + CurrencyType.LabelOf(currencyList[i].type) + " x " + currencyList[i].count + " "; } AwardDescription.text = "领取后立即得到:" + awards; }
public override void BindData(int currentIndex, com.morln.game.gd.command.YuanBaoItem data) { _data = data; if (data == null) { Reset(currentIndex); return; } if (Icon) { Icon.SetTargetPic(data.pic, ResourcePath.YuanBaoPath, data.pic_url); } if (PriceTxt) { PriceTxt.text = string.Format("{0}兑奖券", data.price); } if (LeftCountTxt) { LeftCountTxt.text = string.Format("剩余{0}个", data.left_count); } if (NameGroup) { var hasDisplayName = !string.IsNullOrEmpty(data.displayName); if (NameGroup.activeSelf != hasDisplayName) { NameGroup.SetActive(hasDisplayName); } } if (NameTxt) { NameTxt.text = data.displayName; } if (TagGroup) { var hasTag = !string.IsNullOrEmpty(data.tag); if (TagGroup.activeSelf != hasTag) { TagGroup.SetActive(hasTag); } } if (TagTxt) { TagTxt.text = data.tag; } }
public override void BindData(int currentIndex, UserTaskState data) { _data = data; if (data == null) { Reset(currentIndex); return; } AwardIcon.SetTargetPic(data.pic, null, data.pic_url); AwardCounText.text = data.display_currency_amount + ""; DescriptionText.text = _data.description; if (data.current_progress < 0 || data.total_progress <= 0) { Reset(currentIndex); return; } float progress = (float)data.current_progress / data.total_progress; TaskProcess.value = progress; ProgressTxt.text = data.current_progress >= data.total_progress ? "已完成" : data.current_progress + "/" + data.total_progress; GoToBtn.gameObject.SetActive(false); GetAwardBtn.gameObject.SetActive(false); HasGet.SetActive(false); if (progress >= 0 && progress < 1) { GoToBtn.gameObject.SetActive(true); } else { if (data.award_posted) { HasGet.SetActive(true); } else { GetAwardBtn.gameObject.SetActive(true); } } }
private void Start() { if (AdImg) { _hintItem = GetHintItemByPos(HintItemPos.HALL_BOTTOM); if (_hintItem == null || string.IsNullOrEmpty(_hintItem.outer_pic)) { AdImg.Reset(); } else { AdImg.SetTargetPic(ResourcePicName.ActivityOuterPic, ResourcePath.PortalWindow, null, true); } } }
public void SetHair(int sex, string hair) { // MyLog.InfoWithFrame(name, string.Format("set hair: {0}, {1}", sex, hair)); if (!HairImage) { return; } var defHair = sex == 1 ? DefBoyHair : DefGirlHair; var defHairBg = sex == 1 ? null : DefGirlHairBg; var commodityList = _commodityList.Read(); var data = GameUtil.GetCommodity(commodityList, hair); if (data == null || string.IsNullOrEmpty(data.pic)) { HairImage.SetSprite(defHair, true); // 设置默认的HairBg。 if (HairBgImage) { if (sex == 1) { HairBgImage.Reset(); } else { HairBgImage.SetSprite(defHairBg, true); } } return; } HairImage.SetTargetPic(data.pic, ResourcePath.CommodityPath, data.pic_url, true, defHair); if (HairBgImage) { if (!string.IsNullOrEmpty(data.pic_bg)) { HairBgImage.SetTargetPic(data.pic_bg, ResourcePath.CommodityPath, data.pic_bg_url, true, defHairBg); } else { HairBgImage.Reset(); } } }
public void SetDeskItem(string deskItem) { if (!DeskItemImage) { return; } var commodityList = _commodityList.Read(); var data = GameUtil.GetCommodity(commodityList, deskItem); if (data == null || string.IsNullOrEmpty(data.pic)) { DeskItemImage.Reset(); return; } DeskItemImage.SetTargetPic(data.pic, ResourcePath.CommodityPath, data.pic_url, true); }
public override void BindData(int currentIndex, JianMengItem data) { _data = data; if (data == null) { Reset(currentIndex); return; } var vip = data.vip > 0; if (VipTag.activeSelf != vip) { VipTag.SetActive(vip); } Pic.SetTargetPic(data.pic, ResourcePath.JianMeng, data.pic_url); }
public void SetBody(int sex, string body) { if (!BodyImage) { return; } var defBody = sex == 1 ? DefBoyBody : DefGirlBody; var commodityList = _commodityList.Read(); var data = GameUtil.GetCommodity(commodityList, body); if (data == null || string.IsNullOrEmpty(data.pic)) { BodyImage.SetSprite(defBody, true); return; } BodyImage.SetTargetPic(data.pic, ResourcePath.CommodityPath, data.pic_url, true, defBody); }
public override void BindData(int currentIndex, RaceConfig data) { _data = data; if (data == null) { return; } // 载入比赛图片。 if (string.IsNullOrEmpty(data.pic)) { RaceIcon.Reset(); } else { RaceIcon.SetTargetPic(data.pic, null, data.pic_url); } DisPlayNameTxt.text = data.display_name; RaceDateTxt.text = data.race_description; RaceDescriptionTxt.text = data.award_description; RaceStartTimeTxt.text = data.open_time; if (data.fee != null) { Tickets.SetCurrency(data.fee.count, data.fee.type); } if (!data.race_over) { SignUpOverBtn.gameObject.SetActive(false); SignUpBtn.gameObject.SetActive(!data.signed_up); MatchBtn.gameObject.SetActive(data.signed_up); } else { SignUpOverBtn.gameObject.SetActive(true); } }
public override void BindData(int currentIndex, Room data) { _data = data; if (data == null) { // 如果没有数据的话,应该怎么显示房间按钮呢? // 房间可以不显示,但是是不是要显示在线人数。 return; } // 载入人数和底注。 BaseMoney.SetCurrency(_data.base_money, CurrencyType.GOLDEN_EGG); PlayerCount.text = "" + data.current_player_num; // 载入房间图片。 if (string.IsNullOrEmpty(data.room_pic)) { RoomPic.Reset(); } else { var resourcePath = GetAssetBundleByPicNameMap.GetAssetBundleName(data.room_pic); RoomPic.SetTargetPic(data.room_pic, resourcePath, data.room_pic_url); } if (data.type == RoomType.Ad) { RoomContainer.SetActive(false); TagContainer.SetActive(false); var hintItem = data.hint_item; if (hintItem != null && !string.IsNullOrEmpty(hintItem.content_pic)) { var contentPic = _resourceCache.LoadSpriteFromLocalFile(hintItem.content_pic); if (!contentPic) { if (!string.IsNullOrEmpty(hintItem.content_pic_url) && !_resourceCache.ContainsDownloadTask(hintItem.content_pic)) { _resourceCache.StartDownload( hintItem.content_pic, hintItem.content_pic_url, ContentType.Image); } } } } else { RoomContainer.SetActive(true); TagContainer.SetActive(true); } // 设置标签。 if (!string.IsNullOrEmpty(data.tag)) { if (!Tag1Group.activeSelf) { Tag1Group.SetActive(true); } Tag1.text = data.tag; } else { if (Tag1Group.activeSelf) { Tag1Group.SetActive(false); } } if (!string.IsNullOrEmpty(data.tag1)) { if (!Tag2Group.activeSelf) { Tag2Group.SetActive(true); } Tag2.text = data.tag1; } else { if (Tag2Group.activeSelf) { Tag2Group.SetActive(false); } } if (!Button.gameObject.activeSelf) { Button.gameObject.SetActive(true); } }
public override void BindData(int currentIndex, FriendInfo data) { _data = data; if (data == null) { return; } if (string.IsNullOrEmpty(data.friend_head_icon)) { HeadIcon.gameObject.SetActive(false); } else { HeadIcon.gameObject.SetActive(true); HeadIcon.SetTargetPic(GetHeadIconName(data.friend_head_icon), null, data.friend_head_icon); } if (Nickname) { if (!Nickname.gameObject.activeSelf) { Nickname.gameObject.SetActive(true); } Nickname.text = data.nickname; } if (OnlineState) { if (!OnlineState.gameObject.activeSelf) { OnlineState.gameObject.SetActive(true); } switch (data.online_state) { case com.morln.game.gd.command.OnlineState.Offline: OnlineState.sprite = OfflineSprite; break; case com.morln.game.gd.command.OnlineState.Online: case com.morln.game.gd.command.OnlineState.Playing: OnlineState.sprite = OnlineSprite; break; } } if (FunctionGroup && FunctionGroup.gameObject.activeSelf) { FunctionGroup.gameObject.SetActive(false); } _selected = false; if (Layout) { Layout.preferredWidth = NormalSize.x; Layout.preferredHeight = NormalSize.y; } }
public override void BindData(int currentIndex, Commodity data) { if (data == null) { return; } _data = data; if (SelectCover && !SelectCover.gameObject.activeSelf) { SelectCover.gameObject.SetActive(false); } var pic = data.pic; if (Image) { if (!string.IsNullOrEmpty(pic)) { Image.SetTargetPic(pic, ResourcePath.CommodityPath, data.pic_url, true); } else { Image.Reset(); } } if (BgImage) { var picBg = data.pic_bg; if (!string.IsNullOrEmpty(picBg)) { BgImage.SetTargetPic(picBg, ResourcePath.CommodityPath, data.pic_bg_url, true); } else { BgImage.Reset(); } } if (data.vip_level > 0) { if (!VIPTag.activeSelf) { VIPTag.SetActive(true); } } else { if (VIPTag.activeSelf) { VIPTag.SetActive(false); } } var bag = _bag.Read(); var user = _user.Read(); if (!GameUtil.HasCommodity(bag, data)) { if (UnlockTag && !UnlockTag.activeSelf) { UnlockTag.SetActive(true); } if (StateGroup && !StateGroup.activeSelf) { StateGroup.SetActive(true); } if (StateText) { StateText.text = "" + CommodityHelper.GetPrice(data) + CurrencyType.LabelOf(CommodityHelper.GetCurrencyType(data)); } } else { if (UnlockTag && UnlockTag.activeSelf) { UnlockTag.SetActive(false); } if (StateGroup && !StateGroup.activeSelf) { StateGroup.SetActive(true); } if (StateText) { StateText.text = GameUtil.IsCommodityEquiped(bag, user, data) ? "<color=#4ae91a>当前装饰</color>" : "<color=#f0aa4b>已购买</color>"; } } }
public void Apply(RaceAward msg) { var raceAward = msg; if (raceAward == null) { Reset(); return; } RankTxt.text = "" + raceAward.race_rank; ShareRankTxt.text = "" + raceAward.race_rank; RaceNameTxt.text = raceAward.race_name; ShareRaceNameTxt.text = raceAward.race_name; HelpDescriptionTxt.text = raceAward.help; if (string.IsNullOrEmpty(raceAward.wx_share_url)) { QrCodeImageBg.SetActive(false); } else { var sprite = GenerateQRCode.GenerateQRCodeSpriteFromUrl(raceAward.wx_share_url); if (sprite == null) { QrCodeImageBg.SetActive(false); } else { ShareQrCodeImage.sprite = sprite; QrCodeImageBg.SetActive(true); } } if (string.IsNullOrEmpty(raceAward.description)) { AwardHongbaoTxt.gameObject.SetActive(false); ShareAwardHongbaoTxt.gameObject.SetActive(false); } else { AwardHongbaoTxt.text = raceAward.description; ShareAwardHongbaoTxt.text = raceAward.description; AwardHongbaoTxt.gameObject.SetActive(true); ShareAwardHongbaoTxt.gameObject.SetActive(true); } if (_currencyList.Count > 0) { for (var i = 0; i < _currencyList.Count; i++) { Destroy(_currencyList[i].gameObject); } _currencyList.Clear(); } var currencys = raceAward.currency; _currency.Clear(); if (currencys == null || currencys.Count == 0) { AwardCurrency.SetActive(false); ShareAwardCurrency.SetActive(false); } else { _currency.AddRange(currencys); for (var i = 0; i < currencys.Count; i++) { var cur = _currencyValueFactory.Create(); var shareCur = _currencyValueFactory.Create(); if (cur) { cur.transform.SetParent(AwardCurrency.transform, false); cur.SetCurrency(currencys[i].count, currencys[i].type); cur.AmountTxt.color = Color.yellow; _currencyList.Add(cur); } if (shareCur) { shareCur.transform.SetParent(ShareAwardCurrency.transform, false); shareCur.SetCurrency(currencys[i].count, currencys[i].type); shareCur.AmountTxt.color = Color.yellow; _currencyList.Add(shareCur); } } AwardCurrency.SetActive(true); ShareAwardCurrency.SetActive(true); } var user = raceAward.user; if (user == null) { HeadIcon.Reset(); ShareNickname.text = ""; } else { ShareNickname.text = user.nickname; if (string.IsNullOrEmpty(user.headicon_url)) { HeadIcon.gameObject.SetActive(false); } else { HeadIcon.SetTargetPic(HeadIconPic(user), null, user.headicon_url); } } }
private void SetDetailContent(Commodity data) { if (data != null) { var vip = data.vip_level > 0; if (VIPTag.activeSelf != vip) { VIPTag.SetActive(vip); } if (DetailImage && !DetailImage.gameObject.activeSelf) { DetailImage.gameObject.SetActive(true); } if (DetailBgImage && DetailBgImage.gameObject.activeSelf) { DetailBgImage.gameObject.SetActive(true); } var pic = data.pic; if (DetailImage) { if (!string.IsNullOrEmpty(pic)) { DetailImage.SetTargetPic(pic, ResourcePath.CommodityPath, null, true); } else { DetailImage.Reset(); } } if (DetailBgImage) { var picBg = data.pic_bg; if (!string.IsNullOrEmpty(picBg)) { DetailBgImage.SetTargetPic(picBg, ResourcePath.CommodityPath, null, true); } else { DetailBgImage.Reset(); } } if (DetailName) { if (!DetailName.gameObject.activeSelf) { DetailName.gameObject.SetActive(true); } DetailName.text = data.display_name; } if (DetailPrice) { if (!DetailPrice.gameObject.activeSelf) { DetailPrice.gameObject.SetActive(true); } DetailPrice.SetCurrency(CommodityHelper.GetPrice(data), CommodityHelper.GetCurrencyType(data)); } var bag = _bag.Read(); var user = _user.Read(); var hasCommodity = GameUtil.HasCommodity(bag, data); var equiped = hasCommodity && GameUtil.IsCommodityEquiped(bag, user, data); if (hasCommodity) { // 隐藏购买按钮。 if (BuyBtn && BuyBtn.gameObject.activeSelf) { BuyBtn.gameObject.SetActive(false); } // 使用按钮与是否装备相反。 if (UseBtn) { if (!UseBtn.gameObject.activeSelf) { UseBtn.gameObject.SetActive(true); } UseBtn.interactable = !equiped; } if (UnUseBtn) { if (!UnUseBtn.gameObject.activeSelf) { UnUseBtn.gameObject.SetActive(true); } UnUseBtn.interactable = equiped; } // 6.2版本不再显示典当按钮。 if (SaleBtn && SaleBtn.gameObject.activeSelf) { SaleBtn.gameObject.SetActive(false); } // 6.2版本不再显示典当提示。 if (SaleTip && SaleTip.gameObject.activeSelf) { SaleTip.gameObject.SetActive(false); } } else { if (BuyBtn && !BuyBtn.gameObject.activeSelf) { BuyBtn.gameObject.SetActive(true); } if (UseBtn && UseBtn.gameObject.activeSelf) { UseBtn.gameObject.SetActive(false); } if (UnUseBtn && UnUseBtn.gameObject.activeSelf) { UnUseBtn.gameObject.SetActive(false); } if (SaleBtn && SaleBtn.gameObject.activeSelf) { SaleBtn.gameObject.SetActive(false); } if (SaleTip && SaleTip.gameObject.activeSelf) { SaleTip.gameObject.SetActive(false); } } } else { if (DetailBgImage) { DetailBgImage.Reset(); } if (DetailImage) { DetailImage.Reset(); } if (DetailName && DetailName.gameObject.activeSelf) { DetailName.gameObject.SetActive(false); } if (DetailPrice && DetailPrice.gameObject.activeSelf) { DetailPrice.gameObject.SetActive(false); } if (BuyBtn && BuyBtn.gameObject.activeSelf) { BuyBtn.gameObject.SetActive(false); } if (UseBtn && UseBtn.gameObject.activeSelf) { UseBtn.gameObject.SetActive(false); } if (UnUseBtn && UnUseBtn.gameObject.activeSelf) { UnUseBtn.gameObject.SetActive(false); } if (SaleBtn && SaleBtn.gameObject.activeSelf) { SaleBtn.gameObject.SetActive(false); } if (SaleTip && SaleTip.gameObject.activeSelf) { SaleTip.gameObject.SetActive(false); } } }
public override void BindData(int currentIndex, Prepayment data) { _data = data; if (data == null) { if (NormalGroup.activeSelf) { NormalGroup.SetActive(false); } PackageImg.Reset(); return; } if (data.currency_type == CurrencyType.COMPOUND) { // 礼包类型的支付包。 if (NormalGroup && NormalGroup.activeSelf) { NormalGroup.SetActive(false); } if (string.IsNullOrEmpty(data.pic)) { gameObject.SetActive(false); } else { PackageImg.SetTargetPic(data.pic, null, data.pic_url); } return; } // 普通类型的支付包。 PackageImg.Reset(); if (!NormalGroup.activeSelf) { NormalGroup.SetActive(true); } if (!Icon.gameObject.activeSelf) { Icon.gameObject.SetActive(true); } Icon.sprite = _spriteHolder.GetPrepaymentIcon(data.currency_type); Icon.SetNativeSize(); if (!Price.gameObject.activeSelf) { Price.gameObject.SetActive(true); } Price.text = "¥ " + data.price; HotTag.gameObject.SetActive(false); RecommendTag.gameObject.SetActive(false); if (!string.IsNullOrEmpty(data.tag)) { if (!TagGroup.gameObject.activeSelf) { TagGroup.gameObject.SetActive(true); } if (data.tag == _hotTag) { HotTag.gameObject.SetActive(true); } else if (data.tag == _recommendTag) { RecommendTag.gameObject.SetActive(true); } } else { if (TagGroup.gameObject.activeSelf) { TagGroup.gameObject.SetActive(false); } } if (!string.IsNullOrEmpty(data.display_name)) { if (!NameGroup.activeSelf) { NameGroup.SetActive(true); } Name.text = data.display_name; Description.text = data.description; } else { if (NameGroup.activeSelf) { NameGroup.SetActive(false); } } }