Exemplo n.º 1
0
 public bool IsCollided(Movables mobile)
 {
     for (int i = 0; i < this.width; i++)
     {
         for (int j = 0; j < this.height; j++)
         {
             if (myMap[i, j].blocking && myMap[i, j].IsCollided(myHero))
             {
                 Console.WriteLine("Collided");
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 2
0
 public bool IsCollided(Movables mobile)
 {
     Point[] mobileCorners = new Point[] { new Point(mobile.PositionRect.X, mobile.PositionRect.Y),
                                           new Point(mobile.PositionRect.X, mobile.PositionRect.Y + mobile.PositionRect.Size.Y),
                                           new Point(mobile.PositionRect.X + mobile.PositionRect.Size.X, mobile.PositionRect.Y),
                                           new Point(mobile.PositionRect.X + mobile.PositionRect.Size.X, mobile.PositionRect.Y + mobile.PositionRect.Size.Y) };
     foreach (Point currentPoint in mobileCorners)
     {
         if (currentPoint.X > this.PositionRect.X && currentPoint.X <= this.PositionRect.X + this.PositionRect.Size.X &&
             currentPoint.Y > this.PositionRect.Y && currentPoint.Y <= this.PositionRect.Y + this.PositionRect.Size.Y)
         {
             return(true);
         }
     }
     return(false);
 }