少年修仙传客户端代码仓库
client_linchunjie
2018-11-05 79668324bb457c6df754fd3d252628d1db6d14a9
4398 【1.2】聊天气泡框
13个文件已修改
4个文件已添加
274 ■■■■■ 已修改文件
Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/Model/ConfigManager.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/Model/Player/Character/PlayerBaseData.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/Model/Player/PlayerDatas.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatBubbleBehaviour.cs 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatBubbleModel.cs 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatBubbleModel.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatCenter.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatContentBehaviour.cs 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatData.cs 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatMineVoiceCell.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatOtherVoiceCell.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatPlayerMineCell.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatPlayerOtherCell.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/WindowBase/ModelCenter.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UI/Decorate/Graph/FlipImage.cs 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs
New file
@@ -0,0 +1,69 @@
//--------------------------------------------------------
//    [Author]:            第二世界
//    [  Date ]:           Friday, November 02, 2018
//--------------------------------------------------------
using UnityEngine;
using System;
namespace TableConfig {
    public partial class ChatBubbleBoxConfig : ConfigBase {
        public int ID { get ; private set ; }
        public string Name { get ; private set; }
        public int NeedLV { get ; private set ; }
        public int NeedVIPLVGift { get ; private set ; }
        public string leftBubbleIcon { get ; private set; }
        public string rightBubbleIcon { get ; private set; }
        public int[] leftOffset;
        public int[] rightOffset;
        public override string getKey()
        {
            return ID.ToString();
        }
        public override void Parse() {
            try
            {
                ID=IsNumeric(rawContents[0]) ? int.Parse(rawContents[0]):0;
                Name = rawContents[1].Trim();
                NeedLV=IsNumeric(rawContents[2]) ? int.Parse(rawContents[2]):0;
                NeedVIPLVGift=IsNumeric(rawContents[3]) ? int.Parse(rawContents[3]):0;
                leftBubbleIcon = rawContents[4].Trim();
                rightBubbleIcon = rawContents[5].Trim();
                string[] leftOffsetStringArray = rawContents[6].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries);
                leftOffset = new int[leftOffsetStringArray.Length];
                for (int i=0;i<leftOffsetStringArray.Length;i++)
                {
                     int.TryParse(leftOffsetStringArray[i],out leftOffset[i]);
                }
                string[] rightOffsetStringArray = rawContents[7].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries);
                rightOffset = new int[rightOffsetStringArray.Length];
                for (int i=0;i<rightOffsetStringArray.Length;i++)
                {
                     int.TryParse(rightOffsetStringArray[i],out rightOffset[i]);
                }
            }
            catch (Exception ex)
            {
                DebugEx.Log(ex);
            }
        }
    }
}
Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d3368c32387593943aae6e197d7cb78f
timeCreated: 1541148738
licenseType: Pro
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Core/GameEngine/Model/ConfigManager.cs
@@ -200,6 +200,7 @@
        AddAsyncTask<DailyQuestSpecialOpenTimeConfig>();
        AddAsyncTask<WHYJRewardConfig>();
        AddAsyncTask<TalentConfig>();
        AddAsyncTask<ChatBubbleBoxConfig>();
        while (!AllCompleted())
        {
            var completedCount = 0;
Core/GameEngine/Model/Player/Character/PlayerBaseData.cs
@@ -47,7 +47,7 @@
    public uint ExAttr7;    //扩展属性7,各项目专用
    public uint ExAttr8;    //扩展属性8,各项目专用
    public uint ExAttr9;    //扩展属性9,各项目专用
    public uint ExAttr10;    //扩展属性10,各项目专用
    public uint bubbleId;    //扩展属性10,各项目专用
    public uint ExAttr11;    //预留的扩展属性字段,用来存放项目特定的属性
    public uint ExAttr12;    //预留的扩展属性字段,用来存放项目特定的属性
    public uint ExAttr13;    //预留的扩展属性字段,用来存放项目特定的属性
@@ -117,7 +117,7 @@
        ExAttr7 = _serverInfo.ExAttr7;
        ExAttr8 = _serverInfo.ExAttr8;
        ExAttr9 = _serverInfo.ExAttr9;
        ExAttr10 = _serverInfo.ExAttr10;
        bubbleId = _serverInfo.ExAttr10;
        ExAttr11 = _serverInfo.ExAttr11;
        ExAttr12 = _serverInfo.ExAttr12;
        ExAttr13 = _serverInfo.ExAttr13;
Core/GameEngine/Model/Player/PlayerDatas.cs
@@ -546,7 +546,7 @@
                baseData.ExAttr9 = value;
                break;
            case PlayerDataRefresh.ExAttr10:
                baseData.ExAttr10 = value;
                baseData.bubbleId = value;
                break;
            case PlayerDataRefresh.ModelMark:
                break;
System/Chat/ChatBubbleBehaviour.cs
@@ -12,7 +12,13 @@
    {
        [SerializeField] Text m_Target;
        [SerializeField] RectOffset m_Padding;
        [SerializeField] FlipImage m_Flip;
        [SerializeField] Image m_BubbleIcon;
        [SerializeField] bool left = false;
        private int bubbleId = 0;
        ChatBubbleModel model { get { return ModelCenter.Instance.GetModel<ChatBubbleModel>(); } }
        RectTransform m_Rect;
        RectTransform rect
@@ -74,6 +80,26 @@
            Refresh();
        }
        public void DisplayBubble(int id)
        {
            bubbleId = id;
            ChatBubbleModel.ChatBubble bubble;
            if (model.TryGetBubble(id, out bubble))
            {
                var bubblePadding = left ? bubble.leftPadding : bubble.rifhtPadding;
                padding.top = bubblePadding.top;
                padding.left = bubblePadding.left;
                padding.right = bubblePadding.right;
                padding.bottom = bubblePadding.bottom;
                bool requireFlip = false;
                var iconKey = bubble.GetBubbleIcon(left, ref requireFlip);
                m_BubbleIcon.SetSprite(iconKey);
                m_Flip.flipHorizontal = requireFlip;
                Refresh();
            }
        }
        [ExecuteInEditMode]
        private void LateUpdate()
        {
System/Chat/ChatBubbleModel.cs
New file
@@ -0,0 +1,95 @@
using System.Collections;
using System.Collections.Generic;
using TableConfig;
using UnityEngine;
namespace Snxxz.UI
{
    public class ChatBubbleModel : Model
    {
        public Dictionary<int, ChatBubble> chatBubbles = new Dictionary<int, ChatBubble>();
        public override void Init()
        {
            ParseConfig();
        }
        public override void UnInit()
        {
        }
        void ParseConfig()
        {
            var configs = Config.Instance.GetAllValues<ChatBubbleBoxConfig>();
            for (int i = 0; i < configs.Count; i++)
            {
                var config = configs[i];
                if (chatBubbles.ContainsKey(config.ID))
                {
                    continue;
                }
                var bubble = new ChatBubble();
                bubble.id = config.ID;
                bubble.name = config.Name;
                bubble.requireLevel = config.NeedLV;
                bubble.requireVipLevel = config.NeedVIPLVGift;
                bubble.leftBubbleIcon = config.leftBubbleIcon;
                bubble.rightBubbleIcon = config.rightBubbleIcon;
                bubble.leftPadding = new RectOffset()
                {
                    left = config.leftOffset.Length > 0 ? config.leftOffset[0] : 0,
                    right = config.leftOffset.Length > 1 ? config.leftOffset[1] : 0,
                    top = config.leftOffset.Length > 2 ? config.leftOffset[2] : 0,
                    bottom = config.leftOffset.Length > 3 ? config.leftOffset[3] : 0,
                };
                bubble.rifhtPadding = new RectOffset()
                {
                    left = config.rightOffset.Length > 0 ? config.rightOffset[0] : 0,
                    right = config.rightOffset.Length > 1 ? config.rightOffset[1] : 0,
                    top = config.rightOffset.Length > 2 ? config.rightOffset[2] : 0,
                    bottom = config.rightOffset.Length > 3 ? config.rightOffset[3] : 0,
                };
                chatBubbles.Add(config.ID, bubble);
            }
        }
        public bool TryGetBubble(int id, out ChatBubble bubble)
        {
            return chatBubbles.TryGetValue(id, out bubble);
        }
        public struct ChatBubble
        {
            public int id;
            public string name;
            public int requireLevel;
            public int requireVipLevel;
            public string leftBubbleIcon;
            public string rightBubbleIcon;
            public RectOffset leftPadding;
            public RectOffset rifhtPadding;
            public string GetBubbleIcon(bool left, ref bool isFlip)
            {
                isFlip = false;
                if (left)
                {
                    if (string.IsNullOrEmpty(leftBubbleIcon))
                    {
                        isFlip = true;
                        return rightBubbleIcon;
                    }
                    return leftBubbleIcon;
                }
                else
                {
                    if (string.IsNullOrEmpty(rightBubbleIcon))
                    {
                        isFlip = true;
                        return leftBubbleIcon;
                    }
                    return rightBubbleIcon;
                }
            }
        }
    }
}
System/Chat/ChatBubbleModel.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5df1d87dcb313db40be8a65716d3fca4
timeCreated: 1541148875
licenseType: Pro
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
System/Chat/ChatCenter.cs
@@ -866,7 +866,8 @@
        {
            var vipLevel = PlayerDatas.Instance.baseData.VIPLv;
            var job = PlayerDatas.Instance.baseData.Job;
            return StringUtility.Contact(vipLevel.ToString().PadLeft(2, '0'), 0, job);
            var bubbleId = PlayerDatas.Instance.baseData.bubbleId;
            return StringUtility.Contact(vipLevel.ToString().PadLeft(2, '0'), 0, job, bubbleId.ToString().PadLeft(2, '0'));
        }
        public void HandleChatBanned(ChatInfoType channel, string message, int toPlayer)
System/Chat/ChatContentBehaviour.cs
@@ -85,6 +85,7 @@
            ChatCtrl.OnRefreshSelf += OnRefreshSelf;
            ChatCtrl.Inst.OnPteChatChangeEvent += OnPteChatChangeEvent;
            chatCenter.UpdateChatContent += UpdateChatContent;
            PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerDataRefreshInfoEvent;
            ResetNewInfo();
            UpdateChatContent();
            if (m_ChatType == ChatInfoType.Friend)
@@ -149,7 +150,7 @@
        private void OnScrollValChange(Vector2 _pos)
        {
            if (m_ChatContentControl.mScrollRect.verticalNormalizedPosition < 0.1f&&m_ChatType==ChatInfoType.Friend)
            if (m_ChatContentControl.mScrollRect.verticalNormalizedPosition < 0.1f && m_ChatType == ChatInfoType.Friend)
            {
                ResetNewInfo();
            }
@@ -401,7 +402,7 @@
                _textHeight = Mathf.Max(m_DestSysText.preferredHeight, m_DestSysText.fontSize);
                _height += Mathf.Max(0, _textHeight - 23);
            }
            else if(_type == ScrollerDataType.Extra1)
            else if (_type == ScrollerDataType.Extra1)
            {
                m_DestTipText.SetExtenalData(_infoList);
                m_DestTipText.text = _content;
@@ -455,6 +456,15 @@
            ChatCtrl.OnRefreshSelf -= OnRefreshSelf;
            chatCenter.UpdateChatContent -= UpdateChatContent;
            ChatCtrl.Inst.OnPteChatChangeEvent -= OnPteChatChangeEvent;
            PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= PlayerDataRefreshInfoEvent;
        }
        private void PlayerDataRefreshInfoEvent(PlayerDataRefresh refreshType)
        {
            if (refreshType == PlayerDataRefresh.ExAttr10)
            {
                m_ChatContentControl.m_Scorller.RefreshActiveCellViews();
            }
        }
    }
}
System/Chat/ChatData.cs
@@ -65,20 +65,26 @@
    {
        this.player = player;
        this.name = name;
        extra = UIHelper.ServerStringTrim(extra);
        this.extra = extra;
        this.job = 1;
        IsSound = false;
        if (extra.Length > 1)
        var extraLength = extra.Length;
        if (extraLength > 1)
        {
            vipLv = int.Parse(extra.Substring(0, 2));
        }
        if (extra.Length > 2)
        if (extraLength > 2)
        {
            isGm = byte.Parse(extra.Substring(2, 1)) == 1;
        }
        if (extra.Length > 3)
        if (extraLength > 3)
        {
            job = byte.Parse(extra.Substring(3, 1));
        }
        if (extraLength > 4)
        {
            bubbleId = int.Parse(extra.Substring(4, extraLength > 5 ? 2 : 1));
        }
        if (ChatCenter.s_VoiceRegex.IsMatch(_content))
        {
@@ -94,6 +100,7 @@
    public int vipLv { get; protected set; }
    public bool isGm { get; protected set; }
    public int job { get; protected set; }
    public int bubbleId { get; protected set; }
    public long soundTick { get; private set; }
    public bool IsSound { get; private set; }
    public float soundLength { get; private set; }
System/Chat/ChatMineVoiceCell.cs
@@ -33,6 +33,7 @@
                return;
            }
            m_ChatBubble.DisplayContent(_data.content);
            m_ChatBubble.DisplayBubble((int)PlayerDatas.Instance.baseData.bubbleId);
            m_ChatBubble.gameObject.SetActive(!string.IsNullOrEmpty(_data.content));
            m_ChatIcon.SetSprite(GeneralDefine.GetJobHeadPortrait(_data.job, 0));
System/Chat/ChatOtherVoiceCell.cs
@@ -39,6 +39,7 @@
                ViewPlayer(_data);
            });
            m_ChatBubble.DisplayContent(_data.content, true);
            m_ChatBubble.DisplayBubble(_data.bubbleId);
            m_ChatBubble.gameObject.SetActive(!string.IsNullOrEmpty(_data.content));
            m_ChatIcon.SetSprite(GeneralDefine.GetJobHeadPortrait(_data.job, 0));
            m_PlayerName.text = _data.name;
