少年修仙传客户端代码仓库
client_linchunjie
2018-11-05 33a78a9ac0606ce049c1c0d74966cae12ff5e43e
4398 【1.2】聊天气泡框
5个文件已修改
2个文件已添加
148 ■■■■ 已修改文件
Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs.meta 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatBubbleBehaviour.cs 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatBubbleModel.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatBubblePreviewWin.cs 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatBubblePreviewWin.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatBubbleSelectBehaviour.cs 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs
@@ -19,7 +19,9 @@
        public string rightBubbleIcon { get ; private set; } 
        public int[] leftOffset;
        public int[] rightOffset;
        public string Icon { get ; private set; }
        public string Icon { get ; private set; }
        public int Jump { get ; private set ; }
        public string GainTip { get ; private set; }
        public override string getKey()
        {
@@ -55,7 +57,11 @@
                     int.TryParse(rightOffsetStringArray[i],out rightOffset[i]);
                }
            
                Icon = rawContents[8].Trim();
                Icon = rawContents[8].Trim();
                Jump=IsNumeric(rawContents[9]) ? int.Parse(rawContents[9]):0;
                GainTip = rawContents[10].Trim();
            }
            catch (Exception ex)
            {
Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs.meta
@@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: d3368c32387593943aae6e197d7cb78f
timeCreated: 1541405725
timeCreated: 1541410050
licenseType: Pro
MonoImporter:
  serializedVersion: 2
System/Chat/ChatBubbleBehaviour.cs
@@ -15,6 +15,7 @@
        [SerializeField] FlipImage m_Flip;
        [SerializeField] Image m_BubbleIcon;
        [SerializeField] bool left = false;
        [SerializeField] bool m_PreferredWidth = false;
        private int bubbleId = 0;
@@ -38,8 +39,6 @@
            get { return m_Padding; }
        }
        private bool preferredWidth = false;
        private void OnEnable()
        {
            Refresh();
@@ -52,7 +51,7 @@
                return;
            }
            left = _left;
            preferredWidth = true;
            m_PreferredWidth = true;
            var targetRect = m_Target.rectTransform;
            var richText = m_Target as RichText;
            if (richText != null && !left)
@@ -65,7 +64,7 @@
                if (m_Target.preferredWidth > targetRect.rect.width)
                {
                    m_Target.alignment = TextAnchor.UpperLeft;
                    preferredWidth = false;
                    m_PreferredWidth = false;
                }
                else
                {
@@ -114,7 +113,7 @@
            }
            var targetRect = m_Target.rectTransform;
            var sizeDelta = targetRect.sizeDelta;
            var width = preferredWidth || !Application.isPlaying ? m_Target.preferredWidth : sizeDelta.x;
            var width = m_PreferredWidth || !Application.isPlaying ? m_Target.preferredWidth : sizeDelta.x;
            sizeDelta.x = width + m_Padding.left + m_Padding.right;
            sizeDelta.y = sizeDelta.y + m_Padding.top + m_Padding.bottom;
            if (sizeDelta != rect.sizeDelta)
System/Chat/ChatBubbleModel.cs
@@ -110,6 +110,10 @@
            {
                return;
            }
            if (id == PlayerDatas.Instance.baseData.bubbleId)
            {
                return;
            }
            CA230_tagCMSetChatBubbleBox pak = new CA230_tagCMSetChatBubbleBox();
            pak.BubbleBoxType = (byte)id;
            GameNetSystem.Instance.SendInfo(pak);
System/Chat/ChatBubblePreviewWin.cs
New file
@@ -0,0 +1,87 @@
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Monday, November 05, 2018
//--------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using TableConfig;
using UnityEngine;
using UnityEngine.UI;
namespace Snxxz.UI
{
    public class ChatBubblePreviewWin : Window
    {
        [SerializeField] Text m_ChatLeftName;
        [SerializeField] Text m_ChatRightName;
        [SerializeField] ChatBubbleBehaviour m_ChatLeftBubble;
        [SerializeField] ChatBubbleBehaviour m_ChatRightBubble;
        [SerializeField] Text m_BubbleName;
        [SerializeField] Button m_Goto;
        [SerializeField] Button m_Close;
        public static int previewBubbleId = 0;
        ChatBubbleModel model
        {
            get { return ModelCenter.Instance.GetModel<ChatBubbleModel>(); }
        }
        #region Built-in
        protected override void BindController()
        {
        }
        protected override void AddListeners()
        {
            m_Close.onClick.AddListener(CloseClick);
            m_Goto.onClick.AddListener(Goto);
        }
        protected override void OnPreOpen()
        {
            ChatBubbleModel.ChatBubble bubble;
            if (model.TryGetBubble(previewBubbleId, out bubble))
            {
                m_ChatLeftName.text = Language.Get("ChatBubbleLeftName");
                m_ChatRightName.text = Language.Get("ChatBubbleRightName");
                m_ChatLeftBubble.DisplayBubble(previewBubbleId);
                m_ChatRightBubble.DisplayBubble(previewBubbleId);
                m_ChatLeftBubble.DisplayContent(Language.Get("ChatBubbleLeftWord"), true);
                m_ChatRightBubble.DisplayContent(Language.Get("ChatBubbleRightWord"), false);
                var config = Config.Instance.Get<ChatBubbleBoxConfig>(previewBubbleId);
                m_BubbleName.text = config.Name;
            }
        }
        protected override void OnAfterOpen()
        {
        }
        protected override void OnPreClose()
        {
        }
        protected override void OnAfterClose()
        {
        }
        #endregion
        private void Goto()
        {
            var config = Config.Instance.Get<ChatBubbleBoxConfig>(previewBubbleId);
            if (config != null)
            {
                CloseImmediately();
                WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)config.Jump);
            }
        }
    }
}
System/Chat/ChatBubblePreviewWin.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d471b2d1ce973b54b9c679867a80e250
timeCreated: 1541407079
licenseType: Pro
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
System/Chat/ChatBubbleSelectBehaviour.cs
@@ -92,25 +92,23 @@
                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;
                    }
                    m_Condition.text = config.GainTip;
                }
            }
        }
        private void OnFunc()
        {
            var reason = 0;
            if (model.IsBubbleGot(bubbleId, out reason))
            {
                model.SendUseBubble(bubbleId);
            }
            else
            {
                ChatBubblePreviewWin.previewBubbleId = bubbleId;
                WindowCenter.Instance.Open<ChatBubblePreviewWin>();
            }
        }
    }
}