Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
        protected virtual bool LocalCollisionCriterias(PhysicalEntity physicalEntity)
        {
            if (this.PhysicalEntity == physicalEntity)
                return false;

            if (!GraphicalEntity.IntersectsNext(this.PhysicalEntity, physicalEntity))
                return false;

            return true;
        }
Ejemplo n.º 4
0
        public Cursor(PhysicalEntity owner)
            : base()
        {
            this.Owner = owner;
            TexturePath = ("cursor");
            DrawLayer = 1000;

            InActiveThinkDelay = 0;
            ActiveThinkDelay = 0;
            Position = owner.Position;
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 public override void GetPushed(PhysicalEntity entity)
 {
 }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
 protected override bool LocalCollisionCriterias(PhysicalEntity physicalEntity)
 {
     if (physicalEntity is Player || physicalEntity is StaticEntity)
         return base.LocalCollisionCriterias(physicalEntity);
     return false;
 }
Ejemplo n.º 9
0
        public ArrayList EntitiesInBox(PhysicalEntity box)
        {
            ArrayList l = new ArrayList();

            foreach (GraphicalEntity g in results)
            {
                if (PhysicalEntity.RectangularIntersects(g, box))
                    l.Add(g);
            }

            return l;
        }