Browse Source

【游戏服】增加塔死亡时,玩家单位转移战场的处理
增加玩家死亡示例处理

大爷 1 year ago
parent
commit
748fcbec33

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

@@ -1,6 +1,8 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using MongoDB.Driver;
+using System.Text.RegularExpressions;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 
@@ -48,14 +50,16 @@ namespace ET.Server
         /// </summary>
         /// <param name="self"></param>
         /// <param name="msg"></param>
-        public static void OnMessageEvent(this MapEventComponent self, JObject msg)
+        public static void OnMessageEvent(this MapEventComponent self, JObject json)
         {
-            switch (Convert.ToString(msg.SelectToken("msg")))
+            var msg = Convert.ToString(json.SelectToken("msg"));
+            switch (msg)
             {
                 case "Dead:Tower1":
                 {
                     Log.Debug($"塔1死亡事件...");
                     self.GetParent<Map>().DeadUnits.Add(1001);
+                    self.TransferUnitsToNewTower();
                     return;
                 }
                 case "Dead:Tower2":
@@ -71,6 +75,41 @@ namespace ET.Server
                     return;
                 }
             }
+            if (msg.StartsWith("Dead:{"))
+            {
+                //玩家单位死亡
+                Match m = Regex.Match(msg, "Dead:{(\\d+)}");
+                if (m.Groups.Count == 2)
+                {
+                    try
+                    {
+                        int objid = int.Parse(m.Groups[1].Value);
+                        //TODO: 处理玩家单位死亡
+                    }
+                    catch (Exception)
+                    {
+                        Log.Error("Illegal Dead msg");
+                    }
+                }
+            }
+            else if (msg.StartsWith("Revive:{"))
+            {
+                //TODO:处理玩家单位复活
+            }
+        }
+
+        private static void TransferUnitsToNewTower(this MapEventComponent self)
+        {
+            Map map = self.GetParent<Map>();
+            var mapid = map.Id.ToString();
+
+            int cnt = 0;
+            foreach(var player in map.UnitPlayers.Values)
+            {
+                //TODO: 转移坐标为当前战斗区域中的随机位置
+                map.GetXmdsManager().transferUnit(mapid, player.ObjId, 178f + (cnt++), 139f);
+            }
+            Log.Debug($"transfer unit: {cnt}");
         }
 
         /// <summary>

+ 158 - 0
DotNet/Model/IceGenerate/XmdsManager.cs

