浏览代码

【优化】1.每隔3秒向客户端推送前3名榜单,需要判断是否结束;2.推送排行榜信息字段优化

johnclot69 1 年之前
父节点
当前提交
457d61bf35

+ 7 - 20
DotNet/Hotfix/Scenes/Game/Map/MapEventComponentSystem.cs

@@ -54,24 +54,23 @@ namespace ET.Server
                     {
                         Map map = self.GetParent<Map>();
                         map.CurBattleIndex = 1;
-                        self.TransferUnitsToNewTower();
+                        map.TransferUnitsToNewTower();
                         return;
                     }
                     else if ("Tower2".Equals(parames[1]))
                     {
                         Log.Debug($"塔2死亡事件...");
-                            Map map = self.GetParent<Map>();
-                            map.CurBattleIndex = 2;
-                            self.TransferUnitsToNewTower();
-
-                            return;
+                        Map map = self.GetParent<Map>();
+                        map.CurBattleIndex = 2;
+                        map.TransferUnitsToNewTower();
+                        return;
                     }
                     else if ("Tower3".Equals(parames[1]))
                     {
                         Log.Debug($"塔3死亡事件...");
                         Map map = self.GetParent<Map>();
                         map.CurBattleIndex = 3;
-                        self.TransferUnitsToNewTower();
+                        map.TransferUnitsToNewTower();
                         return;
                     }
                     else
@@ -112,18 +111,6 @@ namespace ET.Server
             }
         }
 
-        private static void TransferUnitsToNewTower(this MapEventComponent self)
-        {
-            Map map = self.GetParent<Map>();
-
-            foreach(Struct.UnitPlayerData player in map.UnitPlayers.Values)
-            {
-                var pos = map.GetRandomPlayerPos();
-                map.GetXmdsManager().transferUnit(map.Id.ToString(), player.ObjId, pos.X, pos.Y);
-            }
-            Log.Debug($"transfer unit: {map.UnitPlayers.Count}");
-        }
-
         /// <summary>
         /// 场景结算事件
         /// </summary>
@@ -138,7 +125,7 @@ namespace ET.Server
             {
                 return;
             }
-            // 场景结束逻辑
+            // 场景结束排行榜逻辑
             map.GetComponent<MapRankComponent>().OnGameOver();
             // 记录玩家历史
             map.SyncPlayerHistoryData(map.Player);

+ 10 - 3
DotNet/Hotfix/Scenes/Game/Map/MapRankComponentSystem.cs

@@ -28,6 +28,13 @@ namespace ET.Server
         {
             protected override void Update(MapRankComponent self)
             {
+                Map map = self.GetParent<Map>();
+
+                if (map.IsGameOver())
+                {
+                    return;
+                }
+
                 // 未死亡的单位玩家,每秒增加贡献值
                 self.AddContributeValue();
 
@@ -93,8 +100,8 @@ namespace ET.Server
             {
                 RankInfo info = new RankInfo();
                 info.Name = unitPlayerData.Name;
-                // info.Url = unitPlayerData.Url;
-                info.Value = unitPlayerData.ContributeValue;
+                info.Url = unitPlayerData.Url;
+                // info.Value = unitPlayerData.ContributeValue;
                 info.Ranking = ranking;
                 infoListProto.Add(info);
 
@@ -159,7 +166,7 @@ namespace ET.Server
             {
                 RankInfo info = new RankInfo();
                 info.Name = unitPlayerData.Name;
-                // info.Url = unitPlayerData.Url;
+                info.Url = unitPlayerData.Url;
                 info.Value = unitPlayerData.ContributeValue;
                 info.Ranking = ranking;
                 infoListProto.Add(info);

+ 10 - 0
DotNet/Hotfix/Scenes/Game/Map/MapSystem.cs

@@ -458,5 +458,15 @@ namespace ET.Server
 
             return new Vector2(tower.X + (float)(r * Math.Cos(ang)), tower.Y - (float)(r * Math.Sin(ang)));
         }
+
+        public static void TransferUnitsToNewTower(this Map self)
+        {
+            foreach(Struct.UnitPlayerData player in self.UnitPlayers.Values)
+            {
+                Vector2 pos = self.GetRandomPlayerPos();
+                self.GetXmdsManager().transferUnit(self.Id.ToString(), player.ObjId, pos.X, pos.Y);
+            }
+            Log.Debug($"transfer unit: {self.UnitPlayers.Count}");
+        }
     }
 }