private void HandleCollision(PhysicalEntity physicalEntity) { float tempMy = this.PhysicalEntity.MovementVector.Y; this.PhysicalEntity.MovementVector *= new Vector2(1, 0); if (PhysicalEntity.Intersects(this.PhysicalEntity, physicalEntity)) this.PhysicalEntity.MovementVector = new Vector2(0, tempMy); if (PhysicalEntity.Intersects(this.PhysicalEntity, physicalEntity)) this.PhysicalEntity.MovementVector = new Vector2(0, 0); }
public bool Intersects(PhysicalEntity e1) { if ((e1.position.X + e1.Bounds.X > this.position.X || this.position.X + this.Bounds.X > e1.position.X) && (e1.position.Y + e1.Bounds.Y > this.position.Y || this.position.Y + this.Bounds.Y > e1.position.Y)) return false; return true; }
protected virtual bool LocalCollisionCriterias(PhysicalEntity physicalEntity) { if (this.PhysicalEntity == physicalEntity) return false; if (!GraphicalEntity.IntersectsNext(this.PhysicalEntity, physicalEntity)) return false; return true; }
public Cursor(PhysicalEntity owner) : base() { this.Owner = owner; TexturePath = ("cursor"); DrawLayer = 1000; InActiveThinkDelay = 0; ActiveThinkDelay = 0; Position = owner.Position; }
public static bool Intersects(PhysicalEntity e1, PhysicalEntity e2) { if ((e1.MovementVector - e2.MovementVector).Length() < 0.001f) return false; Vector2 n1 = e1.GetNextPosition(); Vector2 n2 = e2.position; Rectangle r1 = new Rectangle((int)n1.X, (int)n1.Y, (int)e1.Bounds.X, (int)e1.Bounds.Y); Rectangle r2 = new Rectangle((int)n2.X, (int)n2.Y, (int)e2.Bounds.X, (int)e2.Bounds.Y); return r1.Intersects(r2); }
public override void GetPushed(PhysicalEntity entity) { }
public virtual void GetPushed(PhysicalEntity entity) { PhysicalEntity.MovementVector = (1f * entity.Mass * (entity.MovementVector - PhysicalEntity.MovementVector) + PhysicalEntity.MovementVector * PhysicalEntity.Mass + entity.MovementVector * entity.Mass) / (PhysicalEntity.Mass + entity.Mass); }
protected override bool LocalCollisionCriterias(PhysicalEntity physicalEntity) { if (physicalEntity is Player || physicalEntity is StaticEntity) return base.LocalCollisionCriterias(physicalEntity); return false; }
public ArrayList EntitiesInBox(PhysicalEntity box) { ArrayList l = new ArrayList(); foreach (GraphicalEntity g in results) { if (PhysicalEntity.RectangularIntersects(g, box)) l.Add(g); } return l; }