@@ -2143,6 +2143,9 @@ namespace BattleIce
     [_System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.6.4")]
     public delegate void Callback_XmdsManager_removePointUnit();
 
+    [_System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.6.4")]
+    public delegate void Callback_XmdsManager_transferUnit();
+
     [_System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.6.4")]
     public delegate void Callback_XmdsManager_removeItem();
 
@@ -2878,6 +2881,20 @@ namespace BattleIce
 
         void end_removePointUnit(Ice.AsyncResult r__);
 
+        void transferUnit(string instanceId, int unitObjectId, float x, float y);
+
+        void transferUnit(string instanceId, int unitObjectId, float x, float y, _System.Collections.Generic.Dictionary<string, string> ctx__);
+
+        Ice.AsyncResult<BattleIce.Callback_XmdsManager_transferUnit> begin_transferUnit(string instanceId, int unitObjectId, float x, float y);
+
+        Ice.AsyncResult<BattleIce.Callback_XmdsManager_transferUnit> begin_transferUnit(string instanceId, int unitObjectId, float x, float y, _System.Collections.Generic.Dictionary<string, string> ctx__);
+
+        Ice.AsyncResult begin_transferUnit(string instanceId, int unitObjectId, float x, float y, Ice.AsyncCallback cb__, object cookie__);
+
+        Ice.AsyncResult begin_transferUnit(string instanceId, int unitObjectId, float x, float y, _System.Collections.Generic.Dictionary<string, string> ctx__, Ice.AsyncCallback cb__, object cookie__);
+
+        void end_transferUnit(Ice.AsyncResult r__);
+
         void removeItem(string instanceId, int itemId);
 
         void removeItem(string instanceId, int itemId, _System.Collections.Generic.Dictionary<string, string> ctx__);
@@ -3035,6 +3052,8 @@ namespace BattleIce
 
         void removePointUnit_async(BattleIce.AMD_XmdsManager_removePointUnit cb__, string instanceId, int unitObjectId, Ice.Current current__);
 
+        void transferUnit_async(BattleIce.AMD_XmdsManager_transferUnit cb__, string instanceId, int unitObjectId, float x, float y, Ice.Current current__);
+
         void removeItem_async(BattleIce.AMD_XmdsManager_removeItem cb__, string instanceId, int itemId, Ice.Current current__);
 
         void changePlayerState_async(BattleIce.AMD_XmdsManager_changePlayerState cb__, string instanceId, string playerId, byte status, int time, Ice.Current current__);
@@ -3141,6 +3160,8 @@ namespace BattleIce
 
         void removePointUnit_async(BattleIce.AMD_XmdsManager_removePointUnit cb__, string instanceId, int unitObjectId);
 
+        void transferUnit_async(BattleIce.AMD_XmdsManager_transferUnit cb__, string instanceId, int unitObjectId, float x, float y);
+
         void removeItem_async(BattleIce.AMD_XmdsManager_removeItem cb__, string instanceId, int itemId);
 
         void changePlayerState_async(BattleIce.AMD_XmdsManager_changePlayerState cb__, string instanceId, string playerId, byte status, int time);
@@ -5006,6 +5027,21 @@ namespace BattleIce
             return end_transferToPointPos(begin_transferToPointPos(instanceId, playerId, point, setDirection, direction, context__, explicitCtx__, true, null, null));
         }
 
+        public void transferUnit(string instanceId, int unitObjectId, float x, float y)
+        {
+            this.transferUnit(instanceId, unitObjectId, x, y, null, false);
+        }
+
+        public void transferUnit(string instanceId, int unitObjectId, float x, float y, _System.Collections.Generic.Dictionary<string, string> ctx__)
+        {
+            this.transferUnit(instanceId, unitObjectId, x, y, ctx__, true);
+        }
+
+        private void transferUnit(string instanceId, int unitObjectId, float x, float y, _System.Collections.Generic.Dictionary<string, string> context__, bool explicitCtx__)
+        {
+            end_transferUnit(begin_transferUnit(instanceId, unitObjectId, x, y, context__, explicitCtx__, true, null, null));
+        }
+
         public void triggrBattleFunction(string playerId, int eventId, int value1, int valu2, int valu3, int valu4, int value5, int value6)
         {
             this.triggrBattleFunction(playerId, eventId, value1, valu2, valu3, valu4, value5, value6, null, false);
@@ -8636,6 +8672,66 @@ namespace BattleIce
             }
         }
 
+        public Ice.AsyncResult<BattleIce.Callback_XmdsManager_transferUnit> begin_transferUnit(string instanceId, int unitObjectId, float x, float y)
+        {
+            return begin_transferUnit(instanceId, unitObjectId, x, y, null, false, false, null, null);
+        }
+
+        public Ice.AsyncResult<BattleIce.Callback_XmdsManager_transferUnit> begin_transferUnit(string instanceId, int unitObjectId, float x, float y, _System.Collections.Generic.Dictionary<string, string> ctx__)
+        {
+            return begin_transferUnit(instanceId, unitObjectId, x, y, ctx__, true, false, null, null);
+        }
+
+        public Ice.AsyncResult begin_transferUnit(string instanceId, int unitObjectId, float x, float y, Ice.AsyncCallback cb__, object cookie__)
+        {
+            return begin_transferUnit(instanceId, unitObjectId, x, y, null, false, false, cb__, cookie__);
+        }
+
+        public Ice.AsyncResult begin_transferUnit(string instanceId, int unitObjectId, float x, float y, _System.Collections.Generic.Dictionary<string, string> ctx__, Ice.AsyncCallback cb__, object cookie__)
+        {
+            return begin_transferUnit(instanceId, unitObjectId, x, y, ctx__, true, false, cb__, cookie__);
+        }
+
+        private const string __transferUnit_name = "transferUnit";
+
+        public void end_transferUnit(Ice.AsyncResult r__)
+        {
+            end__(r__, __transferUnit_name);
+        }
+
+        private Ice.AsyncResult<BattleIce.Callback_XmdsManager_transferUnit> begin_transferUnit(string instanceId, int unitObjectId, float x, float y, _System.Collections.Generic.Dictionary<string, string> ctx__, bool explicitContext__, bool synchronous__, Ice.AsyncCallback cb__, object cookie__)
+        {
+            IceInternal.OnewayOutgoingAsync<BattleIce.Callback_XmdsManager_transferUnit> result__ = getOnewayOutgoingAsync<BattleIce.Callback_XmdsManager_transferUnit>(__transferUnit_name, transferUnit_completed__, cookie__);
+            if(cb__ != null)
+            {
+                result__.whenCompletedWithAsyncCallback(cb__);
+            }
+            try
+            {
+                result__.prepare(__transferUnit_name, Ice.OperationMode.Normal, ctx__, explicitContext__, synchronous__);
+                IceInternal.BasicStream os__ = result__.startWriteParams(Ice.FormatType.DefaultFormat);
+                os__.writeString(instanceId);
+                os__.writeInt(unitObjectId);
+                os__.writeFloat(x);
+                os__.writeFloat(y);
+                result__.endWriteParams();
+                result__.invoke();
+            }
+            catch(Ice.Exception ex__)
+            {
+                result__.abort(ex__);
+            }
+            return result__;
+        }
+
+        private void transferUnit_completed__(BattleIce.Callback_XmdsManager_transferUnit cb__)
+        {
+            if(cb__ != null)
+            {
+                cb__();
+            }
+        }
+
         public Ice.AsyncResult<BattleIce.Callback_XmdsManager_triggrBattleFunction> begin_triggrBattleFunction(string playerId, int eventId, int value1, int valu2, int valu3, int valu4, int value5, int value6)
         {
             return begin_triggrBattleFunction(playerId, eventId, value1, valu2, valu3, valu4, value5, value6, null, false, false, null, null);
@@ -9181,6 +9277,13 @@ namespace BattleIce
 
         public abstract void removePointUnit_async(BattleIce.AMD_XmdsManager_removePointUnit cb__, string instanceId, int unitObjectId, Ice.Current current__);
 
+        public void transferUnit_async(BattleIce.AMD_XmdsManager_transferUnit cb__, string instanceId, int unitObjectId, float x, float y)
+        {
+            transferUnit_async(cb__, instanceId, unitObjectId, x, y, Ice.ObjectImpl.defaultCurrent);
+        }
+
+        public abstract void transferUnit_async(BattleIce.AMD_XmdsManager_transferUnit cb__, string instanceId, int unitObjectId, float x, float y, Ice.Current current__);
+
         public void removeItem_async(BattleIce.AMD_XmdsManager_removeItem cb__, string instanceId, int itemId)
         {
             removeItem_async(cb__, instanceId, itemId, Ice.ObjectImpl.defaultCurrent);
@@ -10315,6 +10418,32 @@ namespace BattleIce
             return Ice.DispatchStatus.DispatchAsync;
         }
 
+        [_System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011")]
+        public static Ice.DispatchStatus transferUnit___(XmdsManager obj__, IceInternal.Incoming inS__, Ice.Current current__)
+        {
+            Ice.ObjectImpl.checkMode__(Ice.OperationMode.Normal, current__.mode);
+            IceInternal.BasicStream is__ = inS__.startReadParams();
+            string instanceId;
+            int unitObjectId;
+            float x;
+            float y;
+            instanceId = is__.readString();
+            unitObjectId = is__.readInt();
+            x = is__.readFloat();
+            y = is__.readFloat();
+            inS__.endReadParams();
+            AMD_XmdsManager_transferUnit cb__ = new _AMD_XmdsManager_transferUnit(inS__);
+            try
+            {
+                obj__.transferUnit_async(cb__, instanceId, unitObjectId, x, y, current__);
+            }
+            catch(_System.Exception ex__)
+            {
+                cb__.ice_exception(ex__);
+            }
+            return Ice.DispatchStatus.DispatchAsync;
+        }
+
         [_System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011")]
         public static Ice.DispatchStatus removeItem___(XmdsManager obj__, IceInternal.Incoming inS__, Ice.Current current__)
         {
@@ -10465,6 +10594,7 @@ namespace BattleIce
             "removeUnit",
             "revivePlayer",
             "transferToPointPos",
+            "transferUnit",
             "triggrBattleFunction"
         };
 
@@ -10695,6 +10825,10 @@ namespace BattleIce
                     return transferToPointPos___(this, inS__, current__);
                 }
                 case 54:
+                {
+                    return transferUnit___(this, inS__, current__);
+                }
+                case 55:
                 {
                     return triggrBattleFunction___(this, inS__, current__);
                 }
@@ -12044,6 +12178,30 @@ namespace BattleIce
         }
     }
 
+    [_System.Runtime.InteropServices.ComVisible(false)]
+    [_System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.6.4")]
+    public interface AMD_XmdsManager_transferUnit : Ice.AMDCallback
+    {
+        void ice_response();
+    }
+
+    [_System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.6.4")]
+    class _AMD_XmdsManager_transferUnit : IceInternal.IncomingAsync, AMD_XmdsManager_transferUnit
+    {
+        public _AMD_XmdsManager_transferUnit(IceInternal.Incoming inc) : base(inc)
+        {
+        }
+
+        public void ice_response()
+        {
+            if(validateResponse__(true))
+            {
+                writeEmptyParams__();
+                response__();
+            }
+        }
+    }
+
     [_System.Runtime.InteropServices.ComVisible(false)]
     [_System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.6.4")]
     public interface AMD_XmdsManager_removeItem : Ice.AMDCallback

+ 10 - 10
DotNet/Model/IceGenerate/ZoneManager.cs

@@ -126,14 +126,14 @@ namespace BattleIce
         /// <summary>
         /// 场景管理器相关协议
         /// </summary>
-
+        
         int setCallback(Ice.Identity ident, string srvUUID);
 
         /// <summary>
         /// 场景管理器相关协议
         /// </summary>
         /// <param name="ctx__">The Context map to send with the invocation.</param>
-
+        
         int setCallback(Ice.Identity ident, string srvUUID, _System.Collections.Generic.Dictionary<string, string> ctx__);
 
         /// <summary>
@@ -175,14 +175,14 @@ namespace BattleIce
         /// <summary>
         /// 场景副本相关协议
         /// </summary>
-
+        
         int createZoneRequest(string playerId, string gameServerId, int mapTemplateId, string instanceId, bool force, string data);
 
         /// <summary>
         /// 场景副本相关协议
         /// </summary>
         /// <param name="ctx__">The Context map to send with the invocation.</param>
-
+        
         int createZoneRequest(string playerId, string gameServerId, int mapTemplateId, string instanceId, bool force, string data, _System.Collections.Generic.Dictionary<string, string> ctx__);
 
         /// <summary>
@@ -238,14 +238,14 @@ namespace BattleIce
         /// <summary>
         /// 玩家相关协议
         /// </summary>
-
+        
         void clearAllPlayersRequest();
 
         /// <summary>
         /// 玩家相关协议
         /// </summary>
         /// <param name="ctx__">The Context map to send with the invocation.</param>
-
+        
         void clearAllPlayersRequest(_System.Collections.Generic.Dictionary<string, string> ctx__);
 
         /// <summary>
@@ -405,7 +405,7 @@ namespace BattleIce
         /// 场景管理器相关协议
         /// </summary>
         /// <param name="current__">The Current object for the invocation.</param>
-
+        
         int setCallback(Ice.Identity ident, string srvUUID, Ice.Current current__);
 
         /// <summary>
@@ -445,7 +445,7 @@ namespace BattleIce
         /// <summary>
         /// 场景管理器相关协议
         /// </summary>
-
+        
         int setCallback(Ice.Identity ident, string srvUUID);
 
         /// <summary>
@@ -1908,7 +1908,7 @@ namespace BattleIce
 
         #region Slice type-related members
 
-        public static new readonly string[] ids__ =
+        public static new readonly string[] ids__ = 
         {
             "::BattleIce::ZoneManagerCallback",
             "::Ice::Object"
@@ -2119,7 +2119,7 @@ namespace BattleIce
 
         #region Slice type-related members
 
-        public static new readonly string[] ids__ =
+        public static new readonly string[] ids__ = 
         {
             "::BattleIce::ZoneManager",
             "::Ice::Object"