public OtherCowLocations findCowCollisions(Cow cow) { Rectangle cowRectangle = cow.getCollisionRectangle(); bool hasCowBelow = false; bool hasCowInJumpToPosition = false; bool hasCowNextToWithNoCowOnTop = false; bool notStoodOnGround = cowRectangle.Bottom < 400 - cowRectangle.Height ; foreach (ICollisionObject otherCowObject in otherObjects) { Cow otherCow = otherCowObject as Cow; if(otherCow != null) { if (!otherCow.Equals(cow) && otherCow.partOfPyramid) { if (notStoodOnGround && new Rectangle( cowRectangle.X, cowRectangle.Y + (int)(1.5*(float)cowRectangle.Height), cowRectangle.Width, cowRectangle.Height/2) .Intersects(otherCow.getCollisionRectangle())) { //hasCowBelow = true; } if (new Rectangle( cowRectangle.X + cowRectangle.Width/2, cowRectangle.Y - (int)(1.5*(float)cowRectangle.Height), cowRectangle.Width, cowRectangle.Height) .Intersects(otherCow.getCollisionRectangle())) { //looks to right & up to check for cow hasCowInJumpToPosition = true; } else if (new Rectangle( cowRectangle.X + cowRectangle.Width/2, cowRectangle.Y, cowRectangle.Width, cowRectangle.Height) .Intersects(otherCow.getCollisionRectangle())) { //just looks to right hasCowNextToWithNoCowOnTop = true; } } } } if(notStoodOnGround&&!hasCowBelow) { //return OtherCowLocations.ThereIsNoCowBelowCurrentCow; } if(hasCowInJumpToPosition) { return OtherCowLocations.ThereIsACowOnTopOfTheCowToTheRight; } if(hasCowNextToWithNoCowOnTop) { return OtherCowLocations.ThereIsACowNextToUsWithNoCowOnTop; } return OtherCowLocations.ThereIsNoCowToTheRight; }