Exemplo n.º 1
0
 public override void Collision(GameObjectCollidable goc)
 {
     if(goc as Player != null)
     {
         DeleteFlag = true;
         objectManager.UnregisterObject(this);
     }
     base.Collision(goc);
 }
 /// <summary>
 /// A function that checks if a colllidable before the real test runs
 /// </summary>
 /// <param name="goc">The object to check</param>
 public List<GameObjectCollidable> CheckCollision(GameObjectCollidable goc)
 {
     List<GameObjectCollidable> temp;
     temp = new List<GameObjectCollidable>();
     for (int i = 0; i < collidables.Count; i++)
     {
         if (collidables[i] == goc)
         {
             continue;
         }
         if (goc.CollisionBox.Intersects(collidables[i].CollisionBox))
         {
             temp.Add(collidables[i]);
         }
     }
     return temp;
 }
 /// <summary>
 /// Register an object for collision detection.
 /// </summary>
 /// <param name="goc">The object to register..</param>
 public void RegisterObject(GameObjectCollidable goc)
 {
     collidables.Add(goc);
 }
 /// <summary>
 /// This function does not implement any collision data, as it wouldn't know
 /// what to do if it crashed with something!
 /// </summary>
 /// <param name="goc">The object the called object was hit by</param>
 public virtual void Collision(GameObjectCollidable goc)
 {
 }
Exemplo n.º 5
0
 /// <summary>
 /// Collisions handling if it collidades with something
 /// </summary>
 /// <param name="goc"></param>
 public override void Collision(GameObjectCollidable goc)
 {
     if(goc as Key != null)
     {
         haveKey = true;
     }
     if(goc as Door != null)
     {
         if(haveKey)
         {
             doorOpen = true;
         }
     }
     if (goc as Floor != null)
     {
         if (gravity > 0)
         {
             position.Y = goc.CollisionBox.Top - goc.CollisionBox.Height + 4;
         } else
         {
             position.Y = goc.CollisionBox.Bottom + goc.CollisionBox.Height - 9;
         }
         inAir = false;
     }
     if (goc as Wall != null)
     {
         if (gravity > 0)
         {
             if(_animationWalk == 3)
             {
                 position.X = goc.CollisionBox.Right + 22;
             } else
             {
                 position.X = goc.CollisionBox.Left - 22;
             }
         }
         else
         {
             if (_animationWalk == 3)
             {
                 position.X = goc.CollisionBox.Left - 22;
             }
             else
             {
                 position.X = goc.CollisionBox.Right + 22;
             }
         }
     }
 }