Pārlūkot izejas kodu

【增加】游戏服抖音api回调响应(点赞增加等级,评论"守护家园"增加单位)

johnclot69 1 gadu atpakaļ
vecāks
revīzija
da80a818ad

+ 13 - 0
Config/Proto/InnerMessage_S_20001.proto

@@ -161,3 +161,16 @@ message M2M_UnitTransferResponse // IActorResponse
 	int32 Error = 2;
 	string Message = 3;
 }
+
+message R2G_AddUnitsToMap // IActorMessage
+{
+	string OpenId = 1;
+	int64 RoomId = 2;
+}
+
+message R2G_AddLevel // IActorMessage
+{
+	string OpenId = 1;
+	int64 RoomId = 2;
+	int32 Likes = 3;
+}

+ 6 - 0
Config/Proto/OuterMessage_C_10001.proto

@@ -341,4 +341,10 @@ message R2C_Disconnect // IActorMessage
 	int32 RpcId = 1;
 	int32 Error = 2;
 	string Message = 3;
+}
+
+message HttpDouyinApiCallbackResponse
+{
+	int32 Error = 1;
+	string Message = 2;
 }

+ 7 - 1
DotNet/Hotfix/Helper/HttpHelper.cs

@@ -1,10 +1,16 @@
-using System.Net;
+using System.IO;
+using System.Net;
 using System.Text;
 
 namespace ET.Server
 {
     public static class HttpHelper
     {
+        public static async ETTask<string> GetBodyParameter(HttpListenerContext context)
+        {
+            return await new StreamReader(context.Request.InputStream).ReadToEndAsync();
+        }
+
         public static void Response(HttpListenerContext context, object response)
         {
             byte[] bytes = JsonHelper.ToJson(response).ToUtf8();

+ 2 - 1
DotNet/Hotfix/Helper/MapHelper.cs

@@ -236,7 +236,8 @@ namespace ET.Server
             {
                 Log.Info($"创建Area场景:{map.MapId}, instanceId:{instanceId}, srvId:" + map.LogicServerId);
                 map.BindBattleServer(player, bsServerId);
-                scene.GetComponent<GameMapComponent>().Add(map);
+                // todo 测试用roomId
+                scene.GetComponent<GameMapComponent>().Add(map, 10098);
             }
             else
             {

+ 15 - 2
DotNet/Hotfix/Scenes/Game/GameMapComponentSystem.cs

@@ -24,15 +24,16 @@ namespace ET.Server
             /// 游戏服场景组件销毁
             /// </summary>
             /// <param name="self"></param>
-            /// <exception cref="NotImplementedException"></exception>
             protected override void Destroy(GameMapComponent self)
             {
             }
         }
 
-        public static void Add(this GameMapComponent self, Map map)
+        public static void Add(this GameMapComponent self, Map map, long roomId)
         {
             self.allMaps.TryAdd(map.Id, map);
+            // 映射一下roomId与instanceId的关系
+            self.rooms.TryAdd(roomId, map.Id);
         }
 
         public static Map Get(this GameMapComponent self, long instanceId)
@@ -50,5 +51,17 @@ namespace ET.Server
         {
             return self.allMaps.Values.ToArray();
         }
+
+        public static Map GetMapByRoomId(this GameMapComponent self, long roomId)
+        {
+            long instanceId = self.rooms[roomId];
+
+            if (instanceId > 0)
+            {
+                return self.Get(instanceId);
+            }
+
+            return null;
+        }
     }
 }

+ 6 - 5
DotNet/Hotfix/Scenes/Game/Handler/C2G_AddUnitsToMapHandler.cs

@@ -51,11 +51,12 @@ namespace ET.Server
             }
             unit.autoGuard = true;
 
-            int objId = await player.Map.AddUnits(unit, false);
-            if (objId > 0 && !player.Map.UnitObjIds.Contains(objId))
-            {
-                player.Map.UnitObjIds.Add(objId);
-            }
+            int objId = await player.Map.AddUnits(unit, true);
+            // 临时openId
+            string _openId = player.GetComponent<PlayerDataComponent>().Data.Id.ToString();
+
+            player.Map.AddUnitObjId(_openId, objId);
+            player.Map.AddUnitPlayer(_openId, request.UnitId);
 
             reply();
         }

