void Game::placeTower(Coordinate coord, TowerType type) { if (map->getCellType(coord) == CellType::PATH) return; else if (getTower(coord)) return; else { auto tower = towerFactory.create(coord, type); if (debitCurrency(tower->getPurchasePrice())) { towers.push_back(unique_ptr<BaseTower>(tower)); emit newTower(tower); } else delete tower; } }
void Tile::draw(sf::RenderWindow& w) { if (isPolluted()){ cooldown--; if (cooldown == 0) { currentSprite = 0; spriteUpdate(currentSprite); } } if (hasTower() && isHovered) { getTower()->showRangeCircle(w); } sprite.setTexture(texture); sf::Vector2i spriteInit(0, currentSprite*height); sprite.setTextureRect(sf::IntRect(spriteInit, sf::Vector2i(width, height))); sprite.setPosition(sf::Vector2f(float(positionPixel.x), float(positionPixel.y))); mouseHover(w); w.draw(sprite); }