Ejemplo n.º 1
0
        public void SetHeadIcon(GameImage head_icon, GameNetworkRawImage head_tex, string icon_url_, long player_id_)
        {
            if (CommonTools.IsNeedDownloadIcon(icon_url_))
            {
                head_icon.Visible = false;
                head_tex.Visible  = true;

                if (FriendDataManager.Instance.Friend_icons_dict.ContainsKey(player_id_))
                {
                    FriendIcon f_icon = FriendDataManager.Instance.Friend_icons_dict[player_id_];
                    if (f_icon.Url != icon_url_)
                    {
                        head_tex.OnLoadFinish = (tex_) => { f_icon.Url = icon_url_; f_icon.m_tex = tex_; };
                        head_tex.TextureName  = icon_url_;
                    }
                    else
                    {
                        head_tex.SetTexture(f_icon.m_tex);
                    }
                }
                else
                {
                    head_tex.OnLoadFinish = (tex_) =>
                    {
                        FriendIcon f_icon = new FriendIcon();
                        f_icon.Url   = icon_url_;
                        f_icon.m_tex = tex_;
                        FriendDataManager.Instance.Friend_icons_dict.Add(player_id_, f_icon);
                    };
                    head_tex.TextureName = icon_url_;
                }
            }
            else
            {
                head_icon.Visible = true;
                head_tex.Visible  = false;
                head_icon.Sprite  = CommonData.GetSize3HEADByDefault(icon_url_);
            }
        }
Ejemplo n.º 2
0
        public void Refresh(PlayerFriendMsg info_, IEnumerable <AchievementFriendMsg> achievements_)
        {
            ConfTitle my_title = ConfTitle.Get(info_.TitleId);
            string    temp_str = null != my_title?LocalizeModule.Instance.GetString(my_title.name) : "";

            m_rank_text.Text = $"{title_str}: {temp_str}";

            m_name_text.Text = info_.Name;
            m_lvl_text.Text  = LocalizeModule.Instance.GetString("UI_start_1.lvl", info_.Level);

            if (CommonTools.IsNeedDownloadIcon(info_.Icon))
            {
                if (FriendDataManager.Instance.Friend_icons_dict.ContainsKey(info_.PlayerId))
                {
                    FriendIcon f_icon = FriendDataManager.Instance.Friend_icons_dict[info_.PlayerId];
                    if (f_icon.Url != info_.Icon)
                    {
                        m_head_tex.OnLoadFinish = (tex_) => { f_icon.Url = info_.Icon; f_icon.m_tex = tex_; };
                        m_head_tex.TextureName  = info_.Icon;
                    }
                    else
                    {
                        m_head_tex.SetTexture(f_icon.m_tex);
                    }
                }
                else
                {
                    m_head_tex.OnLoadFinish = (tex_) =>
                    {
                        FriendIcon f_icon = new FriendIcon();
                        f_icon.Url   = info_.Icon;
                        f_icon.m_tex = tex_;
                        FriendDataManager.Instance.Friend_icons_dict.Add(info_.PlayerId, f_icon);
                    };
                    m_head_tex.TextureName = info_.Icon;
                }
            }
            else
            {
                m_head_tex.TextureName = CommonData.GetBigPortrait(info_.Icon);
            }

            m_player_id_text.Text = $"{id_str}: {info_.PlayerId.ToString()}";

            List <AchievementFriendMsg> msgs = new List <AchievementFriendMsg>(achievements_);

            m_achievement_grid.Clear();

            if (msgs.Count > 0)
            {
                List <AchievementFriendMsg> filtered_msgs = msgs.FindAll((item) =>
                {
                    return((item.SubmitStatus & (1 << 1)) > 0 || (item.SubmitStatus & (1 << 2)) > 0 || (item.SubmitStatus & (1 << 3)) > 0);
                });

                if (filtered_msgs.Count > 4)
                {
                    filtered_msgs = filtered_msgs.GetRange(0, 4);
                }

                if (filtered_msgs.Count > 0)
                {
                    m_achievement_grid.EnsureSize <PlayerAchievementComponent>(filtered_msgs.Count);

                    for (int i = 0; i < m_achievement_grid.ChildCount; ++i)
                    {
                        ConfAchievement            confAchieve = ConfAchievement.Get(filtered_msgs[i].Id);
                        PlayerAchievementComponent item        = m_achievement_grid.GetChild <PlayerAchievementComponent>(i);

                        if (confAchieve != null)
                        {
                            string reward_icon = string.Empty;
                            long   finish_time = 0L;
                            if ((filtered_msgs[i].SubmitStatus & (1 << 3)) > 0)
                            {
                                reward_icon = confAchieve.rewardicon3;
                                finish_time = filtered_msgs[i].FinishTime;
                            }
                            else if ((filtered_msgs[i].SubmitStatus & (1 << 2)) > 0)
                            {
                                reward_icon = confAchieve.rewardicon2;
                                finish_time = filtered_msgs[i].FinishTime2;
                            }
                            else if ((filtered_msgs[i].SubmitStatus & (1 << 1)) > 0)
                            {
                                reward_icon = confAchieve.rewardicon1;
                                finish_time = filtered_msgs[i].FinishTime1;
                            }

                            item.SetData(reward_icon, confAchieve.name, finish_time);
                        }

                        item.Visible = true;
                    }
                }
            }
        }