public static void BroadcastTarget(IActorMessage message, List <Player> targets) { ActorMessageSenderComponent actorLocationSenderComponent = Game.Scene.GetComponent <ActorMessageSenderComponent>(); for (int i = 0; i < targets?.Count; i++) { if (!CheckMapUnitSenderVailed(targets[i], out var gateSessionActorId)) { continue; } ActorMessageSender actorMessageSender = actorLocationSenderComponent.Get(gateSessionActorId); actorMessageSender.Send(message); } }
public async void Awake() { while (true) { try { await Task.Delay(10000); if (mList.Count < 1) { continue; } foreach (var player in Game.Scene.GetComponent <PlayerManagerComponent>().UserMap.Keys) { var userInfo = Game.Scene.GetComponent <PlayerManagerComponent>().Get(player); if (userInfo == null) { continue; } ActorMessageSender actorProxy = userInfo.GetComponent <UnitGateComponent>().GetActorMessageSender(); Actor_ScrollToNotice_Ntt ntt = new Actor_ScrollToNotice_Ntt { Content = mList[0] }; actorProxy.Send(ntt); } mList.RemoveAt(0); } catch (System.Exception e) { Log.Error(e.Message); } } }
public static void BroadcastRoom(long roonId, IActorMessage message, params long[] filterUids) { Room room = Game.Scene.GetComponent <RoomComponent>().Get(roonId); if (room == null) { Log.Error($"{message?.GetType()?.ToString()} Broadcast 失敗! 找不到Room : {roonId}"); return; } List <MapUnit> targets = room.GetAll(); ActorMessageSenderComponent actorLocationSenderComponent = Game.Scene.GetComponent <ActorMessageSenderComponent>(); for (int i = 0; i < targets.Count; i++) { if (filterUids != null) { bool isFilter = false; for (int k = 0; k < filterUids.Length; k++) { if (targets[i].Uid == filterUids[k]) { isFilter = true; break; } } if (isFilter) { continue; } } if (!CheckMapUnitSenderVailed(targets[i], out var gateSessionActorId)) { continue; } ActorMessageSender actorMessageSender = actorLocationSenderComponent.Get(gateSessionActorId); actorMessageSender.Send(message); } }