public Overworld(Party playerParty, Area area) { if (playerParty == null) throw new Exception("Party playerParty cannot be null"); PlayerParty = playerParty; Area = area; EnemyParties = new List<Party>(); states = new Stack<OverworldState>(); states.Push(new OverworldStates.Menu(this)); stateChanged = true; Map = new Map(100, 100, 5, 5); PlayerParty.PrimaryPartyMember.StartOverworld(new Vector2(200.0f)); addEntity(PlayerParty.PrimaryPartyMember.OverworldEntity); camera = new Camera(Game1.ScreenSize); camera.Target = playerParty.PrimaryPartyMember.OverworldEntity; //populateWithScenery(); //populateWithEnemies(); playerInvincibilityTimer = 0.0f; }
public bool CollidesWith(Map map) { Rectangle bounds = GetBoundingBox(); Point topLeftTileCoord = new Point(bounds.Left / Map.TileSize, bounds.Top / Map.TileSize); Point bottomRightTileCoord = new Point(bounds.Right / Map.TileSize, bounds.Bottom / Map.TileSize); for (int x = topLeftTileCoord.X; x <= bottomRightTileCoord.X; ++x) { for (int y = topLeftTileCoord.Y; y <= bottomRightTileCoord.Y; ++y) { if (map.CollisionMap[x, y]) { Rectangle tileRect = new Rectangle(x * Map.TileSize, y * Map.TileSize, Map.TileSize, Map.TileSize); if (tileRect.EIntersects(bounds)) return true; } } } return false; }