System/Chat/ChatPlayerMineCell.cs
@@ -32,7 +32,8 @@
            }
            var chatUserData = data as ChatUeseData;
            m_ChatBubble.DisplayContent(data.content);
            m_ChatBubble.DisplayContent(data.content);
            m_ChatBubble.DisplayBubble((int)PlayerDatas.Instance.baseData.bubbleId);
            m_ChatIcon.SetSprite(GeneralDefine.GetJobHeadPortrait(chatUserData.job, 0));
            m_Func.onClick.RemoveAllListeners();
System/Chat/ChatPlayerOtherCell.cs
@@ -50,6 +50,7 @@
                m_VipLv.text = string.Empty;
            }
            m_ChatBubble.DisplayContent(data.content, true);
            m_ChatBubble.DisplayBubble(chatUserData.bubbleId);
        }
        private void OnFunc(CellView cell)
System/WindowBase/ModelCenter.cs
@@ -202,6 +202,7 @@
            RegisterModel<WishingPoolModel>();
            RegisterModel<RolePointModel>();
            RegisterModel<SocialModel>();
            RegisterModel<ChatBubbleModel>();
            inited = true;
        }
UI/Decorate/Graph/FlipImage.cs
@@ -7,8 +7,20 @@
[RequireComponent(typeof(Image))]
public class FlipImage : BaseMeshEffect
{
    [SerializeField] bool flipHorizontal = false;
    [SerializeField] bool flipVertical = false;
    [SerializeField] bool m_FlipHorizontal = false;
    [SerializeField] bool m_FlipVertical = false;
    public bool flipHorizontal
    {
        get { return m_FlipHorizontal; }
        set { m_FlipHorizontal = value; }
    }
    public bool flipVertical
    {
        get { return m_FlipVertical; }
        set { m_FlipVertical = value; }
    }
    public override void ModifyMesh(VertexHelper vh)
    {