R2G_LiveCommentHandler.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using System.Numerics;
  3. namespace ET.Server
  4. {
  5. /// <summary>
  6. /// 抖音推送回调, 评论
  7. /// </summary>
  8. [ActorMessageHandler(SceneType.Game)]
  9. public class R2G_LiveCommentHandler: AMActorHandler<Scene, R2G_LiveComment>
  10. {
  11. protected override async ETTask Run(Scene scene, R2G_LiveComment request)
  12. {
  13. if (string.IsNullOrEmpty(request.OpenId))
  14. {
  15. Log.Debug($"未找到openId...");
  16. return;
  17. }
  18. // 房间是否存在
  19. Map map = scene.GetComponent<GameMapComponent>().GetMapByRoomId(request.RoomId);
  20. if (map == null)
  21. {
  22. Log.Debug($"未找到房间...");
  23. return;
  24. }
  25. // 初始模板id
  26. int[] units = new int[] { 101, 121, 111, 131 };
  27. int templateId = 0;
  28. switch (request.Content)
  29. {
  30. // case "0":
  31. // // 随机
  32. // templateId = RandomGenerator.RandomArray(units);
  33. // break;
  34. case "1":
  35. // 蜜蜂
  36. templateId = units[0];
  37. break;
  38. case "2":
  39. // 花
  40. templateId = units[1];
  41. break;
  42. case "3":
  43. // 鸟
  44. templateId = units[2];
  45. break;
  46. case "4":
  47. // 蘑菇
  48. templateId = units[3];
  49. break;
  50. }
  51. Vector2 pos = map.GetRandomPlayerPos();
  52. await map.AddUnitPlayer(request.OpenId, templateId, 1, "", pos.X, pos.Y, request.NickName, request.Url);
  53. await ETTask.CompletedTask;
  54. }
  55. }
  56. }