From 07aee5604f365541c165f02bfe5437f1ed296fb5 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 05 六月 2025 22:13:20 +0800
Subject: [PATCH] 0015 卡牌服务端搭建 - 前期登录流程

---
 Main/Core/GameEngine/Player/PlayerDatas.cs |  112 +++++++++++++-------------------------------------------
 1 files changed, 26 insertions(+), 86 deletions(-)

diff --git a/Main/Core/GameEngine/Player/PlayerDatas.cs b/Main/Core/GameEngine/Player/PlayerDatas.cs
index 139b1cd..2914956 100644
--- a/Main/Core/GameEngine/Player/PlayerDatas.cs
+++ b/Main/Core/GameEngine/Player/PlayerDatas.cs
@@ -6,9 +6,6 @@
 
 public class PlayerDatas : Singleton<PlayerDatas>
 {
-    // public GA_Hero hero = null;
-
-    // public H0309_tagPlayerLoginInfo loginInfo;
     public uint PlayerId { get { return baseData.PlayerID; } }
 
     PlayerBaseData m_Base = new PlayerBaseData();
@@ -30,11 +27,9 @@
     public uint worldExpRate { get; private set; }
     public List<uint> maliciousAtkPlayer = new List<uint>();// 鍙戝姩鎭舵剰鏀诲嚮鐨勭帺瀹跺垪琛�
     private int m_Tick;
-    public uint crossServerTick;
     public uint changeLV = 0; //褰撳墠鍗噚绾�
 
     public event Action worldLevelUpdateEvent;
-    public event Action<E_AttackMode> OnSwitchAttackMode;
 
     public event Action playerDataUpdateEvent;    // 鏃犲尯鍒洿鏂帮紝鎱庣敤
     public event Action<PlayerDataType> playerDataRefreshEvent;
@@ -44,13 +39,13 @@
 
     private Dictionary<PlayerDataType, ulong> PlayerDataDict = new Dictionary<PlayerDataType, ulong>();
 
-    public void InitPlayerData(/*H0102_tagCDBPlayer data*/)
-    {
-        // baseData.UpdateData(data);
-        // if (playerDataUpdateEvent != null)
-        // {
-        //     playerDataUpdateEvent();
-        // }
+    public void InitPlayerData(H0102_tagCDBPlayer data)
+    {
+        baseData.UpdateData(data);
+        if (playerDataUpdateEvent != null)
+        {
+            playerDataUpdateEvent();
+        }
     }
 
     public void UpdatePlayerData(/*HA112_tagMCDBPlayer data*/)
@@ -70,7 +65,7 @@
 
     public void FightRefreshPlayerHp(ulong hp)
     {
-        RefreshProperty(false, PlayerDataType.HP, (uint)(hp % Constants.ExpPointValue), (uint)(hp/Constants.ExpPointValue));
+        RefreshProperty(PlayerDataType.HP, (uint)(hp % Constants.ExpPointValue), (uint)(hp/Constants.ExpPointValue));
 
         if (playerDataUpdateEvent != null)
         {
@@ -153,7 +148,7 @@
         // }
     }
 
-    public void RefreshProperty(bool isMainServerData, PlayerDataType _type, uint value, uint valueEx)
+    public void RefreshProperty(PlayerDataType _type, uint value, uint valueEx)
     {
         switch (_type)
         {
@@ -240,10 +235,6 @@
                 break;
             case PlayerDataType.MapID:
                 baseData.MapID = (ushort)value;
-                if (isMainServerData)
-                {
-                    baseData.mainServerMapIdRecord = baseData.MapID;
-                }
                 break;
             case PlayerDataType.PosX:
                 baseData.PosX = (ushort)value;//瑙掕壊鍧愭爣x
@@ -262,17 +253,7 @@
                 // }
                 break;
             case PlayerDataType.HP:
-                if (CrossServerUtility.IsCrossServer())
-                {
-                    if (!isMainServerData)
-                    {
-                        baseData.HP = value + valueEx * Constants.ExpPointValue;
-                    }
-                }
-                else
-                {
-                    baseData.HP = value + valueEx * Constants.ExpPointValue;
-                }
+                baseData.HP = value + valueEx * Constants.ExpPointValue;
                 break;
             case PlayerDataType.MaxMP:
                 extersion.MaxMP = (int)value;
@@ -420,42 +401,19 @@
                 break;
             case PlayerDataType.Tick:
 #if UNITY_EDITOR
-                Debug.LogFormat("---- 鏀跺埌鏈嶅姟绔疶ick: {0}", value);
-                if (isMainServerData)
-                {
-                    if (extersion.Tick != 0)
-                    {
-                        uint _curWorldTick = GetWorldTick();
-                        uint _diffValue = value > _curWorldTick ? value - _curWorldTick : _curWorldTick - value;
-                        Debug.LogFormat(" |-------- 褰撳墠瀹㈡埛绔疶ick: {0}, 宸紓: {1}", _curWorldTick, _diffValue);
-                        if (_diffValue > 5000)
-                        {
-                            Debug.LogFormat(" |-------- <color=red>鏀跺埌鏈嶅姟绔疻orldTick涓庡綋鍓嶇殑瀹㈡埛绔疶ick宸紓瓒呰繃5绉�</color>");
-                        }
-                    }
-                }
-                else
-                {
-                    if (crossServerTick != 0)
-                    {
-                        uint _curWorldTick = GetWorldTick();
-                        uint _diffValue = value > _curWorldTick ? value - _curWorldTick : _curWorldTick - value;
-                        Debug.LogFormat(" |-------- 褰撳墠瀹㈡埛绔疶ick: {0}, 宸紓: {1}", _curWorldTick, _diffValue);
-                        if (_diffValue > 5000)
-                        {
-                            Debug.LogFormat(" |-------- <color=red>鏀跺埌鏈嶅姟绔疻orldTick涓庡綋鍓嶇殑瀹㈡埛绔疶ick宸紓瓒呰繃5绉�</color>");
-                        }
-                    }
+                Debug.LogFormat("---- 鏀跺埌鏈嶅姟绔疶ick: {0}", value);
+                if (extersion.Tick != 0)
+                {
+                    uint _curWorldTick = GetWorldTick();
+                    uint _diffValue = value > _curWorldTick ? value - _curWorldTick : _curWorldTick - value;
+                    Debug.LogFormat(" |-------- 褰撳墠瀹㈡埛绔疶ick: {0}, 宸紓: {1}", _curWorldTick, _diffValue);
+                    if (_diffValue > 5000)
+                    {
+                        Debug.LogFormat(" |-------- <color=red>鏀跺埌鏈嶅姟绔疻orldTick涓庡綋鍓嶇殑瀹㈡埛绔疶ick宸紓瓒呰繃5绉�</color>");
+                    }
                 }
 #endif
-                if (isMainServerData)
-                {
-                    extersion.Tick = value;
-                }
-                else
-                {
-                    crossServerTick = value;
-                }
+                extersion.Tick = value;
                 m_Tick = Environment.TickCount;
 
                 break;
@@ -552,7 +510,6 @@
                 //             toLineId = 0,
                 //             needEmpty = true,
                 //             needLoadResource = true,
-                //             serverType = ServerType.CrossSever,
                 //             isClientLoadMap = true,
                 //             refreshPlayerDatas = true
                 //         });
@@ -1023,42 +980,25 @@
     }
 
     public void RequestWorldTick()
-    {
-        // TODO YYL
-        // CA102_tagCMWorldTick _proto = new CA102_tagCMWorldTick();
-        // if (CrossServerUtility.IsCrossServer())
-        // {
-        //     GameNetSystem.Instance.SendToCrossServer(_proto);
-        // }
-        // else
-        // {
-        //     GameNetSystem.Instance.SendInfo(_proto);
-        // }
+    {
+        CA102_tagCMWorldTick _proto = new CA102_tagCMWorldTick();
+        GameNetSystem.Instance.SendInfo(_proto);
     }
 
     public void ClearTick()
     {
         extersion.Tick = 0;
-        crossServerTick = 0;
     }
 
     public bool IsTickVaild()
     {
-        if (CrossServerUtility.IsCrossServer())
-        {
-            return crossServerTick != 0;
-        }
-        else
-        {
-            return extersion.Tick != 0;
-        }
+        return extersion.Tick != 0;
     }
 
     public uint GetWorldTick()
     {
         int _currentTick = Environment.TickCount - m_Tick;
-        uint _tick = CrossServerUtility.IsCrossServer() ? crossServerTick + (uint)_currentTick : extersion.Tick + (uint)_currentTick;
-        return _tick;
+        return extersion.Tick + (uint)_currentTick;
     }
 
 }

--
Gitblit v1.8.0