+ 1 - 10
DotNet/Hotfix/Scenes/Game/Handler/C2G_RemoveUnitHandler.cs

@@ -26,17 +26,8 @@ namespace ET.Server
                 reply();
                 return;
             }
-            // 配置是否能找到
-            Monster prop = MonsterCategory.Instance.Get(request.UnitId);
-            if (prop == null)
-            {
-                Log.Debug($"添加单位出错, 未找到配置...unitId={request.UnitId}, playerId={player.GetId()}");
-                response.Error = ErrorCode.ERR_ConfigError;
-                reply();
-                return;
-            }
 
-            await player.Map.RemoveUnit(request.UnitId);
+            await player.Map.RemovePointUnit(request.UnitId);
 
             reply();
         }

+ 90 - 0
DotNet/Hotfix/Scenes/Game/Handler/R2G_AddLevelHandler.cs

@@ -0,0 +1,90 @@
+namespace ET.Server
+{
+    /// <summary>
+    /// 抖音api http回调, 点赞10次增加等级
+    /// </summary>
+    [ActorMessageHandler(SceneType.Game)]
+    public class R2G_AddLevelHandler : AMActorHandler<Scene, R2G_AddLevel>
+    {
+        protected override async ETTask Run(Scene scene, R2G_AddLevel request)
+        {
+            // 房间是否存在
+            Map map = scene.GetComponent<GameMapComponent>().GetMapByRoomId(request.RoomId);
+
+            if (map == null)
+            {
+                Log.Debug($"未找到房间...roomId={request.RoomId}");
+                return;
+            }
+
+            // 数据是否存在
+            if (map.GetUnitTemplateId(request.OpenId) == 0)
+            {
+                Log.Debug($"未找到单位玩家数据...openId={request.OpenId}");
+                return;
+            }
+
+            // 总点赞数
+            int totelLikes = 0;
+
+            // 累计增加点赞数
+            if (map.UnitPlayerLikes.TryGetValue(request.OpenId, out int likes))
+            {
+                totelLikes = likes + request.Likes;
+                map.UnitPlayerLikes[request.OpenId] = totelLikes;
+            }
+            else
+            {
+                totelLikes = request.Likes;
+                map.UnitPlayerLikes.Add(request.OpenId, totelLikes);
+            }
+
+            int initialLevel = 1; // 初始等级
+            int maxLevel = 3; // 等级上限
+            int level = initialLevel; // 玩家等级
+
+            int levelUpCount = totelLikes / 10; // 计算升级次数
+
+            // 根据升级次数更新等级
+            for (int i = 0; i < levelUpCount; i++)
+            {
+                level++; // 等级加1
+
+                // 如果等级超过上限,将等级设置为上限
+                if (level > maxLevel)
+                {
+                    level = maxLevel;
+                    break;
+                }
+            }
+
+            // 模板id
+            int oldTemplateId = map.GetUnitTemplateId(request.OpenId);
+            int newTemplateId = ((oldTemplateId / 10) * 10) + level;
+
+            if (oldTemplateId != newTemplateId)
+            {
+                // 当前战斗服objId
+                int curObjId = map.GetUnitObjId(request.OpenId);
+                // 移除原单位
+                await map.RemovePointUnit(curObjId);
+
+                string[] pos = map.GetCurXY().Split(";");
+
+                Struct.MonsterUnit unit = new Struct.MonsterUnit();
+                unit.id = newTemplateId;
+                unit.force = 1;
+                unit.x = int.Parse(pos[0]);
+                unit.y = int.Parse(pos[1]);
+                unit.autoGuard = true;
+
+                curObjId = await map.AddUnits(unit, true);
+
+                map.AddUnitObjId(request.OpenId, curObjId);
+                map.AddUnitPlayer(request.OpenId, newTemplateId);
+            }
+
+            await ETTask.CompletedTask;
+        }
+    }
+}

