少年修仙传客户端代码仓库
client_linchunjie
2018-11-05 68acdb8d3f3f34b9f2d87db078b6bab8ae3fefb2
4398 【1.2】聊天气泡框
5个文件已修改
10个文件已添加
451 ■■■■■ 已修改文件
Core/GameEngine/DataToCtl/PackageRegedit.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs.meta 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/NetworkPackage/ClientPack/ClientToMapServer/CA2_Interaction/CA230_tagCMSetChatBubbleBox.cs 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/NetworkPackage/ClientPack/ClientToMapServer/CA2_Interaction/CA230_tagCMSetChatBubbleBox.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/NetworkPackage/DTCFile/ServerPack/HA7_Interaction/DTCA717_tagMCChatBubbleBoxState.cs 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/NetworkPackage/DTCFile/ServerPack/HA7_Interaction/DTCA717_tagMCChatBubbleBoxState.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/NetworkPackage/ServerPack/HA7_Interaction/HA717_tagMCChatBubbleBoxState.cs 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/NetworkPackage/ServerPack/HA7_Interaction/HA717_tagMCChatBubbleBoxState.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatBubbleCell.cs 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatBubbleCell.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatBubbleModel.cs 92 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatBubbleSelectBehaviour.cs 117 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatBubbleSelectBehaviour.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatExtentWin.cs 73 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/DataToCtl/PackageRegedit.cs
@@ -11,6 +11,7 @@
    public static void Init()
    {
        // 登记相应的数据体及对应的数据转逻辑类
        Register(typeof(HA717_tagMCChatBubbleBoxState), typeof(DTCA717_tagMCChatBubbleBoxState));
        Register(typeof(HB913_tagGCEnterTeamFBFailReason), typeof(DTCB913_tagGCEnterTeamFBFailReason));
        Register(typeof(H0311_tagDeleteSkill), typeof(DTC0311_tagDeleteSkill));
        Register(typeof(HB106_tagMCNotifyPlayerMove), typeof(DTCB106_tagMCNotifyPlayerMove));
Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs
@@ -1,6 +1,6 @@
//--------------------------------------------------------
//    [Author]:            第二世界
//    [  Date ]:           Friday, November 02, 2018
//    [  Date ]:           Monday, November 05, 2018
//--------------------------------------------------------
using UnityEngine;
@@ -18,7 +18,8 @@
        public string leftBubbleIcon { get ; private set; } 
        public string rightBubbleIcon { get ; private set; } 
        public int[] leftOffset;
        public int[] rightOffset;
        public int[] rightOffset;
        public string Icon { get ; private set; }
        public override string getKey()
        {
@@ -52,7 +53,9 @@
                for (int i=0;i<rightOffsetStringArray.Length;i++)
                {
                     int.TryParse(rightOffsetStringArray[i],out rightOffset[i]);
                }
                }
                Icon = rawContents[8].Trim();
            }
            catch (Exception ex)
            {
Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs.meta
@@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: d3368c32387593943aae6e197d7cb78f
timeCreated: 1541148738
timeCreated: 1541405725
licenseType: Pro
MonoImporter:
  serializedVersion: 2
Core/NetworkPackage/ClientPack/ClientToMapServer/CA2_Interaction/CA230_tagCMSetChatBubbleBox.cs
New file
@@ -0,0 +1,18 @@
using UnityEngine;
using System.Collections;
// A2 30 设置聊天气泡框 #tagCMSetChatBubbleBox
public class CA230_tagCMSetChatBubbleBox : GameNetPackBasic {
    public byte BubbleBoxType;    //气泡框类型
    public CA230_tagCMSetChatBubbleBox () {
        combineCmd = (ushort)0x03FE;
        _cmd = (ushort)0xA230;
    }
    public override void WriteToBytes () {
        WriteBytes (BubbleBoxType, NetDataType.BYTE);
    }
}
Core/NetworkPackage/ClientPack/ClientToMapServer/CA2_Interaction/CA230_tagCMSetChatBubbleBox.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2bd82e50dd886f640bb5c2c2a95029ae
timeCreated: 1541388926
licenseType: Pro
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Core/NetworkPackage/DTCFile/ServerPack/HA7_Interaction/DTCA717_tagMCChatBubbleBoxState.cs
New file
@@ -0,0 +1,24 @@
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Monday, November 05, 2018
//--------------------------------------------------------
using Snxxz.UI;
using System;
using System.Collections;
using System.Collections.Generic;
public class DTCA717_tagMCChatBubbleBoxState : DtcBasic {
    public override void Done(GameNetPackBasic vNetPack)
    {
        base.Done(vNetPack);
        var package = vNetPack as HA717_tagMCChatBubbleBoxState;
        var model = ModelCenter.Instance.GetModel<ChatBubbleModel>();
    }
}
Core/NetworkPackage/DTCFile/ServerPack/HA7_Interaction/DTCA717_tagMCChatBubbleBoxState.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9b9fa6bf002bc674f827dd8e5bf995be
timeCreated: 1541388295
licenseType: Pro
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Core/NetworkPackage/ServerPack/HA7_Interaction/HA717_tagMCChatBubbleBoxState.cs
New file
@@ -0,0 +1,17 @@
using UnityEngine;
using System.Collections;
// A7 17 聊天气泡框状态 #tagMCChatBubbleBoxState
public class HA717_tagMCChatBubbleBoxState : GameNetPackBasic {
    public uint BoxState;    // 按二进制位存储代表是否已开启,暂支持31位,以后有需要再加
    public HA717_tagMCChatBubbleBoxState () {
        _cmd = (ushort)0xA717;
    }
    public override void ReadFromBytes (byte[] vBytes) {
        TransBytes (out BoxState, vBytes, NetDataType.DWORD);
    }
}
Core/NetworkPackage/ServerPack/HA7_Interaction/HA717_tagMCChatBubbleBoxState.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 75af16c19e35946488560bae099c3ceb
timeCreated: 1541388257
licenseType: Pro
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
System/Chat/ChatBubbleCell.cs
New file
@@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using TableConfig;
using UnityEngine;
namespace Snxxz.UI
{
    public class ChatBubbleCell : CellView
    {
        [SerializeField] ChatBubbleSelectBehaviour[] m_ChatBubbles;
        [SerializeField] int m_LineCount = 7;
        public int lineCount { get { return m_LineCount; } }
        ChatBubbleModel model
        {
            get { return ModelCenter.Instance.GetModel<ChatBubbleModel>(); }
        }
        public void Display(int line)
        {
            var configs = Config.Instance.GetAllValues<ChatBubbleBoxConfig>();
            for (int i = 0; i < lineCount; i++)
            {
                var index = line * 7 + i;
                if (index < configs.Count)
                {
                    m_ChatBubbles[i].gameObject.SetActive(true);
                    m_ChatBubbles[i].Display(configs[i].ID);
                }
                else
                {
                    m_ChatBubbles[i].gameObject.SetActive(false);
                }
            }
        }
    }
}
System/Chat/ChatBubbleCell.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 335becbcd490c4a48b88be31b662fc32
timeCreated: 1541403023
licenseType: Pro
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
System/Chat/ChatBubbleModel.cs
@@ -1,12 +1,17 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using TableConfig;
using UnityEngine;
namespace Snxxz.UI
{
    public class ChatBubbleModel : Model
    public class ChatBubbleModel : Model, IBeforePlayerDataInitialize
    {
        public Dictionary<int, ChatBubble> chatBubbles = new Dictionary<int, ChatBubble>();
        public event Action chatBubbleStateRefresh;
        VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
        public override void Init()
        {
            ParseConfig();
@@ -14,6 +19,11 @@
        public override void UnInit()
        {
        }
        public void OnBeforePlayerDataInitialize()
        {
            bubbleState = 0;
        }
        void ParseConfig()
@@ -28,11 +38,6 @@
                }
                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,
@@ -56,37 +61,88 @@
            return chatBubbles.TryGetValue(id, out bubble);
        }
        public bool IsBubbleGot(int id, out int reason)
        {
            ChatBubble bubble;
            reason = 0;
            if (TryGetBubble(id, out bubble))
            {
                var config = Config.Instance.Get<ChatBubbleBoxConfig>(id);
                if (config.NeedLV != 0)
                {
                    reason = 1;
                    return PlayerDatas.Instance.baseData.LV >= config.NeedLV;
                }
                if (config.NeedVIPLVGift != 0)
                {
                    reason = 2;
                    var gift = vipModel.GetVipGift(config.NeedVIPLVGift);
                    return gift != null && gift.hasBuy;
                }
                try
                {
                    reason = 3;
                    return MathUtility.GetBitValue(bubbleState, (ushort)id);
                }
                catch (ArgumentOutOfRangeException)
                {
                    DebugEx.LogError("目前不支持id超过31的聊天框:" + id);
                }
            }
            return false;
        }
        #region 服务端数据
        public uint bubbleState { get; private set; }
        public void UpdateBubbleState(HA717_tagMCChatBubbleBoxState package)
        {
            bubbleState = package.BoxState;
            if (chatBubbleStateRefresh != null)
            {
                chatBubbleStateRefresh();
            }
        }
        public void SendUseBubble(int id)
        {
            var reason = 0;
            if (!IsBubbleGot(id, out reason))
            {
                return;
            }
            CA230_tagCMSetChatBubbleBox pak = new CA230_tagCMSetChatBubbleBox();
            pak.BubbleBoxType = (byte)id;
            GameNetSystem.Instance.SendInfo(pak);
        }
        #endregion
        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)
            {
                var config = Config.Instance.Get<ChatBubbleBoxConfig>(id);
                isFlip = false;
                if (left)
                {
                    if (string.IsNullOrEmpty(leftBubbleIcon))
                    if (string.IsNullOrEmpty(config.leftBubbleIcon))
                    {
                        isFlip = true;
                        return rightBubbleIcon;
                        return config.rightBubbleIcon;
                    }
                    return leftBubbleIcon;
                    return config.leftBubbleIcon;
                }
                else
                {
                    if (string.IsNullOrEmpty(rightBubbleIcon))
                    if (string.IsNullOrEmpty(config.rightBubbleIcon))
                    {
                        isFlip = true;
                        return leftBubbleIcon;
                        return config.leftBubbleIcon;
                    }
                    return rightBubbleIcon;
                    return config.rightBubbleIcon;
                }
            }
        }
