public void detectCollision() { Rectangle zombieRectangle = new Rectangle((int)sPosition.X + 15, (int)sPosition.Y + 14, 35, 49); int b = mountainMap.checkCollisionforZombies(zombieRectangle); if (b == 1 && (lookingDirection == 3 || lookingDirection == 6 || lookingDirection == 7)) { sDirection = Vector2.Zero; hasCollided = true; } if (b == 2 && (lookingDirection == 2 || lookingDirection == 5 || lookingDirection == 6)) { sDirection = Vector2.Zero; hasCollided = true; } if (b == 3 && (lookingDirection == 4 || lookingDirection == 7 || lookingDirection == 8)) { sDirection = Vector2.Zero; hasCollided = true; } if (b == 4 && (lookingDirection == 1 || lookingDirection == 5 || lookingDirection == 8)) { sDirection = Vector2.Zero; hasCollided = true; } if (b == 0) { hasCollided = false; } }
public void detectCollision() { Rectangle zombieRectangle = new Rectangle((int)sPosition.X + 15, (int)sPosition.Y + 14, 35, 49); int b = 0; int c = 0; switch (levelManager.levelIndicator) { case levelManager.levels.levelOne: { b = map.checkCollisionforZombies(zombieRectangle); c = maptile.checkCollisionforZombies(zombieRectangle); break; } case levelManager.levels.levelTwo: { b = mountainMap.checkCollisionforZombies(zombieRectangle); break; } case levelManager.levels.levelThree: { b = castleMap.checkCollisionforZombies(zombieRectangle); break; } } if ((b == 1 || c == 1) && (lookingDirection == 3 || lookingDirection == 6 || lookingDirection == 7)) { sDirection = Vector2.Zero; hasCollided = true; } if ((b == 2 || c == 2) && (lookingDirection == 2 || lookingDirection == 5 || lookingDirection == 6)) { sDirection = Vector2.Zero; hasCollided = true; } if ((b == 2 || c == 2) && (lookingDirection == 4 || lookingDirection == 7 || lookingDirection == 8)) { sDirection = Vector2.Zero; hasCollided = true; } if ((b == 4 || c == 4) && (lookingDirection == 1 || lookingDirection == 5 || lookingDirection == 8)) { sDirection = Vector2.Zero; hasCollided = true; } if ((b == 0 && c == 0)) { hasCollided = false; } }