Browse Source

修改添加单位测试接口,支持随便机头像

大爷 1 year ago
parent
commit
a043ca2d84

+ 27 - 1
DotNet/Hotfix/Scenes/Game/Handler/C2G_AddUnitsToMapHandler.cs

@@ -40,9 +40,35 @@ namespace ET.Server
 
             // 临时openId
             string _openId = (10000 + new Random().Next(999)).ToString();
-            await player.Map.AddUnitPlayer(_openId, request.UnitId, request.Force, request.Flag, request.X, request.Y, "", "");
+            await player.Map.AddUnitPlayer(_openId, request.UnitId, request.Force, request.Flag, request.X, request.Y, GetRandomPlayerName(), GetRandomUrl());
 
             reply();
         }
+
+        private string GetRandomPlayerName()
+        {
+            string[] names =
+            {
+                "好人", "小新", "精钢侠", "带投大戈", "奥仔", "袄特门", "兔比斯", "张剑闯天牙", "窝耗帅", "大白"
+            };
+
+            var rand = new Random();
+            var first = names[rand.Next(names.Length)];
+            return first + rand.Next(99);
+        }
+
+        private string GetRandomUrl()
+        {
+            string[] url =
+            {
+                "https://pic1.zhimg.com/v2-3f475a4727cdff2c7289ce3c728a0e67_r.jpg",
+                "https://img.zcool.cn/community/01cfd95d145660a8012051cdb52093.png@1280w_1l_2o_100sh.png",
+                "https://pic4.zhimg.com/v2-ceb6cc092425322d0b4cab403cd403d7_r.jpg",
+                "https://pic3.zhimg.com/50/v2-e1ad5394ae2d3b2dc9d04c1d7a63f0e6_hd.jpg",
+                "https://pic1.zhimg.com/v2-9ee4a6f411b9a8ff076c38f1dcb03024_b.jpg"
+            };
+            var rand = new Random();
+            return url[rand.Next(url.Length)];
+        }
     }
 }

+ 0 - 2
DotNet/Hotfix/Scenes/Game/Map/MapEventComponentSystem.cs

@@ -73,7 +73,6 @@ namespace ET.Server
                         int objId = int.Parse(parames[1]);
                         if (objId > 0 && objId != 1 && objId != 2 && objId != 3)
                         {
-                            Log.Debug($"单位:{objId}死亡事件...");
                             Map map = self.GetParent<Map>();
                             Struct.UnitPlayerData unitPlayerData = map.GetUnitPlayerByObjId(objId);
                             if (unitPlayerData != null)
@@ -93,7 +92,6 @@ namespace ET.Server
                     int objId = int.Parse(parames[1]);
                     if (objId > 0)
                     {
-                        Log.Debug($"单位:{objId}复活事件...");
                         Map map = self.GetParent<Map>();
                         Struct.UnitPlayerData unitPlayerData = map.GetUnitPlayerByObjId(objId);
                         if (unitPlayerData != null)

+ 1 - 13
DotNet/Hotfix/Scenes/Game/Map/MapSystem.cs

@@ -355,7 +355,7 @@ namespace ET.Server
                 unit.y = y;
             }
             unit.autoGuard = true;
-            unit.name = string.IsNullOrEmpty(name)? self.GetRandomPlayerName() : name;
+            unit.name = name;
             unit.alias = url;
 
             int objId = await self.AddUnits(unit, true);
@@ -522,17 +522,5 @@ namespace ET.Server
             }
             Log.Debug($"transfer unit: {self.UnitPlayers.Count}");
         }
-
-        public static string GetRandomPlayerName(this Map self)
-        {
-            string[] names =
-            {
-                "好人", "小新", "精钢侠", "带投大戈", "奥仔", "袄特门", "兔比斯", "张剑闯天牙", "窝耗帅", "大白"
-            };
-
-            var rand = new Random();
-            var first = names[rand.Next(names.Length)];
-            return first + rand.Next(9999);
-        }
     }
 }