예제 #1
0
        public RectTransform GetCustomMessageCellViewNode(FizzChannelMessage message)
        {
            if (message.Data != null)
            {
                if (message.Data.ContainsKey("type") && message.Data["type"].Equals("fizz_predefine_phrase"))
                {
                    string id = message.Data["phrase_id"];
                    FizzHypercasualPhraseDataItem phraseData = dataProvider.GetPhrase(id);
                    if (phraseData != null)
                    {
                        FizzCustomPhraseView phraseView = Instantiate(PhrasePrefab);
                        phraseView.gameObject.SetActive(true);
                        phraseView.SetPhrase(phraseData.GetLocalizedContent(Application.systemLanguage));

                        // Theme color change
                        phraseView.GetComponent <ThemeLabelColor>().SetColor((message.From.Equals(FizzService.Instance.UserId)? ThemeColor.Base_2 : ThemeColor.Base_1));

                        return(phraseView.GetComponent <RectTransform> ());
                    }
                }
                else if (message.Data.ContainsKey("type") && message.Data["type"].Equals("fizz_predefine_sticker"))
                {
                    string id = message.Data["sticker_id"];
                    FizzHypercasualStickerDataItem stickerData = dataProvider.GetSticker(id);
                    if (stickerData != null)
                    {
                        FizzCustomStickerView sticker = Instantiate(StickerPrefab);
                        sticker.gameObject.SetActive(true);
                        sticker.SetSticker(stickerData.Content);
                        return(sticker.GetComponent <RectTransform> ());
                    }
                }
            }
            return(null);
        }
        private void LoadStickers(bool loadRecent = false)
        {
            ReturnStickerViewToPool();
            if (!loadRecent && selectedTab == null)
            {
                return;
            }
            List <string> stickers = loadRecent ? dataProvider.GetRecentStickers() : dataProvider.GetAllStickers(selectedTab.Tag);

            if (stickers.Count == 0)
            {
                return;
            }

            foreach (string id in stickers)
            {
                FizzHypercasualDataItem stickerItem = dataProvider.GetSticker(id);
                if (stickerItem == null)
                {
                    continue;
                }

                FizzHypercasualStickerView stickerView = GetStickerViewFromPool();
                stickerView.gameObject.SetActive(true);
                stickerView.transform.SetParent(StickersContainer, false);
                stickerView.transform.localScale = Vector3.one;
                stickerView.SetStickerData(stickerItem);
                stickerView.OnStickerClick = OnStickerClicked;
            }
        }