Ejemplo n.º 1
0
    /// <summary>
    /// 实例化聊天内容UI
    /// </summary>
    protected ChatContentUI InstantiateChatContentUI(int _type)
    {
        if (_type == 1)
        {
            if (comChatContentUI != null)
            {
                ChatContentUI obj          = Instantiate(comChatContentUI) as ChatContentUI;
                Transform     parentTransf = chatContentUIParent.transform;
                obj.transform.parent        = parentTransf;
                obj.transform.localScale    = Vector3.one;
                obj.transform.localPosition = Vector3.zero;
                obj.gameObject.SetActive(true);
                return(obj);
            }
        }
        if (_type == 5)
        {
            if (storyChatContentUI != null)
            {
                ChatContentUI obj          = Instantiate(storyChatContentUI) as ChatContentUI;
                Transform     parentTransf = chatContentUIParent.transform;
                obj.transform.parent        = parentTransf;
                obj.transform.localScale    = Vector3.one;
                obj.transform.localPosition = Vector3.zero;

                obj.gameObject.SetActive(true);
                return(obj);
            }
        }
        if (_type == 4)
        {
            if (friendChatContentUI != null)
            {
                ChatContentUI obj          = Instantiate(friendChatContentUI) as ChatContentUI;
                Transform     parentTransf = chatContentUIParent.transform;
                obj.transform.parent        = parentTransf;
                obj.transform.localScale    = Vector3.one;
                obj.transform.localPosition = Vector3.zero;

                obj.gameObject.SetActive(true);
                return(obj);
            }
        }
        if (_type == 2)
        {
            if (ownChatContentUI != null)
            {
                ChatContentUI obj          = Instantiate(ownChatContentUI) as ChatContentUI;
                Transform     parentTransf = chatContentUIParent.transform;
                obj.transform.parent        = parentTransf;
                obj.transform.localScale    = Vector3.one;
                obj.transform.localPosition = new Vector3(670, 0, 0);

                obj.gameObject.SetActive(true);
                return(obj);
            }
        }
        return(null);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 选择其他聊天类型更新聊天内容
    /// </summary>
    void SelectChatType(int _type)
    {
        if (toggle.Length > (int)GameCenter.chatMng.CurChatType)
        {
            toggle[(int)GameCenter.chatMng.CurChatType].value = true;
        }
        //Debug.Log("选择的聊天类型为" + (int)GameCenter.chatMng.CurChatType);
        HideAllChatContent();
        RefreshView(_type);
        List <ChatInfo> infoList = GameCenter.chatMng.GetInfoList(_type);

        if (_type == (int)ChatInfo.Type.Private)
        {
            infoList = GameCenter.chatMng.GetPrivateInfoList(GameCenter.chatMng.CurTargetName);
            RefreshPrivateWnd();
        }
        int chatCount = infoList.Count;
        int type      = 1;

        for (int i = 0; i < chatCount; i++)
        {
            type = 1;
            if (infoList[i] == null)
            {
                break;
            }
            switch (infoList[i].chatTypeID)
            {
            //case 5: type = 5; break;
            case 1:
            case 2:
            case 3:
                type = 5;
                if (infoList[i].isSystemInfo)
                {
                    type = 1;
                }
                break;

            case 4:
                if (infoList[i].isSystemInfo)
                {
                    type = 1;
                }
                if (infoList[i].senderID != GameCenter.mainPlayerMng.MainPlayerInfo.ServerInstanceID)
                {
                    type = 4;
                }
                else
                {
                    type = 2;
                }
                break;

            default:
                break;
            }
            if (i >= chatUIList.Count)
            {
                ChatContentUI chatUI = InstantiateChatContentUI(type);
                chatUIList.Add(chatUI);
            }
            if (type == 1)
            {
                if (infoList[i] != null)
                {
                    chatUIList[i].ShowContent(infoList[i]);
                }
            }
            else
            {
                chatUIList[i].ShowPrivateContent(infoList[i]);
            }
            chatUIList[i].gameObject.SetActive(i < chatCount);
            if (i > 0)
            {
                AddNewChatContentUI(i - 1);
            }
        }
        //   chatContentUIParent.Reposition();
        view.ResetPosition();
        if (view.shouldMoveVertically)
        {
            view.SetDragAmount(0.01f, 1.0f, false);
        }


        //BoxCollider box = chatContentUIParent.GetComponent<BoxCollider>();
        //if (box != null)
        //{
        //    box.enabled = infoList.Count >= 5;
        //    box.size = new Vector3(box.size.x, (float)83 * infoList.Count, box.size.z);
        //    box.center = new Vector3(box.center.x,-41.5f * (infoList.Count - 1), box.center.z);
        //}
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 有新的聊天记录更新聊天内容
    /// </summary>
    void ShowChatContent(ChatInfo _info)
    {
        ChatInfo.Type   curChatType = GameCenter.chatMng.CurChatType;
        List <ChatInfo> infoList    = GameCenter.chatMng.GetInfoList((int)curChatType);
        int             chatCount   = infoList.Count;
        int             type        = 1;

        if (chatUIList.Count < chatCount)
        {
            switch (_info.chatTypeID)
            {
            //case 5: type = 5; break;
            case 1:
            case 2:
            case 3:
            case 4:
                if (_info.senderID != GameCenter.mainPlayerMng.MainPlayerInfo.ServerInstanceID)
                {
                    type = 4;
                }
                else
                {
                    type = 2;
                }
                break;

            default:
                break;
            }
            ChatContentUI chatUI = InstantiateChatContentUI(type);
            if (type == 2 || type == 3 || type == 4)
            {
                chatUI.ShowPrivateContent(_info);
            }
            else
            {
                chatUI.ShowContent(_info);
            }
            chatUIList.Add(chatUI);
        }
        else
        {
            if (type != 4 && type != 3 && type != 2 && type != 1)
            {
                chatUIList[chatCount - 1].ShowContent(_info);//
            }
            else
            {
                chatUIList[chatCount - 1].ShowPrivateContent(_info);
            }
            chatUIList[chatCount - 1].gameObject.SetActive(true);
        }
        if (chatUIList.Count > 1)
        {
            AddNewChatContentUI(chatUIList.Count - 2);
        }
        //  chatContentUIParent.Reposition();
        view.ResetPosition();
        if (view.shouldMoveVertically)
        {
            view.SetDragAmount(0.01f, 1.0f, false);
        }

        //BoxCollider box = chatContentUIParent.GetComponent<BoxCollider>();
        //if (box != null)
        //{
        //    box.enabled = infoList.Count >= 5;
        //    box.size = new Vector3(box.size.x, (float)83 * infoList.Count, box.size.z);
        //    box.center = new Vector3(box.center.x, -41.5f * (infoList.Count - 1), box.center.z);
        //}
    }