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; } } }