summaryrefslogtreecommitdiff
path: root/Penguloon/Levels/LevelBase.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Penguloon/Levels/LevelBase.cs')
-rw-r--r--Penguloon/Levels/LevelBase.cs30
1 files changed, 28 insertions, 2 deletions
diff --git a/Penguloon/Levels/LevelBase.cs b/Penguloon/Levels/LevelBase.cs
index 351cdcf..2b003cf 100644
--- a/Penguloon/Levels/LevelBase.cs
+++ b/Penguloon/Levels/LevelBase.cs
@@ -80,8 +80,34 @@ namespace Penguloon.Levels
// check if there isnt an object already
for (int x = 0; x < Map.Objects.Count; x++)
{
- if (Map.Objects[x].Position == new Vector2(posToSpawnX, posToSpawnY))
- return;
+ for (int px = 0; px < Map.Objects[x].TileSpanX; px++)
+ {
+ for (int py = 0; py < Map.Objects[x].TileSpanY; py++)
+ {
+ Vector2 posToCheck = Map.Objects[x].Position + new Vector2(px * Map.TileWidth, py * Map.TileHeight);
+
+ if (posToCheck == new Vector2(posToSpawnX, posToSpawnY))
+ return;
+ }
+ }
+ }
+
+ // check if it isnt touching any walkable tiles
+ for (int px = 0; px < ParentScene.ObjectSeletor.Objects[ParentScene.ObjectSeletor.SelectedObjectIndex].Item1.TileSpanX; px++)
+ {
+ for (int py = 0; py < ParentScene.ObjectSeletor.Objects[ParentScene.ObjectSeletor.SelectedObjectIndex].Item1.TileSpanY; py++)
+ {
+ Vector2 posToCheck = new Vector2(posToSpawnX, posToSpawnY) + new Vector2(px * Map.TileWidth, py * Map.TileHeight);
+
+ int tx = (int)posToCheck.X / Map.TileWidth;
+ int ty = (int)posToCheck.Y / Map.TileHeight;
+
+ try
+ {
+ if (Map.TileMap[ty, tx].Direction != Direction.None) return;
+ }
+ catch { return; }
+ }
}
Money -= ParentScene.ObjectSeletor.Objects[ParentScene.ObjectSeletor.SelectedObjectIndex].Item2;