+ 42 - 0
DotNet/Hotfix/Scenes/Game/Handler/R2G_AddUnitsToMapHandler.cs

@@ -0,0 +1,42 @@
+namespace ET.Server
+{
+    /// <summary>
+    /// 抖音api http回调, 评论添加玩家
+    /// </summary>
+    [ActorMessageHandler(SceneType.Game)]
+    public class R2G_AddUnitsToMapHandler: AMActorHandler<Scene, R2G_AddUnitsToMap>
+    {
+        protected override async ETTask Run(Scene scene, R2G_AddUnitsToMap request)
+        {
+            // 初始模板id
+            int[] units = new int[] { 101, 111, 121, 131 };
+
+            int templateId = RandomGenerator.RandomArray(units);
+
+            // 房间是否存在
+            Map map = scene.GetComponent<GameMapComponent>().GetMapByRoomId(request.RoomId);
+
+            if (map == null)
+            {
+                Log.Debug($"未找到房间...");
+                return;
+            }
+
+            string[] pos = map.GetCurXY().Split(";");
+
+            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.autoGuard = true;
+
+            int objId = await map.AddUnits(unit, true);
+
+            map.AddUnitObjId(request.OpenId, objId);
+            map.AddUnitPlayer(request.OpenId, templateId);
+
+            await ETTask.CompletedTask;
+        }
+    }
+}

+ 54 - 32
DotNet/Hotfix/Scenes/Game/Map/MapEventComponentSystem.cs

@@ -81,7 +81,7 @@ namespace ET.Server
                     Monster monsterProp = MonsterCategory.Instance.Get(unitTemplateId);
                     if (monsterProp == null)
                     {
-                        Log.Error($"unitDead not fount montster : {unitTemplateId}, {map.MapId}, {msg}");
+                        Log.Error($"单位死亡...找不到怪物配置 : unitTemplateId={unitTemplateId}, MapId={map.MapId}, data={msg}");
                         return;
                     }
 
@@ -94,14 +94,34 @@ namespace ET.Server
                         }
                     }
                     // 如果是单位玩家
-                    /*if (map.UnitObjIds.Contains(objId) && !map.IsGameOver())
+                    if (map.UnitObjIds.ContainsValue(objId) && !map.IsGameOver())
                     {
-                        Log.Debug($"单位死亡...objId={objId}, unitTemplateId={unitTemplateId}, posX={Convert.ToInt32(msg.SelectToken("posX"))}, posY={Convert.ToInt32(msg.SelectToken("posY"))}");
+                        Log.Debug($"单位死亡...objId={objId}, unitTemplateId={unitTemplateId}, posX={posX}, posY={posY}");
 
-                        map.UnitObjIds.Remove(objId);
+                        string unitOpenId = null;
 
-                        map.GetComponent<MapReliveTimeComponent>().ReliveDatas.Add(new Struct.UnitPlayerReliveData(map, unitTemplateId, TimeHelper.ServerNow() + 5000, posX, posY));
-                    }*/
+                        foreach (string key in from key in map.UnitObjIds.Keys where !string.IsNullOrEmpty(key) let value = map.UnitObjIds[key] where value >= 0 && value == objId select key)
+                        {
+                            unitOpenId = key;
+                            break;
+                        }
+
+                        if (unitOpenId != null)
+                        {
+                            unitTemplateId = map.GetUnitTemplateId(unitOpenId);
+
+                            if (unitTemplateId == 0)
+                            {
+                                int[] units = new int[] { 101, 111, 121 };
+
+                                unitTemplateId = RandomGenerator.RandomArray(units);
+                            }
+
+                            map.GetComponent<MapReliveTimeComponent>().ReliveDatas.Add(new Struct.UnitPlayerReliveData(map, unitOpenId, unitTemplateId, TimeHelper.ServerNow() + 5000, posX, posY));
+
+                            map.UnitObjIds.Remove(unitOpenId);
+                        }
+                    }
 
                     break;
                 case 1:
