Exemplo n.º 1
0
        /// <summary>
        /// Sets component data with specified item.
        /// </summary>
        /// <param name="newItem">Item.</param>
        public virtual void SetData(UBuddySessionListItem newItem)
        {
            item = newItem;

            if (item == null)
            {
                return;
            }

            SNSDataManager.BuddyInfo buddy = LogicDataCenter.snsDataManager.getBuddyInfoByUserID(newItem.UserID);

            HeadIcon.sprite    = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_PlayerHead, WndID.WND_ID_SNS_CHAT, 1, buddy.Info.nSex + 1);
            GameStateDesc.text = LogicDataCenter.snsDataManager.getBuddyStatusDesc(buddy);
            Name.text          = getBuddyName(buddy);

            if (buddy.Info.nStatus == (int)ACTOR_GAME_STATE.GAME_STATE_OFFLINE)
            {
                GameStateIcon.gameObject.SetActive(false);
                HeadIcon.AddNewMaterial(EUIShaderType.EST_Gray);
                Name.color          = Color.gray;
                GameStateDesc.color = Color.gray;
            }
            else
            {
                HeadIcon.ResetToDefaultMaterial();
                GameStateIcon.gameObject.SetActive(true);
                GameStateIcon.sprite = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_GameState, WndID.WND_ID_SNS_MAINPANEL,
                                                                         UDefines.GetGameStateIconID(buddy.Info.nStatus));
                Name.color          = Color.white;
                GameStateDesc.color = Color.white;
            }

            SelectedBg.gameObject.SetActive(item.isCurSession);
        }
Exemplo n.º 2
0
            public override void initContent()
            {
                base.initContent();

                SNSDataManager.BuddyInfo buddyInfo = LogicDataCenter.snsDataManager.getBuddyInfoByUserID(m_Component.Item.nUserID);

                m_Component.BuddyName.text = buddyInfo.Info.szName;
            }
        /// <summary>
        /// Updates the view.
        /// </summary>
        protected virtual void UpdateView()
        {
            if (ItemDepth > 0)  // 显示好友
            {
                GroupTrans.gameObject.SetActive(false);
                PlayerTrans.gameObject.SetActive(true);

                if (item.nGroupID == (int)InvitePlayGame.InvitePlayGameGroup.emBuddyGroup ||
                    item.nGroupID == (int)InvitePlayGame.InvitePlayGameGroup.emNearbyGroup)
                {
                    SNSDataManager.BuddyInfo buddyInfo = LogicDataCenter.snsDataManager.getBuddyInfoByUserID(Item.nUserID);
                    ActorName.text = getBuddyName(buddyInfo);
                }
                else
                {
                    ActorName.text = item.Name;
                }

                HeadImage.sprite = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_PlayerHead, WndID.WND_ID_INVITEPLAYGAME, 1, 1); // 设置头像
                SexImage.sprite  = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_SNS, "Sex_" + item.nSex, WndID.WND_ID_INVITEPLAYGAME);
                RankName.text    = Item.RankName;

                // 游戏状态图标
                int nStateIconID = UDefines.GetGameStateIconID(item.nGameState);
                StateIcon.sprite = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_GameState, WndID.WND_ID_INVITEPLAYGAME, nStateIconID);

                // 当前游戏状态描述
                if (item.isInvited)
                {
                    StateDesc.text = ULocalizationService.Instance.Get("UIView", "GameWaitingRoom", "AlreadyInivtedDesc");
                }
                else
                {
                    string GameStateDesc  = UDefines.GetGameStateDesc(item.nGameState);
                    string GameStateColor = UDefines.GetGameStateColor(item.nGameState);
                    StateDesc.text = String.Format("<color=#{0}>{1}</color>", GameStateColor, ULocalizationService.Instance.Get("UIView", "Common", GameStateDesc));
                }

                CheckMarkImage.SetActive(item.isSelected);

                if (item.isCanInvite)
                {
                    CheckMarkBg.SetActive(true);
                }
                else
                {
                    CheckMarkBg.SetActive(false);
                }
            }
            else   // 显示分组
            {
                Text.text = Item.Name;
                GroupTrans.gameObject.SetActive(true);
                PlayerTrans.gameObject.SetActive(false);
            }
        }
