Пример #1
0
    public UILabel mLabel;               //文本框

    /// <summary>
    /// 设置数据并显示
    /// </summary>
    /// <param name="data">聊天数据</param>
    /// <param name="pos">坐标,世界坐标</param>
    /// <param name="call">回调</param>
    public void SetData(SendReceiveGameChat data, Vector3 pos, eChatTextDirectionType dType)
    {
        //设置位置
        transform.position = pos;
        gameObject.SetActive(true);
        eGameChatContentType _type = (eGameChatContentType)data.chatType;

        if (_type == eGameChatContentType.Chat)//普通文字
        {
            mLabel.text = data.content;
        }
        else if (_type == eGameChatContentType.TexTVoice)//文字语音
        {
            List <ConfigDada> conList = ConfigManager.GetConfigs <TSTGameTxtChatConfig>();
            ConfigDada        conData = conList.Find(o => o.conIndex == data.faceIndex.ToString());
            if (conData == null)
            {
                return;
            }
            TSTGameTxtChatConfig con = conData as TSTGameTxtChatConfig;
            mLabel.text = con.name;

            string voice = data.sex == 1 ? con.soundNameman : con.soundNamewoman;
            SoundProcess.PlaySound("ChatSound/" + voice);
        }
        mBg.width = 20 + mLabel.width;//设置背景长度
        DelayRun(2, () =>
        {
            gameObject.SetActive(false);
        });
    }
Пример #2
0
    /// <summary>
    /// 添加一个表情
    /// </summary>
    /// <param name="pos">位置,世界坐标</param>
    /// <param name="_type">类型</param>
    /// <param name="data">数据</param>
    private void AddOneFace(Vector3 pos, eChatTextDirectionType _type, SendReceiveGameChat data)
    {
        int index = _type.GetHashCode();

        if (index >= 0 && index < mFaces.Length)
        {
            //List<ConfigDada> configs = ConfigManager.GetConfigs<GameFaceConfig>();
            //ConfigDada conData = configs.Find(o => o.conIndex == data.faceIndex);
            //if (conData != null)
            //{
            //    mFaces[index].transform.position = pos;
            //    GameFaceConfig con = conData as GameFaceConfig;
            //    mFaces[index].SetBegin(con.animSprite, con.startEnd[0], con.startEnd[con.startEnd.Length - 1], 2, 0.25f, false);
            //}
        }
    }
Пример #3
0
    /// <summary>
    /// 文字聊天,文字语音,语音,表情
    /// </summary>
    /// <param name="pos">位置,世界坐标</param>
    /// <param name="_type">类型</param>
    /// <param name="data">数据</param>
    public void AddOneChat(Vector3 pos, eChatTextDirectionType _type, SendReceiveGameChat data)
    {
        eGameChatContentType chatType = (eGameChatContentType)data.chatType;

        switch (chatType)
        {
        case eGameChatContentType.Chat:      //文字
        case eGameChatContentType.TexTVoice: //文字语音
            AddOneText(pos, _type, data);
            break;

        case eGameChatContentType.Face:    //表情
            AddOneFace(pos, _type, data);
            break;

        case eGameChatContentType.Voice:    //语音
            AddOneVoice(pos, _type, data);
            break;
        }
    }
Пример #4
0
    /// <summary>
    /// 添加一个文字聊天或文字语音
    /// </summary>
    /// <param name="pos">位置,世界坐标</param>
    /// <param name="_type">类型</param>
    /// <param name="data">数据</param>
    private void AddOneText(Vector3 pos, eChatTextDirectionType _type, SendReceiveGameChat data)
    {
        int index = (int)_type;
        GameTextChatShowItem item;

        if (mTextChat.ContainsKey(data.fromSeatId))
        {
            item = mTextChat[data.fromSeatId];
        }
        else
        {
            if (index < 0 || index >= mTextItems.Length)
            {
                return;
            }
            GameObject obj = NGUITools.AddChild(mTextRoot, mTextItems[index].gameObject);
            item = obj.GetComponent <GameTextChatShowItem>();
            mTextChat[data.fromSeatId] = item;
        }
        item.SetData(data, pos, _type);
    }
Пример #5
0
    /// <summary>
    /// 添加一个语音
    /// </summary>
    /// <param name="pos">位置,世界坐标</param>
    /// <param name="_type">类型</param>
    /// <param name="data">数据</param>
    private void AddOneVoice(Vector3 pos, eChatTextDirectionType _type, SendReceiveGameChat data)
    {
        bool ised = PlayerPrefs.GetInt("DDL_" + PlayerModel.Inst.UserInfo.userId) == 1 ? true : false;//等于1是勾选了,其他是未勾选

        if (!ised)
        {
            string ext = DateTime.Now.ToFileTime().ToString();
#if YYVOICE
            YunVaImSDK.instance.RecordStartPlayRequest("", data.content, ext, (data2) =>
            {
                if (data2.result == 0)
                {
                    SQDebug.Log("播放成功");
                }
                else
                {
                    SQDebug.Log("播放失败");
                }
            });
#endif
        }
        int        index = data.fromSeatId;
        GameObject obj;
        if (mVoiceDic.ContainsKey(index))
        {
            obj = mVoiceDic[index];
        }
        else
        {
            obj = NGUITools.AddChild(mVoiceRoot, mVoiceItem);
            mVoiceDic[index] = obj;
        }
        obj.SetActive(true);
        obj.transform.position = pos;
        float t = data.voiceChatTime / 1000f;
        DelayRun(t, () =>
        {
            obj.SetActive(false);
        });
    }
Пример #6
0
 private void SetDirection(eChatTextDirectionType dType)
 {
     //设置背景和文字方向
 }