@@ -187,41 +207,43 @@ namespace ET.Server
             List<Struct.BattleReports> list = new List<Struct.BattleReports>();
 
             var battleReports = JsonConvert.DeserializeObject<List<Struct.BattleReports>>(data);
-            if (battleReports is { Count: > 0 })
+            if (battleReports is not { Count: > 0 })
             {
-                foreach (Struct.BattleReports report in battleReports)
+                return;
+            }
+
+            foreach (Struct.BattleReports report in battleReports)
+            {
+                // 过滤一下非我方单位
+                if (report.Force != 1)
                 {
-                    // 过滤一下非我方单位
-                    if (report.Force != 1)
-                    {
-                        continue;
-                    }
+                    continue;
+                }
 
-                    uint ID = report.ID;
-                    long PlayerUUID = string.IsNullOrEmpty(report.PlayerUUID)? 0 : Convert.ToInt64(report.PlayerUUID);
-                    int TemplateID = report.TemplateId;
-                    int Force = report.Force;
-                    int TotalDamage = report.TotalDamage;
+                uint ID = report.ID;
+                long PlayerUUID = string.IsNullOrEmpty(report.PlayerUUID)? 0 : Convert.ToInt64(report.PlayerUUID);
+                int TemplateID = report.TemplateId;
+                int Force = report.Force;
+                int TotalDamage = report.TotalDamage;
 
-                    string name = "";
-                    if (PlayerUUID > 0)
-                    {
-                        name = "玩家-" + TemplateID;
-                    }
-                    else
+                string name = "";
+                if (PlayerUUID > 0)
+                {
+                    name = "玩家-" + TemplateID;
+                }
+                else
+                {
+                    if (TemplateID > 0)
                     {
-                        if (TemplateID > 0)
+                        Monster prop = MonsterCategory.Instance.Get(TemplateID);
+                        if (prop != null)
                         {
-                            Monster prop = MonsterCategory.Instance.Get(TemplateID);
-                            if (prop != null)
-                            {
-                                name = prop.Name;
-                            }
+                            name = prop.Name;
                         }
                     }
-
-                    list.Add(new Struct.BattleReports(ID, report.PlayerUUID, TemplateID, name, Force, TotalDamage));
                 }
+
+                list.Add(new Struct.BattleReports(ID, report.PlayerUUID, TemplateID, name, Force, TotalDamage));
             }
 
             map.GetComponent<MapRankComponent>().UpdateRank(list, map);

+ 3 - 5
DotNet/Hotfix/Scenes/Game/Map/MapReliveTimeComponentSystem.cs

@@ -45,12 +45,10 @@ namespace ET.Server
                     unit.y = data.y;
                     unit.autoGuard = true;
 
-                    int objId = data.Map.AddUnits(unit, false).GetResult();
+                    int objId = data.Map.AddUnits(unit, true).GetResult();
 
-                    if (objId > 0 && !data.Map.UnitObjIds.Contains(objId) && !data.Map.IsGameOver())
-                    {
-                        data.Map.UnitObjIds.Add(objId);
-                    }
+                    data.Map.AddUnitObjId(data.OpenId, objId);
+                    data.Map.AddUnitPlayer(data.OpenId, data.ID);
 
                     self.ReliveDatas.Remove(data);
                 }

+ 116 - 19
DotNet/Hotfix/Scenes/Game/Map/MapSystem.cs

@@ -26,7 +26,10 @@ namespace ET.Server
                 self.MapId = Convert.ToInt32(opts.SelectToken("areaId"));
                 self.Prop = MapConfigCategory.Instance.Get(self.MapId);
                 self.Type = self.Prop.Type;
-                self.UnitObjIds = new List<int>();
+                self.UnitPlayers = new Dictionary<string, int>();
+                self.UnitObjIds = new Dictionary<string, int>();
+                self.UnitPlayerLikes = new Dictionary<string, int>();
+
                 // 场景事件组件
                 self.AddComponent<MapEventComponent>();
                 // 场景复活组件