Exemplo n.º 4
0
        protected string getBuddyName(SNSDataManager.BuddyInfo buddyInfo)
        {
            string remark = LogicDataCenter.snsDataManager.getBuddyRemark(buddyInfo.Info.nUserID);

            if (String.IsNullOrEmpty(remark))
            {
                return(buddyInfo.Info.szName);
            }
            else
            {
                return(string.Format("{0}({1})", remark, buddyInfo.Info.szName));
            }
        }
Exemplo n.º 5
0
        private string getBuddyName(SNSDataManager.BuddyInfo buddyInfo)
        {
            string remark = LogicDataCenter.snsDataManager.getBuddyRemark(buddyInfo.Info.nUserID);

            remark = remark == null ? "" : remark;

            if (remark.Length == 0)
            {
                return(buddyInfo.Info.szName);
            }
            else
            {
                return(string.Format("{0}({1})", remark, buddyInfo.Info.szName));
            }
        }
Exemplo n.º 6
0
            public virtual void initContent()
            {
                SNSDataManager.BuddyInfo buddyInfo = LogicDataCenter.snsDataManager.getBuddyInfoByUserID(m_Component.Item.nUserID);

                m_Component.BuddyInfoTrans.gameObject.SetActive(true);
                m_Component.BuddyGroupTrans.gameObject.SetActive(false);

                m_Component.Icon.sprite          = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_PlayerHead, WndID.WND_ID_SNS_MAINPANEL, 1, buddyInfo.Info.nSex + 1); // 设置头像
                m_Component.SexIcon.sprite       = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_SNS, "Sex_" + buddyInfo.Info.nSex, WndID.WND_ID_SNS_MAINPANEL);
                m_Component.RankIcon.sprite      = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_RankImage, WndID.WND_ID_SNS_MAINPANEL, 2, buddyInfo.Info.nRankIconID);
                m_Component.BuddyName.text       = getBuddyName(buddyInfo);
                m_Component.GameStateDesc.text   = LogicDataCenter.snsDataManager.getBuddyStatusDesc(buddyInfo);
                m_Component.GameStateIcon.sprite = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_GameState, WndID.WND_ID_SNS_MAINPANEL,
                                                                                     UDefines.GetGameStateIconID(buddyInfo.Info.nStatus));
                m_Component.RankName.text = buddyInfo.Info.szRankName;
                m_Component.Mood.text     = buddyInfo.Info.szMood;

                if (buddyInfo.Info.nStatus == (int)ACTOR_GAME_STATE.GAME_STATE_OFFLINE)
                {
                    Color gray = new Color(118f / 255f, 120f / 255f, 123f / 255f);
                    m_Component.Icon.AddNewMaterial(EUIShaderType.EST_Gray);
                    m_Component.SexIcon.AddNewMaterial(EUIShaderType.EST_Gray);
                    m_Component.RankIcon.AddNewMaterial(EUIShaderType.EST_Gray);
                    m_Component.BuddyName.color     = gray;
                    m_Component.GameStateDesc.color = gray;
                    m_Component.RankName.color      = gray;

                    m_Component.GameStateIcon.gameObject.SetActive(false);
                }
                else
                {
                    m_Component.Icon.ResetToDefaultMaterial();
                    m_Component.RankIcon.ResetToDefaultMaterial();
                    m_Component.SexIcon.ResetToDefaultMaterial();
                    m_Component.BuddyName.color = BuddyNameColor;
                    m_Component.RankName.color  = Color.white;

                    m_Component.GameStateIcon.gameObject.SetActive(true);
                }

                setBuddyInfoTooltips(buddyInfo);
            }
