Exemplo n.º 1
0
 public void VoiceRecordMainWnd(bool _isPress, ChatInfo.Type _type, string name = null)
 {
     //Debug.Log("VoiceRecordMainWnd :  " + _isPress);
     if (_isPress)
     {
         SetIsRcordingVoice(true);
         YvVoiceSdk.YvVoiceRecordVoice();
         recordTime = Time.time;
     }
     else
     {
         SetIsRcordingVoice(false);
         float overTime = Time.time - recordTime;
         if (OnShowSendVoiceUpdate != null)
         {
             OnShowSendVoiceUpdate(true);
         }
         YvVoiceSdk.YvVoiceStopRecordVoice((data1, data2) =>
         {
             string st = "[Voice]=[Voice]=" + data1 + "=[Voice]=" + data2 + "=[Voice]=" + (overTime);
             if (!string.IsNullOrEmpty(name))
             {
                 GameCenter.chatMng.SendChatContent(st, (int)_type, name);
             }
             else
             {
                 GameCenter.chatMng.SendChatContent(st, (int)_type);
             }
             if (OnShowSendVoiceUpdate != null)
             {
                 OnShowSendVoiceUpdate(false);
             }
         });
     }
 }
Exemplo n.º 2
0
 public VoiceData(string _privateName)
 {
     type = ChatInfo.Type.Private;
     if (_privateName != null)
     {
         privateName = _privateName;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 获取当前玩家的未读聊天数目
 /// </summary>
 public int GetChatNumIsNotRead(ChatInfo.Type _type)
 {
     if (chatNumDic.ContainsKey(_type))
     {
         return(chatNumDic[_type]);
     }
     return(0);
 }
Exemplo n.º 4
0
 void ResetData()
 {
     allChatInfo.Clear();
     chatInfoDic.Clear();
     PrivateChatDic.Clear();
     PrivateChatNewNum.Clear();
     AllPrivateChatNewNum = 0;
     bgmValue             = 0;
     soundEffectValue     = 0;
     chatNumDic.Clear();
     CurTargetName = string.Empty;
     curChatType   = ChatInfo.Type.World;
     ClearVoiceCach();
 }
Exemplo n.º 5
0
 /// <summary>
 /// 获取保存的聊天内容
 /// </summary>
 public void GetSavedContent()
 {
     if (PlayerPrefs.HasKey(SAVED_CHAT))
     {
         string   saved   = PlayerPrefs.GetString(SAVED_CHAT);
         string[] content = saved.Split('/');
         if (content.Length > 0)
         {
             savedChatType = (ChatInfo.Type)(int.Parse(content[0]));
         }
         if (content.Length > 1)
         {
             savedChat = content[1];
         }
     }
     else
     {
         SaveContent();
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// 更新每个聊天类型新增加的聊天数目(_operaterType=1加新消息,2,清空,玩家在选择这个选项时清空)
 /// </summary>
 protected void SetchatNumDic(ChatInfo.Type _type, int _operaterType)
 {
     if (!chatNumDic.ContainsKey(_type))
     {
         chatNumDic.Add(_type, 0);
     }
     if (_operaterType == 1)
     {
         chatNumDic[_type]++;
     }
     else if (_operaterType == 2)
     {
         chatNumDic[_type] = 0;
         if (_type == ChatInfo.Type.All)
         {
             if (chatNumDic.ContainsKey(ChatInfo.Type.Team))
             {
                 chatNumDic[ChatInfo.Type.Team] = 0;
             }
             if (chatNumDic.ContainsKey(ChatInfo.Type.Guild))
             {
                 chatNumDic[ChatInfo.Type.Guild] = 0;
             }
         }
         if (_type == ChatInfo.Type.World)//系统的消息在世界里面,所以在世界里清空
         {
             if (chatNumDic.ContainsKey(ChatInfo.Type.System))
             {
                 chatNumDic[ChatInfo.Type.System] = 0;
             }
         }
     }
     if (ChatNumChangeEvent != null)
     {
         ChatNumChangeEvent();
     }
 }
Exemplo n.º 7
0
 public VoiceData(ChatInfo.Type _type)
 {
     type = _type;
 }
Exemplo n.º 8
0
 /// <summary>
 /// 发送指定聊天类型的信息
 /// </summary>
 /// <param name="_type"></param>
 /// <param name="_content"></param>
 public void SendMsgByType(ChatInfo.Type _type, string _content, string _targetName = "")
 {
     // Debug.Log("发送的消息为:" + _content);
     SendChatContent(_content, (int)_type, _targetName);
 }
Exemplo n.º 9
0
 /// <summary>
 /// 复原保存内容
 /// </summary>
 public void RecoverSavedContent()
 {
     savedChatType = ChatInfo.Type.All;
     savedChat     = string.Empty;
 }
Exemplo n.º 10
0
    ///// <summary>
    ///// 设置语音是否自动播放
    ///// </summary>
    ///// <param name="_type"></param>
    ///// <param name="_isSelect"></param>
    //public void SetChatTypeVoiceSelfPlaying(ChatInfo.Type _type, bool _isSelect)
    //{
    //    string type = _type.ToString();
    //    PlayerPrefs.SetInt(type, _isSelect ? 1 : 0);
    //    if (!_isSelect)
    //    {
    //        ClearVoiceListAlongSelfSet(_type);
    //    }
    //}

    /// <summary>
    /// 获得语音自动播放设置
    /// </summary>
    /// <param name="_type"></param>
    /// <returns></returns>
    //public bool GetChatTypeVoiceSelfPlaying(ChatInfo.Type _type)
    //{
    //    string type = _type.ToString();
    //    //   Debug.Log(PlayerPrefs.HasKey(type) + ":" + YvVoiceSdk.IsWifiNetWork() + ":" + type);
    //    if (PlayerPrefs.HasKey(type) && YvVoiceSdk.IsWifiNetWork())
    //    {
    //        return PlayerPrefs.GetInt(type) == 1;
    //    }
    //    else
    //    {
    //        PlayerPrefs.SetInt(type, YvVoiceSdk.IsWifiNetWork() ? 1 : 0);
    //        return PlayerPrefs.GetInt(type) == 1;
    //    }

    //}

    /// <summary>
    /// 设置自动播放时的语音数据清理
    /// </summary>
    protected void ClearVoiceListAlongSelfSet(ChatInfo.Type _type)
    {
        voiceList.RemoveAll((ChatInfo temp) => temp.chatTypeID == (int)_type);
    }
Exemplo n.º 11
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);
        //}
    }