コード例 #1
0
        protected override async ETTask Run(Session session, C2G_PlayerHitOtherPlayer message)
        {
            //获取玩家
            Player player = Game.Scene.GetComponent <PlayerComponent>().getPlayerByAccount(message.HitPlayerAccount);
            //Actor发送组件
            ActorMessageSenderComponent actorSenderComponent = Game.Scene.GetComponent <ActorMessageSenderComponent>();
            ActorMessageSender          actorMessageSender   = actorSenderComponent.Get(player.MapInstanceId);

            Actor_PlayerToUnitSubHealthResponse actor_PlayerToUnitSubHealthResponse = (Actor_PlayerToUnitSubHealthResponse)await actorMessageSender.Call(new Actor_PlayerToUnitSubHealthRequest()
            {
                SubHealth     = message.SubHealth,
                KillerAccount = message.SelfAccount
            });

            //只有攻击了没有死亡的角色才会发送信息
            if (!actor_PlayerToUnitSubHealthResponse.AttackDiePlayer)
            {
                //给对应角色发扣血的信息
                player.session.Send(new G2C_PlayerHealthUpuate()
                {
                    NewHealth = actor_PlayerToUnitSubHealthResponse.UnitHealth,
                    Die       = actor_PlayerToUnitSubHealthResponse.Die
                });
            }


            await ETTask.CompletedTask;
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
            }
        }