예제 #1
0
        public override void DoEventClient(IContexts contexts, IEntity entity, IEvent e)
        {
            var          playerEntity       = entity as PlayerEntity;
            Contexts     c                  = contexts as Contexts;
            BeenHitEvent ev                 = e as BeenHitEvent;
            var          playerEntityTarget = c.player.GetEntityWithEntityKey(ev.Target);

            if (playerEntity != null)
            {
                //服务器下发的被击中者调用受击命令
                if (playerEntity.entityKey.Value == ev.Target && playerEntity.hasStateInterface)
                {
                    Logger.DebugFormat("self:{0}, invoke , CanBeenHit:{1}", ev.Target, playerEntity.stateInterface.State.CanBeenHit());

                    if (playerEntity.stateInterface.State.CanBeenHit())
                    {
                        playerEntity.stateInterface.State.BeenHit();
                    }
                }
                //自己预测击中的受击者命令,强制使受击者播放受击动画
                else
                {
                    if (playerEntityTarget != null && playerEntityTarget.hasOverrideNetworkAnimator)
                    {
                        Logger.DebugFormat("target:{0}, invoke , IsInjuryAnimatorActive", ev.Target, ev.TriggerTime);

                        playerEntityTarget.overrideNetworkAnimator.IsInjuryAnimatorActive = true;
                        playerEntityTarget.overrideNetworkAnimator.InjuryTriigerTime      = ev.TriggerTime;
                    }
                }
            }
        }
예제 #2
0
        public void RewindTo(IEvent value)
        {
            BeenHitEvent right = value as BeenHitEvent;

            Target      = right.Target;
            UniqueId    = right.UniqueId;
            TriggerTime = right.TriggerTime;
        }
예제 #3
0
        public override void DoEventServer(IContexts contexts, IEntity entity, IEvent e)
        {
            Contexts     c            = contexts as Contexts;
            BeenHitEvent ev           = e as BeenHitEvent;
            var          playerEntity = c.player.GetEntityWithEntityKey(ev.Target);

            if (playerEntity != null)
            {
                //由于remoteEvents是playback的,命令不会发送给受击者,让受击者调用受伤动画
//                var v = EventInfos.Instance.Allocate(e.EventType, true);
//                v.RewindTo(e);
//                playerEntity.remoteEvents.Events.AddEvent(v);
//                Logger.InfoFormat("server add to player:{0} remoteEvents:{1}", playerEntity.entityKey.Value, e.GetType());
            }
            else
            {
                Logger.WarnFormat("entity:{0} is not found in BeenHitEventHandler.DoEventServer", ev.Target);
            }
        }