@@ -153,37 +156,43 @@ namespace ET.Server
         }
 
         /** 创建单位 **/
-        public static async ETTask<int> AddUnits(this Map self, string instanceId, string data)
+        public static async ETTask<int> AddUnits(this Map self, List<Struct.MonsterUnit> data, bool needReturn)
         {
-            await ETTask.CompletedTask;
-            return self.GetXmdsManager().addUnits(instanceId, data);
-        }
-
-        /** 创建单位 **/
-        public static async ETTask<int> AddUnits(this Map self, Struct.MonsterUnit unit, bool needReturn)
-        {
-            List<Struct.MonsterUnit> listData = new List<Struct.MonsterUnit>();
-            listData.Add(unit);
+            if (data.Count <= 0)
+            {
+                return 0;
+            }
 
             int addUnitsResult = 0;
-            int objId = 0;
 
             if (needReturn) {
-                addUnitsResult = self.GetXmdsManager().addUnits(self.Id.ToString().Trim(), JsonConvert.SerializeObject(listData, Formatting.Indented));
-                Log.Info($"addUnits needReturn : mapId={self.MapId}, instanceId={self.Id.ToString().Trim()}, data={listData}, add units result={addUnitsResult}");
+                addUnitsResult = self.GetXmdsManager().addUnits(self.Id.ToString().Trim(), JsonConvert.SerializeObject(data, Formatting.Indented));
+                Log.Info($"addUnits needReturn : mapId={self.MapId}, instanceId={self.Id.ToString().Trim()}, data={data}, add units result={addUnitsResult}");
             } else
             {
-                objId = await self.AddUnits(self.Id.ToString().Trim(), JsonConvert.SerializeObject(listData, Formatting.Indented));
+                int objId = self.GetXmdsManager().addUnits(self.Id.ToString().Trim(), JsonConvert.SerializeObject(data, Formatting.Indented));
                 Log.Info($"addUnits: mapId={self.MapId}, instanceId={self.Id.ToString().Trim()}, objId={objId}");
             }
 
-            return objId;
+            await ETTask.CompletedTask;
+            return addUnitsResult;
+        }
+
+        public static async ETTask<int> AddUnits(this Map self, Struct.MonsterUnit data, bool needReturn)
+        {
+            List<Struct.MonsterUnit> listData = new List<Struct.MonsterUnit>();
+            listData.Add(data);
+            return await self.AddUnits(listData, needReturn);
         }
 
-        /** 移除单位 **/
-        public static async ETTask RemoveUnit(this Map self, int unitId)
+        /// <summary>
+        /// 移除单位,战斗服创建的unit
+        /// </summary>
+        /// <param name="self"></param>
+        /// <param name="objectId"></param>
+        public static async ETTask RemovePointUnit(this Map self, int objectId)
         {
-            self.GetXmdsManager().removeUnit(self.Id.ToString().Trim(), unitId);
+            self.GetXmdsManager().removePointUnit(self.Id.ToString().Trim(), objectId);
             await ETTask.CompletedTask;
         }
 
@@ -212,5 +221,93 @@ namespace ET.Server
         {
             return self.IsGameOver;
         }
