public void BroadcastUDP(GameObjectUpdate message)
 {
     foreach (Player client in clients)
     {
         client.SendUDP(message);
     }
 }
 public override GameObjectUpdate ConstructMessage(GameObjectUpdate message)
 {
     message.Append(this.value.Count);
     foreach (GameObjectReference <T> obj in this.value)
     {
         message = obj.ConstructMessage(message);
     }
     return(message);
 }
        //sends an update message
        public void SendUpdateMessage(Lobby lobby, GameTime gameTime)
        {
            float secondsElapsed = gameTime.ElapsedGameTime.Milliseconds / 1000.0f;

            this.secondsUntilUpdateMessage = this.secondsUntilUpdateMessage - secondsElapsed;
            if (this.IsDestroyed || this.secondsUntilUpdateMessage <= 0)
            {
                GameObjectUpdate message = new GameObjectUpdate(gameTime, this);
                lobby.BroadcastUDP(message);
                this.secondsUntilUpdateMessage = this.SecondsBetweenUpdateMessage;
            }
        }
        public override void ApplyMessage(GameObjectUpdate message)
        {
            var rtn   = new List <GameObjectReference <T> >();
            int count = message.ReadInt();

            for (int i = 0; i < count; i++)
            {
                GameObjectReference <T> rf = new GameObjectReference <T>(message, collection);
                rtn.Add(rf);
            }
            this.value = rtn;
        }
 public GameObjectReference(GameObjectUpdate message, GameObjectCollection collection)
 {
     this.obj             = null;
     this.hasDereferenced = false;
     this.id         = message.ReadInt();
     this.collection = collection;
     if (id == 0)
     {
         hasDereferenced = true;
     }
     else
     {
         Dereference();
     }
 }
Example #6
0
 public override void ApplyMessage(GameObjectUpdate message)
 {
     base.ApplyMessage(message);
     this.Value = message.ReadFloat();
 }
 public override void ApplyMessage(GameObjectUpdate message)
 {
     this.previousValue = this.drawValue;
 }
 public abstract GameObjectUpdate ConstructMessage(GameObjectUpdate message);
 //TODO: is this the best way?
 public abstract void ApplyMessage(GameObjectUpdate message);
Example #10
0
 //sends an update message
 public void SendUpdateMessage(Lobby lobby, GameTime gameTime)
 {
     float secondsElapsed = gameTime.ElapsedGameTime.Milliseconds / 1000.0f;
     this.secondsUntilUpdateMessage = this.secondsUntilUpdateMessage - secondsElapsed;
     if (this.IsDestroyed || this.secondsUntilUpdateMessage <= 0)
     {
         GameObjectUpdate message = new GameObjectUpdate(gameTime, this);
         lobby.BroadcastUDP(message);
         this.secondsUntilUpdateMessage = this.SecondsBetweenUpdateMessage;
     }
 }
Example #11
0
 public abstract GameObjectUpdate ConstructMessage(GameObjectUpdate message);
Example #12
0
 //TODO: is this the best way?
 public abstract void ApplyMessage(GameObjectUpdate message);
 public GameObjectUpdate ConstructMessage(GameObjectUpdate message)
 {
     message.Append(this.id);
     return(message);
 }
 public override GameObjectUpdate ConstructMessage(GameObjectUpdate message)
 {
     message.Append(this.SimulationValue);
     return(message);
 }
 public override void ApplyMessage(GameObjectUpdate message)
 {
     base.ApplyMessage(message);
     this.SimulationValue = message.ReadVector2();
 }
Example #16
0
 public override GameObjectUpdate ConstructMessage(GameObjectUpdate message)
 {
     return(this.value.ConstructMessage(message));
 }
Example #17
0
 public override void ApplyMessage(GameObjectUpdate message)
 {
     this.value = new GameObjectReference <T>(message, this.collection);
 }