using System;
namespace ET.Server
{
///
/// 抖音推送回调, 评论
///
[ActorMessageHandler(SceneType.Game)]
public class R2G_LiveCommentHandler: AMActorHandler
{
protected override async ETTask Run(Scene scene, R2G_LiveComment request)
{
if (string.IsNullOrEmpty(request.OpenId))
{
Log.Debug($"未找到openId...");
return;
}
// 房间是否存在
Map map = scene.GetComponent().GetMapByRoomId(request.RoomId);
if (map == null)
{
Log.Debug($"未找到房间...");
return;
}
// 初始模板id
int[] units = new int[] { 101, 121, 111, 131 };
int templateId = 0;
switch (request.Content)
{
case "0":
// 随机
templateId = RandomGenerator.RandomArray(units);
break;
case "1":
// 蜜蜂
templateId = units[0];
break;
case "2":
// 花
templateId = units[1];
break;
case "3":
// 鸟
templateId = units[2];
break;
case "4":
// 蘑菇
templateId = units[3];
break;
}
var pos = map.GetRandomPlayerPos();
Struct.MonsterUnit unit = new Struct.MonsterUnit();
unit.id = templateId;
unit.force = 1;
unit.x = pos.X;
unit.y = pos.Y;
unit.autoGuard = true;
unit.name = request.Nickname;
unit.alias = request.Url;
int objId = await map.AddUnits(unit, true);
map.AddUnitPlayer(request.OpenId, templateId, objId, 0);
await ETTask.CompletedTask;
}
}
}