Exemplo n.º 7
0
        public void SetData(SNSMsgContentItem data)
        {
            m_nMsgID = data.info.msg.dwMsgID;

            Transform curTrans = null;

            if (isSelf(data.info.msg.dwFromAccountID))
            {
                curTrans = rightTrans;
                leftTrans.gameObject.SetActive(false);
                rightTrans.gameObject.SetActive(true);
            }
            else
            {
                curTrans = leftTrans;
                leftTrans.gameObject.SetActive(true);
                rightTrans.gameObject.SetActive(false);
            }

            Transform timeTrans = curTrans.FindChild("Time");

            if (timeTrans == null)
            {
                return;
            }

            Transform bubbleTrans = curTrans.FindChild("Bubble");

            if (bubbleTrans == null)
            {
                return;
            }

            Transform contentTrans = curTrans.FindChild("Bubble/Content");

            if (contentTrans == null)
            {
                return;
            }

            Image avatar = curTrans.FindChild("Avatar").GetComponent <Image>();

            if (avatar == null)
            {
                return;
            }

            SNSDataManager.BuddyInfo buddy = LogicDataCenter.snsDataManager.getBuddyInfoByUserID(data.info.msg.dwFromAccountID);

            // 设置头像
            avatar.sprite = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_PlayerHead, WndID.WND_ID_SNS_MAINPANEL, 1, buddy.Info.nSex + 1);


            timeTrans.GetComponent <Text>().text = Api.convertTimeStamp2DateTime(data.info.msg.dwTime).ToString("yyyy-MM-dd HH:mm");

            // 设置content的最大宽度
            RectTransform contentRect = contentTrans as RectTransform;

            contentRect.sizeDelta = new Vector2(MaxWidth, contentRect.sizeDelta.y);
            //contentRect.anchoredPosition = new Vector2(contentRect.anchoredPosition.x, 0);

            float           contentHeight = 0;
            ChatContentItem item          = contentTrans.GetComponent <ChatContentItem>();

            if (item != null)
            {
                ChatContentItemData itemData = new ChatContentItemData();
                itemData.objList = data.info.objList;
                item.SetData(itemData);

                contentHeight = item.Height;
            }
            else
            {
                Debug.LogError("item == null, This GameObject have no ChatContentItem component.");
            }

            // 设置内容的大小
            float contentWidth = contentRect.sizeDelta.x;

            contentRect.sizeDelta = new Vector2(contentWidth, contentHeight);

            // 气泡与内容之间的边缘大小
            Vector2 Margin;

            Margin.x = Math.Abs(contentRect.anchoredPosition.x);
            Margin.y = Math.Abs(contentRect.anchoredPosition.y);

            // 计算气泡的大小
            RectTransform bubbleRect = bubbleTrans as RectTransform;

            bubbleRect.sizeDelta = new Vector2(contentWidth + Margin.x * 2, contentHeight + Margin.y * 2);
            float bubbleHeight = bubbleRect.sizeDelta.y;


            // 设置时间的坐标(时间显示在聊天内容下面),坐标为负数
            float         timePosY = bubbleRect.anchoredPosition.y + (-bubbleHeight);
            RectTransform timeRect = timeTrans as RectTransform;

            timeRect.anchoredPosition = new Vector2(timeRect.anchoredPosition.x, timePosY);

            // 计算总高度
            m_Height = Math.Abs(bubbleRect.anchoredPosition.y) + bubbleHeight + TimeHeight + MarginY;
            if (m_Height < MinHeight)
            {
                m_Height = MinHeight;
            }

            // 设置总高度
            RectTransform rect2 = curTrans as RectTransform;

            rect2.sizeDelta = new Vector2(rect2.sizeDelta.x, m_Height);

            // 设置DefautItem高度
            RectTransform rect3 = transform as RectTransform;

            rect3.sizeDelta = new Vector2(rect3.sizeDelta.x, m_Height);

            m_Height = 0;
        }