public bool BuyTower(Vector2f pos, TowerEntityType type) { switch (type) { // TODO: Check if a tower is null before subtrackting units case TowerEntityType.Basic: var stats = EntityStats.TowerEntityStatTable[type]; if (UnitBalance >= stats.UnitCost) { UnitBalance -= stats.UnitCost; var normIndex = _tileMap.GetGridCoords(pos); int index = _towerMap.GetIndex((int)normIndex.X, (int)normIndex.Y); var mPos = _overlayLevel.GetMouseGridCoordsToLevel(); var tileSize = 8 * SpriteScalar; var texSize = _towerBasic.Size * (uint)SpriteScalar; var newPos = new Vector2f( mPos.X + ((tileSize / 2) - (texSize.X / 2)), mPos.Y + ((tileSize / 2) - (texSize.Y / 2))); if (_towerMap[index] == null) { _towerMap[index] = new BasicTower(index, newPos, this, _towerBasic); UpdateInfo(); return(true); } } break; } return(false); }