System/Chat/ChatBubbleSelectBehaviour.cs
New file
@@ -0,0 +1,117 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TableConfig;
using UnityEngine;
using UnityEngine.UI;
namespace Snxxz.UI
{
    public class ChatBubbleSelectBehaviour : MonoBehaviour
    {
        [SerializeField] Button m_Func;
        [SerializeField] Image m_Icon;
        [SerializeField] Image m_Using;
        [SerializeField] Text m_BubbleName;
        [SerializeField] RectTransform m_ContainerUnGet;
        [SerializeField] Text m_Condition;
        private int bubbleId = 0;
        ChatBubbleModel model
        {
            get { return ModelCenter.Instance.GetModel<ChatBubbleModel>(); }
        }
        VipModel vipModel
        {
            get { return ModelCenter.Instance.GetModel<VipModel>(); }
        }
        private void Awake()
        {
            m_Func.onClick.AddListener(OnFunc);
        }
        private void OnEnable()
        {
            PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerDataRefreshInfoEvent;
            vipModel.OnVipGiftEvent += OnVipGiftEvent;
        }
        private void OnDisable()
        {
            PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= PlayerDataRefreshInfoEvent;
            vipModel.OnVipGiftEvent -= OnVipGiftEvent;
        }
        private void PlayerDataRefreshInfoEvent(PlayerDataRefresh refreshType)
        {
            if (refreshType == PlayerDataRefresh.ExAttr10)
            {
                DisplaySelect();
            }
            else if (refreshType == PlayerDataRefresh.LV)
            {
                DisplayState();
            }
        }
        private void OnVipGiftEvent()
        {
            DisplayState();
        }
        public void Display(int id)
        {
            ChatBubbleModel.ChatBubble bubble;
            if (model.TryGetBubble(id, out bubble))
            {
                bubbleId = id;
                var config = Config.Instance.Get<ChatBubbleBoxConfig>(bubbleId);
                m_BubbleName.text = config.Name;
                m_Icon.SetSprite(config.Icon);
                DisplayState();
                DisplaySelect();
            }
        }
        void DisplaySelect()
        {
            m_Using.gameObject.SetActive(PlayerDatas.Instance.baseData.bubbleId == bubbleId);
        }
        void DisplayState()
        {
            ChatBubbleModel.ChatBubble bubble;
            if (model.TryGetBubble(bubbleId, out bubble))
            {
                var reason = 0;
                var got = model.IsBubbleGot(bubbleId, out reason);
                m_ContainerUnGet.gameObject.SetActive(reason != 0 && !got);
                var config = Config.Instance.Get<ChatBubbleBoxConfig>(bubbleId);
                if (!got)
                {
                    switch (reason)
                    {
                        case 1:
                            m_Condition.text = Language.Get("", config.NeedLV);
                            break;
                        case 2:
                            m_Condition.text = Language.Get("", config.NeedVIPLVGift);
                            break;
                        default:
                            m_Condition.text = string.Empty;
                            break;
                    }
                }
            }
        }
        private void OnFunc()
        {
        }
    }
}
System/Chat/ChatBubbleSelectBehaviour.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f81808b2bd0f09e41b846324c1fedcf6
timeCreated: 1541387386
licenseType: Pro
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
System/Chat/ChatExtentWin.cs
@@ -11,7 +11,8 @@
using UnityEngine;
using UnityEngine.UI;
namespace Snxxz.UI {
namespace Snxxz.UI
{
    public class ChatExtentWin : Window
    {
@@ -23,13 +24,19 @@
        [SerializeField] ScrollerController m_BagControl;
        [SerializeField] RectTransform m_ContainerFace;
        [SerializeField] ScrollerController m_FaceControl;
        [SerializeField] RectTransform m_ContainerChatBubble;
        [SerializeField] ScrollerController m_ChatBubbleController;
        [SerializeField] Button m_FaceBtn;
        [SerializeField] Button m_QuickChatBtn;
        [SerializeField] Button m_BagBtn;
        [SerializeField] Button m_Face;
        [SerializeField] Button m_QuickChat;
        [SerializeField] Button m_Bag;
        [SerializeField] Button m_ChatBubble;
        [SerializeField] Text m_FaceBtnTxt;
        [SerializeField] Text m_QuickChatBtnTxt;
        [SerializeField] Text m_BagBtnTxt;
        [SerializeField] Text m_ChatBubbleBtnTxt;
        [SerializeField] ChatBubbleCell m_ChatBubbleCell;
        ChatCenter m_ChatCenter;
        ChatCenter chatCenter
@@ -60,18 +67,20 @@
            for (int i = 0; i < m_QuickChatBtns.Count; i++)
            {
                int _index = i;
                m_QuickChatBtns[i].onClick.AddListener(()=>
                m_QuickChatBtns[i].onClick.AddListener(() =>
                {
                    OnQuickChat(_index);
                });
            }
            m_FaceBtn.onClick.AddListener(OnFaceBtn);
            m_BagBtn.onClick.AddListener(OnBagBtn);
            m_QuickChatBtn.onClick.AddListener(OnQuickChat);
            m_Face.onClick.AddListener(OnFaceBtn);
            m_Bag.onClick.AddListener(OnBagBtn);
            m_QuickChat.onClick.AddListener(OnQuickChat);
            m_ChatBubble.onClick.AddListener(OnChatBubble);
            m_FaceControl.OnRefreshCell += OnRefreshFaceCell;
            m_BagControl.OnRefreshCell += OnRefreshBagCell;
            m_ChatBubbleController.OnRefreshCell += OnRefreshBubbleCell;
        }
        private void OnRefreshBagCell(ScrollerDataType type, CellView cell)
@@ -202,6 +211,14 @@
            RecentlyChatChangeEvent();
        }
        private void OnChatBubble()
        {
            presentSelect = 3;
            UpdateButtonState();
            RefreshChatBubble();
        }
        private void OnQuickChat(int _index)
        {
            if (_index < chatCenter.recentlyChats.Count)
@@ -251,7 +268,7 @@
            }
        }
        private bool GetCutOffValue(Text _text,string _value,int _line,out string _display)
        private bool GetCutOffValue(Text _text, string _value, int _line, out string _display)
        {
            _display = string.Empty;
            if (_text.preferredWidth >= _text.rectTransform.rect.width * _line)
@@ -271,7 +288,7 @@
                        break;
                    }
                }
                _display= _value.Substring(0, Mathf.Max(0, _index - 5));
                _display = _value.Substring(0, Mathf.Max(0, _index - 5));
                return true;
            }
            return false;
