public static bool ImageTouches(BaseEntity entity1, BaseEntity entity2)
 {
     Vector2 myMin = entity1.MinBound;
     Vector2 myMax = entity1.MaxBound;
     Vector2 otherMin = entity2.MinBound;
     Vector2 otherMax = entity2.MaxBound;
     return
         ((myMin.X < otherMax.X) && (myMax.X > otherMin.X) &&
           (myMin.Y < otherMax.Y) && (myMax.Y > otherMin.Y));
 }
        public static bool CheckPixelCollision(BaseEntity entity1, BaseEntity entity2)
        {
            // Get the tectures.
            Texture2D obj1 = TextureManager.LoadTexture(entity1.Texture);
            Texture2D obj2 = TextureManager.LoadTexture(entity2.Texture);

            // Get the pixels.
            Color[] mTexture1Color = GetColorOfImage(obj1);
            Color[] mTexture2Color = GetColorOfImage(obj2);

            bool pixelTouch = false;
            // If image touches, that means the rectangle image.
            if (ImageTouches(entity1, entity2))
            {
                int i = 0;
                int width = obj1.Width;
                int height = obj1.Height;

                while ((!pixelTouch) && (i < width))
                {
                    int j = 0;
                    while ((!pixelTouch) && (j < (height)))
                    {
                        // check if this position of the image has a color.
                        Color myColor = GetColor(width, mTexture1Color, i, j);
                        if (myColor.A > 0)
                        {
                            Vector2 otherIndex = PositionToPixelImage(new Vector2(obj2.Width, obj1.Height), entity1.Position, entity2.Position);
                            int xMin = (int)otherIndex.X;
                            int yMin = (int)otherIndex.Y;

                            // check if the other image position overlaps.
                            if ((xMin >= 0) && (xMin < obj2.Width) &&
                                 (yMin >= 0) && (yMin < obj2.Height))
                            {
                                // get the other color and check if a color exists on that position of the image.
                                pixelTouch = (GetColor(obj2.Width, mTexture2Color, i, j).A > 0);
                            }
                        }
                        j++;
                    }
                    i++;
                }
            }

            return pixelTouch;
        }
 public WaterSpawnHandler(BaseEntity player)
 {
     CurrEnemyLifeForms = new List<EnemyLifeForm>();
     _player = player;
 }