12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using System.Text.Json;
- namespace ET.Server
- {
-
-
-
- [ActorMessageHandler(SceneType.Game)]
- public class R2G_LiveLikeHandler : AMActorHandler<Scene, R2G_LiveLike>
- {
- protected override async ETTask Run(Scene scene, R2G_LiveLike request)
- {
-
- Map map = scene.GetComponent<GameMapComponent>().GetMapByRoomId(request.RoomId);
- if (map == null)
- {
- Log.Debug($"未找到房间...roomId={request.RoomId}");
- return;
- }
-
- Struct.UnitPlayerData unitPlayerData = map.GetUnitPlayerByOpenId(request.OpenId) ?? map.AddUnitPlayer(request.OpenId, 0, 0, request.Likes);
-
- unitPlayerData.Likes += request.Likes;
- map.TotalLikeNum += request.Likes;
-
- unitPlayerData.ContributeValue += request.Likes;
- const int configNum = 1000;
- bool notifyBattleServer = false;
-
- if (map.TotalLikeNum >= configNum)
- {
-
- map.TotalLikeNum -= configNum;
- map.ConfigNum += 1;
- notifyBattleServer = true;
- }
-
- if (map.Player != null)
- {
- long totalNum = map.ConfigNum * configNum + map.TotalLikeNum;
- MessageHelper.SendToClient(map.Player, new G2C_LikeInfoPush{ TotalNum = totalNum, ConfigNum = configNum});
- }
- if (notifyBattleServer)
- {
- Struct.TriggerEventNotify notify = new Struct.TriggerEventNotify();
- notify.message = BattleNotify.TiktokLike_energy.ToString();
- notify.TriggerUnits = unitPlayerData.ObjId.ToString();
- map.GetXmdsManager().notifyBattleServer(map.Id.ToString(), NotifyBSName.TriggerEvent, JsonSerializer.Serialize(notify));
- }
- await ETTask.CompletedTask;
- }
- }
- }
|