Пример #1
0
        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();
                }
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
        public void SetEmoji(string emoji)
        {
            Sprite sprite = null;

            if (EmojiList != null)
            {
                for (int i = 0; i < EmojiList.Count; i++)
                {
                    var e = EmojiList[i];
                    if (e.name == emoji)
                    {
                        sprite = e;
                        break;
                    }
                }
            }

            if (sprite)
            {
                if (Text.gameObject.activeSelf)
                {
                    Text.gameObject.SetActive(false);
                }

                Image.SetSprite(sprite, true);
            }
            else
            {
                if (!Text.gameObject.activeSelf)
                {
                    Text.gameObject.SetActive(true);
                }

                Text.text = emoji;

                if (Image.gameObject.activeSelf)
                {
                    Image.gameObject.SetActive(false);
                }
            }
        }