Exemplo n.º 1
1
 public void Dispose()
 {
     _deathStartedAt = null;
     _killedBy = null;
     _owner.OnCollision -= collision;
     _owner = null; ;
 }
Exemplo n.º 2
0
 private void collision(object sender, CollisionEventArgs e)
 {
     if(!_deathStartedAt.HasValue)
     {
         _killedBy = e.CollidedWith;
         _deathStartedAt = GameTime.LastUpdated; // Last Updated is nearly equivalent to the current time
     }
 }
Exemplo n.º 3
0
 public void Update(GameTime gameTime)
 {
     var velocityZero = _owner.MovementController.Velocity.IsZero();
     if (_deathStartedAt.HasValue
         && gameTime.Now - _deathStartedAt >= DEATH_AFTER
         && velocityZero)
     {
         // We've died
         _owner.Die(_killedBy);
     }
     else if (!velocityZero)
     {
         _deathStartedAt = null;
         _killedBy = null;
     }
 }
Exemplo n.º 4
0
 public CollisionEventArgs(Collidable collidedWith)
 {
     CollidedWith = collidedWith;
 }
Exemplo n.º 5
0
 private void setCollidableContractMembers(object[] result, Collidable collidable)
 {
     result[_collidableCompressionContract.ID] = collidable.ID;
     result[_collidableCompressionContract.Alive] = Convert.ToInt16(collidable.Alive);
     result[_collidableCompressionContract.Position_X] = Math.Round(collidable.MovementController.Position.x, 2);
     result[_collidableCompressionContract.Position_Y] = Math.Round(collidable.MovementController.Position.y, 2);
     result[_collidableCompressionContract.Position_Z] = Math.Round(collidable.MovementController.Position.z, 2);
     result[_collidableCompressionContract.Velocity_X] = Math.Round(collidable.MovementController.Velocity.x, 2);
     result[_collidableCompressionContract.Velocity_Y] = Math.Round(collidable.MovementController.Velocity.y, 2);
     result[_collidableCompressionContract.Velocity_Z] = Math.Round(collidable.MovementController.Velocity.z, 2);
     result[_collidableCompressionContract.Rotation] = Math.Round(collidable.MovementController.Rotation, 2);
 }
Exemplo n.º 6
0
 public virtual void HandleCollisionWith(Collidable obj)
 {
     Colliding = true;
 }
Exemplo n.º 7
0
 public DeathEventArgs(Collidable killedBy)
 {
     KilledBy = killedBy;
 }
Exemplo n.º 8
0
 public virtual void HandleCollisionWith(Collidable obj)
 {
     Colliding = true;
 }