+
+        /// <summary>
+        /// 增加单位玩家
+        /// </summary>
+        /// <param name="self"></param>
+        /// <param name="openId"></param>
+        /// <param name="objId"></param>
+        public static void AddUnitObjId(this Map self, string openId, int objId)
+        {
+            if (objId <= 0 || self.IsGameOver())
+            {
+                return;
+            }
+
+            if (!self.UnitObjIds.TryAdd(openId, objId))
+            {
+                self.UnitObjIds[openId] = objId;
+            }
+        }
+
+        /// <summary>
+        /// 获取单位玩家objId
+        /// </summary>
+        /// <param name="self"></param>
+        /// <param name="openId"></param>
+        public static int GetUnitObjId(this Map self, string openId)
+        {
+            if (self.UnitObjIds.TryGetValue(openId, out int objId))
+            {
+                return objId;
+            }
+
+            return 0;
+        }
+
+        /// <summary>
+        /// 添加单位玩家
+        /// </summary>
+        /// <param name="self"></param>
+        /// <param name="openId"></param>
+        /// <param name="templateId"></param>
+        public static void AddUnitPlayer(this Map self, string openId, int templateId)
+        {
+            if (templateId <= 0 || self.IsGameOver())
+            {
+                return;
+            }
+
+            if (!self.UnitPlayers.TryAdd(openId, templateId))
+            {
+                self.UnitPlayers[openId] = templateId;
+            }
+        }
+
+        /// <summary>
+        /// 获取单位玩家模板id
+        /// </summary>
+        /// <param name="self"></param>
+        /// <param name="openId"></param>
+        /// <returns></returns>
+        public static int GetUnitTemplateId(this Map self, string openId)
+        {
+            if (self.UnitPlayers.TryGetValue(openId, out int templateId))
+            {
+                return templateId;
+            }
+
+            return 0;
+        }
+
+        /// <summary>
+        /// 获取当前坐标xy
+        /// </summary>
+        /// <param name="self"></param>
+        /// <returns></returns>
+        public static string GetCurXY(this Map self)
+        {
+            return self.DeadUnits.Count switch
+            {
+                // 1塔位置
+                0 => "230;85",
+                // 1塔挂了,2塔位置
+                1 when self.DeadUnits.Contains(1001) => "150;85",
+                // 1塔2塔挂了,3塔位置
+                2 when self.DeadUnits.Contains(1001) && self.DeadUnits.Contains(1002) => "70;85",
+                _ => "230;85"
+            };
+        }
     }
 }

+ 116 - 0
DotNet/Hotfix/Scenes/Router/HttpDouyinApiCallbackHandler.cs

@@ -0,0 +1,116 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using Newtonsoft.Json.Linq;
+
+namespace ET.Server
+{
+    /// <summary>
+    /// 抖音api回调, 评论添加玩家
+    /// </summary>
+    [HttpHandler(SceneType.RouterManager, "/addPlayer")]
+    public class HttpCommentHandler: IHttpHandler
+    {
+        public async ETTask Handle(Entity domain, HttpListenerContext context)
+        {
+            Log.Debug($"收到http 评论添加玩家回调...");
+
+            HttpDouyinApiCallbackResponse response = new HttpDouyinApiCallbackResponse();
+
+            string bodyStr = await HttpHelper.GetBodyParameter(context);
+            // 判断body是否为空
+            if (string.IsNullOrEmpty(bodyStr))
+            {
+                response.Error = ErrorCode.ERR_ParameterError;
+                response.Message = "参数错误";
+                HttpHelper.Response(context, response);
+                return;
+            }
+
+            JObject parameter = JObject.Parse(bodyStr);
+
+            string openId = Convert.ToString(parameter.SelectToken("openId"));
+            long roomId = Convert.ToInt64(parameter.SelectToken("roomId"));
+            int serverId = Convert.ToInt32(parameter.SelectToken("serverId"));
+
+            Log.Debug($"body参数: openid={openId}, roomId={roomId}, serverId={serverId}");
+            // 判断参数
+            if (string.IsNullOrEmpty(openId) || roomId <= 0 || serverId <= 0)
+            {
+                response.Error = ErrorCode.ERR_ParameterError;
+                response.Message = "参数错误";
+                HttpHelper.Response(context, response);
+                return;
+            }
+
+            List<StartSceneConfig> list = RealmGateAddressHelper.GetAllGame(1);
+
+            foreach (StartSceneConfig config in list.Where(config => config != null && config.Id == serverId))
+            {
+                for (int i = 1; i <= 4; i++)
+                {
+                    MessageHelper.SendActor(config.InstanceId, new R2G_AddUnitsToMap() { OpenId = (i * 100).ToString(), RoomId = roomId});
+                }
+                break;
+            }
+
+            HttpHelper.Response(context, response);
+            await ETTask.CompletedTask;
+        }
+    }
+
+    /// <summary>
+    /// 抖音api回调, 点赞10次增加等级
+    /// </summary>
+    [HttpHandler(SceneType.RouterManager, "/like")]
+    public class HttpLikeHandler: IHttpHandler
+    {
+        public async ETTask Handle(Entity domain, HttpListenerContext context)
+        {
+            Log.Debug($"收到http 点赞10次增加等级回调...");
+
+            HttpDouyinApiCallbackResponse response = new HttpDouyinApiCallbackResponse();
+
+            string bodyStr = await HttpHelper.GetBodyParameter(context);
+
+            if (string.IsNullOrEmpty(bodyStr))
+            {
+                response.Error = ErrorCode.ERR_ParameterError;
+                response.Message = "参数错误";
+                HttpHelper.Response(context, response);
+                return;
+            }
+
+            JObject parameter = JObject.Parse(bodyStr);
+
+            string openId = Convert.ToString(parameter.SelectToken("openId"));
+            long roomId = Convert.ToInt64(parameter.SelectToken("roomId"));
+            int serverId = Convert.ToInt32(parameter.SelectToken("serverId"));
+            // 点赞数
+            int likes = Convert.ToInt32(parameter.SelectToken("likes"));
+            likes = 30;
+
+            Log.Debug($"body参数: openid={openId}, roomId={roomId}, serverId={serverId}, likes={likes}");
+            // 判断参数
+            if (string.IsNullOrEmpty(openId) || roomId <= 0 || serverId <= 0 || likes < 0)
+            {
+                response.Error = ErrorCode.ERR_ParameterError;
+                response.Message = "参数错误";
+                HttpHelper.Response(context, response);
+                return;
+            }
+
+            List<StartSceneConfig> list = RealmGateAddressHelper.GetAllGame(1);
+
+            foreach (StartSceneConfig config in list.Where(config => config != null && config.Id == serverId))
+            {
+                MessageHelper.SendActor(config.InstanceId, new R2G_AddLevel() { OpenId = openId, RoomId = roomId, Likes = likes});
+                break;
+            }
+
+            HttpHelper.Response(context, response);
+            await ETTask.CompletedTask;
+        }
+    }
+}

