少年修仙传客户端代码仓库
Client_PangDeRong
2019-01-03 8c1b39b00fd0f9df1f23445aed456c0b92366218
Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
5个文件已修改
615 ■■■■■ 已修改文件
Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0403_tagPlayerLoginLoadOK.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatBubbleBehaviour.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Login/CrossServerLogin.cs 570 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Message/RichTableEvent.cs 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Utility/UIHelper.cs 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0403_tagPlayerLoginLoadOK.cs
@@ -19,6 +19,12 @@
        finishedLogin = true;
        NetLinkWin.Hide();
        if (loginModel.reconnectBackGround)
        {
            WindowCenter.Instance.Close<LoadingWin>();
        }
        switch (vNetData.socketType)
        {
            case GameNetSystem.SocketType.Main:
@@ -26,6 +32,7 @@
                break;
            case GameNetSystem.SocketType.CrossSever:
                CrossServerLogin.Instance.reconnectBackGround = false;
                CrossServerLogin.Instance.StopLoginOverTimeProcess();
                break;
            default:
                break;
System/Chat/ChatBubbleBehaviour.cs
@@ -138,7 +138,7 @@
            var height = sizeDelta.y;
            if (nullContent)
            {
                height = 0;
                height = m_Target.fontSize + 3;
            }
            if (m_ContainerVoice != null)
System/Login/CrossServerLogin.cs
@@ -1,272 +1,300 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
namespace Snxxz.UI
{
    public class CrossServerLogin : Singleton<CrossServerLogin>
    {
        bool m_Busy = false;
        public bool busy {
            get { return m_Busy; }
            set { m_Busy = value; }
        }
        public bool reconnectBackGround { get; set; }
        int reLoginTime = 0;
        Clock loginOverTimeClock;
        public CrossServerOneVsOne oneVsOnePlayerData { get; private set; }
        LoginModel loginModel { get { return ModelCenter.Instance.GetModel<LoginModel>(); } }
        public void Init()
        {
            SnxxzGame.Instance.AddApplicationOutAction(OnApplicationOut);
        }
        public void UnInit()
        {
            SnxxzGame.Instance.RemoveApplicationOutAction(OnApplicationOut);
        }
        public string ipBuf { get; private set; }
        public int portBuf { get; private set; }
        public int gamePortBuf { get; private set; }
        public string accountBuf { get; private set; }
        public string passwordBuf { get; private set; }
        public void UpdateCrossServerOneVsOneData(HC001_tagGCCrossRealmPKMatchOK matchOK)
        {
            oneVsOnePlayerData = new CrossServerOneVsOne()
            {
                roomId = matchOK.RoomID,
                waitForLoginCrossServer = true,
                validTimeLimited = Time.time + 30f,
                autoEnsureTime = Time.time + 3f,
                myName = matchOK.PlayerName,
                myJob = PlayerDatas.Instance.baseData.Job,
                myBornPoint = matchOK.Number,
                opponentName = matchOK.MatchPlayer[0].PlayerName,
                opponentJob = matchOK.MatchPlayer[0].Job,
                opponentMaxHp = (int)matchOK.MatchPlayer[0].MaxHP,
                opponentLevel = (int)matchOK.MatchPlayer[0].LV,
                opponentPlayerId = (int)matchOK.MatchPlayer[0].PlayerID,
                MaxProDef = (int)matchOK.MatchPlayer[0].MaxProDef,
            };
            Clock.Create(DateTime.Now + new TimeSpan(5 * TimeSpan.TicksPerSecond), () =>
            {
                if (oneVsOnePlayerData.waitForLoginCrossServer)
                {
                    CrossServerOneVsOneLogin();
                }
            });
        }
        public void CrossServerOneVsOneLogin()
        {
            var loginModel = ModelCenter.Instance.GetModel<LoginModel>();
            var account = loginModel.accountBuf;
            var ip = GameNetSystem.Instance.crossServerData.ip;
            var port = GameNetSystem.Instance.crossServerData.port;
            WindowCenter.Instance.Open<LoadingWin>();
            oneVsOnePlayerData = oneVsOnePlayerData.SetWaitForLoginCrossServer(false);
            AccountLogin(account, ip, port, false);
        }
        public bool IsEnterCrossServerPreparing()
        {
            return oneVsOnePlayerData.IsCrossServerOneVsOneEntering();
        }
        public void AccountLogin(string account, string ip, int gamePort, bool reconnectBackGround)
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                ConfirmCancel.ShowPopConfirm(
                    Language.Get("Mail101"),
                    Language.Get("L1116"),
                    () => { }
                    );
                return;
            }
            if (busy)
            {
                return;
            }
            busy = true;
            reLoginTime = 0;
            try
            {
                this.reconnectBackGround = reconnectBackGround;
                accountBuf = account;
                ipBuf = ip;
                gamePortBuf = gamePort;
                if (loginOverTimeClock != null)
                {
                    loginOverTimeClock.Stop();
                }
                loginOverTimeClock = Clock.Create(DateTime.Now + new TimeSpan(15 * TimeSpan.TicksPerSecond), ProcessLoginFailure);
                GameNetSystem.Instance.BeginConnectCrossServer(ipBuf, gamePortBuf, OnGameServerConnected);
                NetLinkWin.Show();
            }
            catch (Exception ex)
            {
                Debug.Log(ex);
                busy = false;
            }
        }
        public void ReAccountLogin()
        {
            if (busy)
            {
                return;
            }
            busy = true;
            try
            {
                if (loginOverTimeClock != null)
                {
                    loginOverTimeClock.Stop();
                }
                loginOverTimeClock = Clock.Create(DateTime.Now + new TimeSpan(15 * TimeSpan.TicksPerSecond), ProcessLoginFailure);
                GameNetSystem.Instance.BeginConnectCrossServer(ipBuf, gamePortBuf, OnGameServerConnected);
                NetLinkWin.Show();
            }
            catch (Exception ex)
            {
                Debug.Log(ex);
                busy = false;
            }
        }
        private void OnGameServerConnected(bool ok)
        {
            if (ok)
            {
                var sendInfo = new C0123_tagCClientPackVersion();
                sendInfo.Version = LoginModel.DwVersionNo;
                GameNetSystem.Instance.SendToCrossServer(sendInfo);
            }
            else
            {
                busy = false;
            }
        }
        public void AccessLogin(H0101_tagServerPrepared _serverInfo)
        {
            GameNetSystem.Instance.SendToCrossServer(loginModel.Get0101SendPackage(_serverInfo)); // 登录
            NetLinkWin.Show();
        }
        public void CheckClientVersion()
        {
            var sendInfo = new C010D_tagCClientVersion();
            sendInfo.Version = "10.1000.1";
            GameNetSystem.Instance.SendToCrossServer(sendInfo);
            NetLinkWin.Show();
        }
        public void OnGetPlayerLoginInfo(byte _type)
        {
            NetLinkWin.Hide();
            busy = false;
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                ConfirmCancel.ShowPopConfirm(
                    Language.Get("Mail101"),
                    Language.Get("L1116"),
                    () => { }
                    );
                return;
            }
            GameNetSystem.Instance.crossServerConnected_Loigc = true;
            var tagCRoleLoginAsk = new C0108_tagCRoleLoginAsk();
            tagCRoleLoginAsk.Type = (byte)_type;//进入游戏
            tagCRoleLoginAsk.ClientID = SDKUtility.Instance.RegistrationID;
            GameNetSystem.Instance.SendToCrossServer(tagCRoleLoginAsk);
            NetLinkWin.Show();
            if (loginOverTimeClock != null)
            {
                loginOverTimeClock.Stop();
            }
        }
        private void ProcessLoginFailure()
        {
            if (reLoginTime < 1)
            {
                busy = false;
                reLoginTime++;
                ReAccountLogin();
            }
            else
            {
                ExceptionCatcher.ReportException("登录跨服出现异常", StringUtility.Contact("角色:", PlayerDatas.Instance.baseData.PlayerName));
                var sendInfo = new CC003_tagCGForceQuitCrossState();
                GameNetSystem.Instance.SendInfo(sendInfo);
                loginModel.ReAccountLogin();
                WindowCenter.Instance.Close<LoadingWin>();
            }
        }
        private void OnApplicationOut()
        {
            var sendInfo = new C0103_tagCPlayerLogOut();
            sendInfo.Type = 1;
            GameNetSystem.Instance.SendToCrossServer(sendInfo);
        }
    }
    public struct CrossServerOneVsOne
    {
        public int roomId;
        public bool waitForLoginCrossServer;
        public float autoEnsureTime;
        public float validTimeLimited;
        public string myName;
        public int myJob;
        public int myBornPoint;//1-左;2-右
        public int opponentPlayerId;
        public string opponentName;
        public int opponentJob;
        public int opponentLevel;
        public int opponentMaxHp;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
namespace Snxxz.UI
{
    public class CrossServerLogin : Singleton<CrossServerLogin>
    {
        bool m_Busy = false;
        public bool busy {
            get { return m_Busy; }
            set { m_Busy = value; }
        }
        public bool reconnectBackGround { get; set; }
        int reLoginTime = 0;
        Clock loginOverTimeClock;
        float lastLoginTime = 0f;
        int reLoginTimes = 0;
        public CrossServerOneVsOne oneVsOnePlayerData { get; private set; }
        LoginModel loginModel { get { return ModelCenter.Instance.GetModel<LoginModel>(); } }
        public void Init()
        {
            SnxxzGame.Instance.AddApplicationOutAction(OnApplicationOut);
        }
        public void UnInit()
        {
            SnxxzGame.Instance.RemoveApplicationOutAction(OnApplicationOut);
        }
        public string ipBuf { get; private set; }
        public int portBuf { get; private set; }
        public int gamePortBuf { get; private set; }
        public string accountBuf { get; private set; }
        public string passwordBuf { get; private set; }
        public void UpdateCrossServerOneVsOneData(HC001_tagGCCrossRealmPKMatchOK matchOK)
        {
            oneVsOnePlayerData = new CrossServerOneVsOne()
            {
                roomId = matchOK.RoomID,
                waitForLoginCrossServer = true,
                validTimeLimited = Time.time + 30f,
                autoEnsureTime = Time.time + 3f,
                myName = matchOK.PlayerName,
                myJob = PlayerDatas.Instance.baseData.Job,
                myBornPoint = matchOK.Number,
                opponentName = matchOK.MatchPlayer[0].PlayerName,
                opponentJob = matchOK.MatchPlayer[0].Job,
                opponentMaxHp = (int)matchOK.MatchPlayer[0].MaxHP,
                opponentLevel = (int)matchOK.MatchPlayer[0].LV,
                opponentPlayerId = (int)matchOK.MatchPlayer[0].PlayerID,
                MaxProDef = (int)matchOK.MatchPlayer[0].MaxProDef,
            };
            Clock.Create(DateTime.Now + new TimeSpan(5 * TimeSpan.TicksPerSecond), () =>
            {
                if (oneVsOnePlayerData.waitForLoginCrossServer)
                {
                    CrossServerOneVsOneLogin();
                }
            });
        }
        public void CrossServerOneVsOneLogin()
        {
            var loginModel = ModelCenter.Instance.GetModel<LoginModel>();
            var account = loginModel.accountBuf;
            var ip = GameNetSystem.Instance.crossServerData.ip;
            var port = GameNetSystem.Instance.crossServerData.port;
            WindowCenter.Instance.Open<LoadingWin>();
            oneVsOnePlayerData = oneVsOnePlayerData.SetWaitForLoginCrossServer(false);
            AccountLogin(account, ip, port, false);
        }
        public bool IsEnterCrossServerPreparing()
        {
            return oneVsOnePlayerData.IsCrossServerOneVsOneEntering();
        }
        public void AccountLogin(string account, string ip, int gamePort, bool reconnectBackGround)
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                ConfirmCancel.ShowPopConfirm(
                    Language.Get("Mail101"),
                    Language.Get("L1116"),
                    () => { }
                    );
                return;
            }
            if (busy)
            {
                return;
            }
            busy = true;
            if (Time.time - lastLoginTime < 15)
            {
                reLoginTimes++;
                if (reLoginTimes > 2)
                {
                    ProcessLoginFailure();
                    return;
                }
            }
            else
            {
                reLoginTimes = 0;
            }
            lastLoginTime = Time.time;
            try
            {
                this.reconnectBackGround = reconnectBackGround;
                accountBuf = account;
                ipBuf = ip;
                gamePortBuf = gamePort;
                StopLoginOverTimeProcess();
                loginOverTimeClock = Clock.Create(DateTime.Now + new TimeSpan(15 * TimeSpan.TicksPerSecond), () =>
                {
                    busy = false;
                    ReAccountLogin();
                });
                GameNetSystem.Instance.BeginConnectCrossServer(ipBuf, gamePortBuf, OnGameServerConnected);
                NetLinkWin.Show();
            }
            catch (Exception ex)
            {
                Debug.Log(ex);
                busy = false;
            }
        }
        public void ReAccountLogin()
        {
            if (busy)
            {
                return;
            }
            busy = true;
            if (Time.time - lastLoginTime < 15)
            {
                reLoginTimes++;
                if (reLoginTimes > 2)
                {
                    ProcessLoginFailure();
                    return;
                }
            }
            else
            {
                reLoginTimes = 0;
            }
            lastLoginTime = Time.time;
            try
            {
                StopLoginOverTimeProcess();
                loginOverTimeClock = Clock.Create(DateTime.Now + new TimeSpan(15 * TimeSpan.TicksPerSecond), () =>
                {
                    busy = false;
                    ReAccountLogin();
                });
                GameNetSystem.Instance.BeginConnectCrossServer(ipBuf, gamePortBuf, OnGameServerConnected);
                NetLinkWin.Show();
            }
            catch (Exception ex)
            {
                Debug.Log(ex);
                busy = false;
            }
        }
        public void StopLoginOverTimeProcess()
        {
            if (loginOverTimeClock != null)
            {
                loginOverTimeClock.Stop();
            }
            loginOverTimeClock = null;
        }
        private void OnGameServerConnected(bool ok)
        {
            if (ok)
            {
                var sendInfo = new C0123_tagCClientPackVersion();
                sendInfo.Version = LoginModel.DwVersionNo;
                GameNetSystem.Instance.SendToCrossServer(sendInfo);
            }
            else
            {
                busy = false;
            }
        }
        public void AccessLogin(H0101_tagServerPrepared _serverInfo)
        {
            GameNetSystem.Instance.SendToCrossServer(loginModel.Get0101SendPackage(_serverInfo)); // 登录
            NetLinkWin.Show();
        }
        public void CheckClientVersion()
        {
            var sendInfo = new C010D_tagCClientVersion();
            sendInfo.Version = "10.1000.1";
            GameNetSystem.Instance.SendToCrossServer(sendInfo);
            NetLinkWin.Show();
        }
        public void OnGetPlayerLoginInfo(byte _type)
        {
            NetLinkWin.Hide();
            busy = false;
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                ConfirmCancel.ShowPopConfirm(
                    Language.Get("Mail101"),
                    Language.Get("L1116"),
                    () => { }
                    );
                return;
            }
            GameNetSystem.Instance.crossServerConnected_Loigc = true;
            var tagCRoleLoginAsk = new C0108_tagCRoleLoginAsk();
            tagCRoleLoginAsk.Type = (byte)_type;//进入游戏
            tagCRoleLoginAsk.ClientID = SDKUtility.Instance.RegistrationID;
            GameNetSystem.Instance.SendToCrossServer(tagCRoleLoginAsk);
            NetLinkWin.Show();
        }
        private void ProcessLoginFailure()
        {
            busy = false;
            ExceptionCatcher.ReportException("登录跨服出现异常", StringUtility.Contact("角色:", PlayerDatas.Instance.baseData.PlayerName));
            var sendInfo = new CC003_tagCGForceQuitCrossState();
            GameNetSystem.Instance.SendInfo(sendInfo);
            Clock.Create(DateTime.Now + new TimeSpan(2 * TimeSpan.TicksPerSecond), () =>
            {
                loginModel.ReAccountLogin();
            });
        }
        private void OnApplicationOut()
        {
            var sendInfo = new C0103_tagCPlayerLogOut();
            sendInfo.Type = 1;
            GameNetSystem.Instance.SendToCrossServer(sendInfo);
        }
    }
    public struct CrossServerOneVsOne
    {
        public int roomId;
        public bool waitForLoginCrossServer;
        public float autoEnsureTime;
        public float validTimeLimited;
        public string myName;
        public int myJob;
        public int myBornPoint;//1-左;2-右
        public int opponentPlayerId;
        public string opponentName;
        public int opponentJob;
        public int opponentLevel;
        public int opponentMaxHp;
        public int MaxProDef;// 最大护盾
        public CrossServerOneVsOne SetWaitForLoginCrossServer(bool waitForLoginCrossServer)
        {
            this.waitForLoginCrossServer = waitForLoginCrossServer;
            return this;
        }
        public bool IsCrossServerOneVsOneEntering()
        {
            return autoEnsureTime > Time.time;
        }
    }
}
        public CrossServerOneVsOne SetWaitForLoginCrossServer(bool waitForLoginCrossServer)
        {
            this.waitForLoginCrossServer = waitForLoginCrossServer;
            return this;
        }
        public bool IsCrossServerOneVsOneEntering()
        {
            return autoEnsureTime > Time.time;
        }
    }
}
System/Message/RichTableEvent.cs
@@ -381,11 +381,13 @@
                                    var _id = 0;
                                    if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id))
                                    {
                                        var config = Config.Instance.Get<CrossServerArenaConfig>(_id);
                                        if (config != null)
                                        var text = RichTextMgr.Inst.presentRichText;
                                        int colorType = 0;
                                        if (text != null)
                                        {
                                            return config.Name;
                                            colorType = text.colorType == RichText.ColorType.Dark ? 0 : 1;
                                        }
                                        return UIHelper.AppendDanLVNameColor(_id, colorType == 1);
                                    }
                                }
                                break;
