Browse Source

【优化】评论添加单位按范围增加

johnclot69 1 year ago
parent
commit
d97539667e
1 changed files with 11 additions and 3 deletions
  1. 11 3
      DotNet/Hotfix/Scenes/Game/Handler/R2G_LiveCommentHandler.cs

+ 11 - 3
DotNet/Hotfix/Scenes/Game/Handler/R2G_LiveCommentHandler.cs

@@ -1,4 +1,6 @@
-namespace ET.Server
+using System;
+
+namespace ET.Server
 {
     /// <summary>
     /// 抖音推送回调, 评论
@@ -54,11 +56,17 @@
 
             string[] pos = map.GetCurXY().Split(";");
 
+            Random rand = new Random();
+            float r = (float)Math.Sqrt(rand.Next(2304)) + 12;
+            double ang = rand.Next(40) / 180.0f * Math.PI + Math.PI/2.0f + Math.PI;
+            float x = int.Parse(pos[0]) + (float)(r * Math.Cos(ang));
+            float y = int.Parse(pos[1]) - (float)(r * Math.Sin(ang));
+
             Struct.MonsterUnit unit = new Struct.MonsterUnit();
             unit.id = templateId;
             unit.force = 1;
-            unit.x = int.Parse(pos[0]);
-            unit.y = int.Parse(pos[1]);
+            unit.x = (int)x;
+            unit.y = (int)y;
             unit.autoGuard = true;
 
             int objId = await map.AddUnits(unit, true);