+ 5 - 1
DotNet/Model/Const/Struct.cs

@@ -260,6 +260,9 @@
             /** 复活场景 **/
             public Map Map { get; set; }
 
+            /** 复活的openId **/
+            public string OpenId { get; set; }
+
             /** 复活单位模板id **/
             public int ID { get; set; }
 
@@ -276,9 +279,10 @@
             {
             }
 
-            public UnitPlayerReliveData(Map map, int id, long time, int x, int y)
+            public UnitPlayerReliveData(Map map, string openId, int id, long time, int x, int y)
             {
                 this.Map = map;
+                this.OpenId = openId;
                 this.ID = id;
                 this.ReliveTime = time;
                 this.x = x;

+ 29 - 0
DotNet/Model/Generate/Message/InnerMessage_S_20001.cs

@@ -341,6 +341,33 @@ namespace ET
 
 	}
 
+	[Message(InnerMessage.R2G_AddUnitsToMap)]
+	[ProtoContract]
+	public partial class R2G_AddUnitsToMap: ProtoObject, IActorMessage
+	{
+		[ProtoMember(1)]
+		public string OpenId { get; set; }
+
+		[ProtoMember(2)]
+		public long RoomId { get; set; }
+
+	}
+
+	[Message(InnerMessage.R2G_AddLevel)]
+	[ProtoContract]
+	public partial class R2G_AddLevel: ProtoObject, IActorMessage
+	{
+		[ProtoMember(1)]
+		public string OpenId { get; set; }
+
+		[ProtoMember(2)]
+		public long RoomId { get; set; }
+
+		[ProtoMember(3)]
+		public int Likes { get; set; }
+
+	}
+
 	public static class InnerMessage
 	{
 		 public const ushort ObjectQueryRequest = 20002;
@@ -365,5 +392,7 @@ namespace ET
 		 public const ushort G2M_SessionDisconnect = 20021;
 		 public const ushort M2M_UnitTransferRequest = 20022;
 		 public const ushort M2M_UnitTransferResponse = 20023;
+		 public const ushort R2G_AddUnitsToMap = 20024;
+		 public const ushort R2G_AddLevel = 20025;
 	}
 }

