少年修仙传客户端代码仓库
client_linchunjie
2018-09-12 bbd61c2b8046be61819be325a3bc892c683e4eda
1913【前端】【主干】语音无法自动播放
3个文件已修改
69 ■■■■ 已修改文件
System/Chat/ChatCenter.cs 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatCtrl.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/SystemSetting/ChatSetting.cs 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatCenter.cs
@@ -148,7 +148,6 @@
            m_VoiceChatDict.Clear();
            autoPlayVoices.Clear();
            voicePlaying = false;
            netState = 0;
        }
        public void OnSwitchAccount()
@@ -346,12 +345,6 @@
                           }
                           var bytes = Convert.FromBase64String(speech.content);
                           SaveSpeech(_player, tick, bytes);
                           if (autoPlayVoices.Count > 0
                           && autoPlayVoices[0].playerId == _player
                           && autoPlayVoices[0].tick == tick)
                           {
                               AutoPlayVoice();
                           }
                       }
                       catch (Exception e)
                       {
@@ -404,12 +397,20 @@
                dict = new Dictionary<long, AudioClip>();
                speechDict.Add(_decodec.playerId, dict);
            }
            if (dict.ContainsKey(_decodec.tick))
            {
                return;
            }
            var clip = AudioClip.Create("Sound", _decodec.samples.Length, 1, VoiceSettings.frequency, false);
            clip.SetData(_decodec.samples, 0);
            dict.Add(_decodec.tick, clip);
            if (_decodec.playerId == cachePlayerId && cacheTick == _decodec.tick)
            {
                PlaySpeech(clip, cacheLength);
            }
            else if (autoPlayVoices.Count > 0)
            {
                AutoPlayVoice();
            }
            if (speechDownloadSuccess != null)
            {
@@ -520,12 +521,9 @@
            return ChatInfoType.World;
        }
        int netState = 0;
        private void OnNetStatusChanged(NetworkReachability _state)
        {
            netState = (int)_state;
            if (netState != 1 && netState != 4)
            if ((int)SDKUtility.Instance.NetworkType == 0)
            {
                autoPlayVoices.Clear();
            }
@@ -536,9 +534,9 @@
        public void CheckAutoPlayVoice(ChatData _chat)
        {
            var _netState = netState;
            var netType = (int)SDKUtility.Instance.NetworkType;
#if UNITY_EDITOR
            _netState = 1;
            netType = 2;
#endif
            if (!serverInited)
            {
@@ -557,7 +555,7 @@
            {
                return;
            }
            if (!ChatSetting.Instance.GetAutoPlayVoice(_chat.type, _netState))
            if (!ChatSetting.Instance.GetAutoPlayVoice(_chat.type, netType))
            {
                return;
            }
@@ -626,7 +624,7 @@
                case ChatBoolType.GradVoice4G:
                case ChatBoolType.GradVoiceWifi:
                    if (!ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Fairy, 1)
                        && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Fairy, 4))
                        && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Fairy, 2))
                    {
                        RemoveAutoVoice(ChatInfoType.Fairy);
                    }
@@ -634,7 +632,7 @@
                case ChatBoolType.PrivatChatVoice4G:
                case ChatBoolType.PrivateChatVoiceWifi:
                    if (!ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Friend, 1)
                        && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Friend, 4))
                        && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Friend, 2))
                    {
                        RemoveAutoVoice(ChatInfoType.Friend);
                    }
@@ -642,7 +640,7 @@
                case ChatBoolType.TeamVoice4G:
                case ChatBoolType.TeamVoiceWifi:
                    if (!ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Team, 1)
                       && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Team, 4))
                       && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Team, 2))
                    {
                        RemoveAutoVoice(ChatInfoType.Team);
                    }
@@ -650,7 +648,7 @@
                case ChatBoolType.WorldVoice4G:
                case ChatBoolType.WorldVoiceWifi:
                    if (!ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.World, 1)
                       && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.World, 4))
                       && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.World, 2))
                    {
                        RemoveAutoVoice(ChatInfoType.World);
                    }
@@ -658,7 +656,7 @@
                case ChatBoolType.AreaVoiceWifi:
                case ChatBoolType.AreaVoice4G:
                    if (!ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Area, 1)
                       && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Area, 4))
                       && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Area, 2))
                    {
                        RemoveAutoVoice(ChatInfoType.Area);
                    }
System/Chat/ChatCtrl.cs
@@ -447,6 +447,10 @@
                OnRefreshSelf(chatData);
            }
        }
        if (chatData.IsSound)
        {
            chatCenter.CheckAutoPlayVoice(chatData);
        }
    }
    private void AddPteChat(ChatFriendData chatData)
    {
System/SystemSetting/ChatSetting.cs
@@ -112,58 +112,57 @@
    public bool GetAutoPlayVoice(ChatInfoType type, int netState)
    {
        if (netState == 0)
        {
            return false;
        }
        switch (type)
        {
            case ChatInfoType.World:
                if (netState == 1)
                if (netState == 2)
                {
                    return GetBool(ChatBoolType.WorldVoiceWifi);
                }
                else if (netState == 4)
                else
                {
                    return GetBool(ChatBoolType.WorldVoice4G);
                }
                break;
            case ChatInfoType.Area:
                if (netState == 1)
                if (netState == 2)
                {
                    return GetBool(ChatBoolType.AreaVoiceWifi);
                }
                else if (netState == 4)
                else
                {
                    return GetBool(ChatBoolType.AreaVoice4G);
                }
                break;
            case ChatInfoType.Team:
                if (netState == 1)
                if (netState == 2)
                {
                    return GetBool(ChatBoolType.TeamVoiceWifi);
                }
                else if (netState == 4)
                else
                {
                    return GetBool(ChatBoolType.TeamVoice4G);
                }
                break;
            case ChatInfoType.Fairy:
                if (netState == 1)
                if (netState == 2)
                {
                    return GetBool(ChatBoolType.GradVoiceWifi);
                }
                else if (netState == 4)
                else
                {
                    return GetBool(ChatBoolType.GradVoice4G);
                }
                break;
            case ChatInfoType.Friend:
                if (netState == 1)
                if (netState == 2)
                {
                    return GetBool(ChatBoolType.PrivateChatVoiceWifi);
                }
                else if (netState == 4)
                else
                {
                    return GetBool(ChatBoolType.PrivatChatVoice4G);
                }
                break;
        }
        return false;
    }