Пример #1
0
        //解析服务器传过来的头像编号 由heroid + star组成
        public static string ParseHeadIcon(int headNo)
        {
            //headicon

            int headHeroId = headNo / 10;
            int headStar   = (headNo - headHeroId * 10);

            //int isPet = headNo - headHeroId*100 - headStar*10;

            Logic.Hero.Model.HeroData heroData = Logic.Hero.Model.HeroData.GetHeroDataByID(headHeroId);

            if (heroData != null)
            {
//				if(heroData.hero_type == 2 )//主角
//				{
//					Logic.Pet.Model.PetData petdata = Logic.Pet.Model.PetData.GetPetDataByID(Logic.Player.Model.PlayerData.GetPlayerData((uint)headHeroId).pet_id);
//					return Common.ResMgr.ResPath.GetCharacterHeadIconPath(petdata.head_icon);
//				}else if(headStar <= heroData.headIcons.Length)
//				{
                return(ResPath.GetCharacterHeadIconPath(heroData.headIcons[headStar - 1]));
//				}
            }
            Debugger.LogError(string.Format("头像找不到 headHeroId :{0},star:{0}", headHeroId, headStar));
            return(Logic.Game.Model.GameProxy.instance.PlayerInfo.HeadIcon);
        }
Пример #2
0
        public void SetShopGoodItemInfo(ShopGoodsItemInfo shopGoodsItemInfo)
        {
            _shopGoodsItemInfo = shopGoodsItemInfo;

            GameResData goodsGameResData = _shopGoodsItemInfo.ShopGoodsData.goodsGameResData;

            nameText.text        = Localization.Get(_shopGoodsItemInfo.ShopGoodsData.name);
            descriptionText.text = Localization.Get(_shopGoodsItemInfo.ShopGoodsData.description);

            string itemIconSpritePath = string.Empty;

            if (!string.IsNullOrEmpty(_shopGoodsItemInfo.ShopGoodsData.pic))
            {
                itemIconSpritePath = ResPath.GetShopItemIconPath(_shopGoodsItemInfo.ShopGoodsData.pic);
            }
            else
            {
                if (goodsGameResData.type == Logic.Enums.BaseResType.Item)
                {
                    ItemData itemData = ItemData.GetItemDataByID(goodsGameResData.id);
                    itemIconSpritePath = ResPath.GetItemIconPath(itemData.icon);
                }
                else if (goodsGameResData.type == Logic.Enums.BaseResType.Hero)
                {
                    HeroData heroData = HeroData.GetHeroDataByID(goodsGameResData.id);
                    itemIconSpritePath = ResPath.GetCharacterHeadIconPath(heroData.headIcons[heroData.starMin - 1]);
                }
            }
            itemIconImage.SetSprite(ResMgr.instance.Load <Sprite>(itemIconSpritePath));
            itemIconImage.SetNativeSize();

            costResourceIcon.SetSprite(ResMgr.instance.Load <Sprite>(UIUtil.GetBaseResIconPath(_shopGoodsItemInfo.ShopGoodsData.costGameResData.type)));
            costResourceIcon.SetNativeSize();
            costResourceCountText.text = _shopGoodsItemInfo.ShopGoodsData.costGameResData.count.ToString();

            freeTimesRoot.SetActive(false);
            freeCountDownSlider.gameObject.SetActive(false);

            if (_shopGoodsItemInfo.ShopGoodsData.itemNum > 0)
            {
                if (_shopGoodsItemInfo.RemainPurchaseTimes > 0)
                {
                    buyButton.gameObject.SetActive(true);
                    soldOutButton.gameObject.SetActive(false);
                }
                else
                {
                    buyButton.gameObject.SetActive(false);
                    soldOutButton.gameObject.SetActive(true);
                }
                limitTimesText.text = string.Format(Localization.Get("common.value/max"), _shopGoodsItemInfo.RemainPurchaseTimes, _shopGoodsItemInfo.ShopGoodsData.itemNum);
                limitTimesRoot.SetActive(true);
            }
            else
            {
                limitTimesRoot.SetActive(false);
                buyButton.gameObject.SetActive(true);
                soldOutButton.gameObject.SetActive(false);
            }
        }