Utility/UIHelper.cs
@@ -474,6 +474,34 @@
        return Color.white;
    }
    public static string AppendDanLVNameColor(int danLv, bool bright = false)
    {
        var crossDanLVConfig = Config.Instance.Get<CrossServerArenaConfig>(danLv);
        if (crossDanLVConfig == null)
        {
            return string.Empty;
        }
        var name = crossDanLVConfig.Name;
        switch (crossDanLVConfig.DanType)
        {
            case 0:
                return StringUtility.Contact("<color=#", bright ? "666666" : "dddddd", ">", name, "</color>");
            case 1:
                return StringUtility.Contact("<color=#", bright ? "9460ff" : "7999ff", ">", name, "</color>");
            case 2:
                return StringUtility.Contact("<color=#", bright ? "0066ff" : "00c6ff", ">", name, "</color>");
            case 3:
                return StringUtility.Contact("<color=#", bright ? "00b337" : "66ff00", ">", name, "</color>");
            case 4:
                return StringUtility.Contact("<color=#", bright ? "ff6600" : "ff9000", ">", name, "</color>");
            case 5:
                return StringUtility.Contact("<color=#", bright ? "ff0000" : "ff0000", ">", name, "</color>");
            case 6:
                return StringUtility.Contact("<color=#", bright ? "ff00f6" : "f000ff", ">", name, "</color>");
        }
        return name;
    }
    public static Color GetUIColor(int itemColor, bool bright = false)
    {
        switch (itemColor)