コード例 #1
0
ファイル: Key.cs プロジェクト: Sebbe/The-Cloning-Game
 public override void Collision(GameObjectCollidable goc)
 {
     if(goc as Player != null)
     {
         DeleteFlag = true;
         objectManager.UnregisterObject(this);
     }
     base.Collision(goc);
 }
コード例 #2
0
 /// <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;
 }
コード例 #3
0
 /// <summary>
 /// Register an object for collision detection.
 /// </summary>
 /// <param name="goc">The object to register..</param>
 public void RegisterObject(GameObjectCollidable goc)
 {
     collidables.Add(goc);
 }
コード例 #4
0
 /// <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)
 {
 }
コード例 #5
0
ファイル: Player.cs プロジェクト: Sebbe/The-Cloning-Game
 /// <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;
             }
         }
     }
 }