Ejemplo n.º 1
0
        public void HandleGMUpdate(NetworkMessage msg)
        {
            MsgGMUpdate gm = msg as MsgGMUpdate;

            Shot s = GetShotByBZFSID(BuildBZFSShotID(gm.PlayerID, gm.ShotID));

            if (s == null)
            {
                return;
            }

            s.Position   = gm.Position;
            s.Velocity   = gm.Velocity;
            s.LastUpdate = PlayerList.Clock.StepTime;
            s.DeltaTime  = gm.DeltaTime;
            s.Target     = PlayerList.GetPlayerByID(gm.TargetID);

            if (ShotUpdated != null)
            {
                ShotUpdated.Invoke(this, s);
            }
        }
Ejemplo n.º 2
0
        public void UpdateShot(ShotInfo shot, Vector3F postion, Vector3F velocity, float delta, ServerPlayer target)
        {
            if (shot == null || target == null)
            {
                return;
            }

            shot.UpdateTimestamp = GameTime.Now;
            shot.UpdatePostion   = postion;
            shot.UpdateVector    = velocity;

            ShotUpdatedEventArgs args = new ShotUpdatedEventArgs();

            args.Shot   = shot;
            args.Target = target;

            ShotPreUpdate?.Invoke(this, args);

            MsgGMUpdate update = new MsgGMUpdate();

            if (shot.Owner != null)
            {
                update.PlayerID = shot.Owner.PlayerID;
            }
            else
            {
                update.PlayerID = PlayerConstants.ServerPlayerID;
            }

            update.ShotID    = shot.PlayerShotID;
            update.TargetID  = args.Target.PlayerID;
            update.Position  = shot.UpdatePostion;
            update.Velocity  = shot.UpdateVector;
            update.DeltaTime = delta;
            update.Team      = shot.TeamColor;

            Players.SendToAll(update, false);
            ShotUpdated?.Invoke(this, shot);
        }