+ 13 - 0
DotNet/Model/Generate/Message/OuterMessage_C_10001.cs

@@ -709,6 +709,18 @@ namespace ET
 
 	}
 
+	[Message(OuterMessage.HttpDouyinApiCallbackResponse)]
+	[ProtoContract]
+	public partial class HttpDouyinApiCallbackResponse: ProtoObject
+	{
+		[ProtoMember(1)]
+		public int Error { get; set; }
+
+		[ProtoMember(2)]
+		public string Message { get; set; }
+
+	}
+
 	public static class OuterMessage
 	{
 		 public const ushort HttpGetRouterResponse = 10002;
@@ -758,5 +770,6 @@ namespace ET
 		 public const ushort C2G_Benchmark = 10046;
 		 public const ushort G2C_Benchmark = 10047;
 		 public const ushort R2C_Disconnect = 10048;
+		 public const ushort HttpDouyinApiCallbackResponse = 10049;
 	}
 }

+ 3 - 0
DotNet/Model/Scenes/Game/GameMapComponent.cs

@@ -13,5 +13,8 @@ namespace ET.Server
         /** 场景集合 key:instanceId, value:map **/
         [StaticField]
         public Dictionary<long, Map> allMaps = new Dictionary<long, Map>();
+        /** room集合 key:roomId, value:instanceId **/
+        [StaticField]
+        public Dictionary<long, long> rooms = new Dictionary<long, long>();
     }
 }

+ 8 - 4
DotNet/Model/Scenes/Game/Map/Map.cs

@@ -21,12 +21,16 @@ namespace ET.Server
         public int LogicServerId { get; set; }
         /** 副本创建时间 **/
         public long createTime { get; set; }
-        /** 场景里的角色 **/
+        /** 场景里的角色(主播) [key:playerId, value:主播玩家实体] **/
         [StaticField]
         public Dictionary<long, WNPlayer> Players = new Dictionary<long, WNPlayer>();
-        /** 场景中单位玩家objId列表 **/
-        public List<int> UnitObjIds { get; set; }
-        /** 死亡的单位 **/
+        /** 场景里的单位玩家 [key:openId, value:模板id] **/
+        public Dictionary<string, int> UnitPlayers { get; set; }
+        /** 场景中单位玩家objId列表 [key:openId, value:战斗服objId] **/
+        public Dictionary<string, int> UnitObjIds { get; set; }
+        /** 场景中单位玩家点赞数 [key:openId, value:点赞数] **/
+        public Dictionary<string, int> UnitPlayerLikes { get; set; }
+        /** 死亡的单位(塔) **/
         [StaticField]
         public List<int> DeadUnits = new List<int>();
         /** 游戏结束标记 **/

+ 13 - 0
Unity/Assets/Scripts/Codes/Model/Client/Generate/Message/OuterMessage_C_10001.cs

@@ -709,6 +709,18 @@ namespace ET
 
 	}
 
+	[Message(OuterMessage.HttpDouyinApiCallbackResponse)]
+	[ProtoContract]
+	public partial class HttpDouyinApiCallbackResponse: ProtoObject
+	{
+		[ProtoMember(1)]
+		public int Error { get; set; }
+
+		[ProtoMember(2)]
+		public string Message { get; set; }
+
+	}
+
 	public static class OuterMessage
 	{
 		 public const ushort HttpGetRouterResponse = 10002;
@@ -758,5 +770,6 @@ namespace ET
 		 public const ushort C2G_Benchmark = 10046;
 		 public const ushort G2C_Benchmark = 10047;
 		 public const ushort R2C_Disconnect = 10048;
+		 public const ushort HttpDouyinApiCallbackResponse = 10049;
 	}
 }