@@ -322,19 +339,49 @@
            m_BagControl.Restart();
        }
        private void RefreshChatBubble()
        {
            if (m_ChatBubbleController.GetNumberOfCells(m_ChatBubbleController.m_Scorller) == 0)
            {
                m_ChatBubbleController.Refresh();
                var configs = Config.Instance.GetAllValues<ChatBubbleBoxConfig>();
                var lineCount = m_ChatBubbleCell.lineCount == 0 ? 7 : m_ChatBubbleCell.lineCount;
                var line = Mathf.CeilToInt((float)configs.Count / lineCount);
                for (int i = 0; i < line; i++)
                {
                    m_ChatBubbleController.AddCell(ScrollerDataType.Header, i);
                }
                m_ChatBubbleController.Restart();
            }
            else
            {
                m_ChatBubbleController.JumpIndex(0);
                m_ChatBubbleController.m_Scorller.RefreshActiveCellViews();
            }
        }
        private void OnRefreshBubbleCell(ScrollerDataType type, CellView cell)
        {
            var chatBubbleCell = cell as ChatBubbleCell;
            chatBubbleCell.Display(cell.index);
        }
        void UpdateButtonState()
        {
            m_ContainerFace.gameObject.SetActive(presentSelect == 0);
            m_ContainerBag.gameObject.SetActive(presentSelect == 2);
            m_ContainerQuickChat.gameObject.SetActive(presentSelect == 1);
            m_ContainerChatBubble.gameObject.SetActive(presentSelect == 3);
            m_BagBtn.image.SetSprite(presentSelect == 2 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
            m_FaceBtn.image.SetSprite(presentSelect == 0 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
            m_QuickChatBtn.image.SetSprite(presentSelect == 1 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
            m_Bag.image.SetSprite(presentSelect == 2 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
            m_Face.image.SetSprite(presentSelect == 0 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
            m_QuickChat.image.SetSprite(presentSelect == 1 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
            m_ChatBubble.image.SetSprite(presentSelect == 3 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
            m_QuickChatBtnTxt.color = presentSelect == 1 ? UIHelper.s_LightYellow : UIHelper.GetUIColor(TextColType.NavyBrown);
            m_BagBtnTxt.color = presentSelect == 2 ? UIHelper.s_LightYellow : UIHelper.GetUIColor(TextColType.NavyBrown);
            m_FaceBtnTxt.color = presentSelect == 0 ? UIHelper.s_LightYellow : UIHelper.GetUIColor(TextColType.NavyBrown);
            m_ChatBubbleBtnTxt.color = presentSelect == 3 ? UIHelper.s_LightYellow : UIHelper.GetUIColor(TextColType.NavyBrown);
        }
    }