| 229 | } |
| 230 | |
| 231 | void Room::updateActiveSpots() |
| 232 | { |
| 233 | std::vector<Tile*> centralActiveSpotTiles; |
| 234 | std::vector<Tile*> leftWallsActiveSpotTiles; |
| 235 | std::vector<Tile*> rightWallsActiveSpotTiles; |
| 236 | std::vector<Tile*> topWallsActiveSpotTiles; |
| 237 | std::vector<Tile*> bottomWallsActiveSpotTiles; |
| 238 | |
| 239 | // Detect the centers of 3x3 squares tiles |
| 240 | for(unsigned int i = 0, size = mCoveredTiles.size(); i < size; ++i) |
| 241 | { |
| 242 | bool foundTop = false; |
| 243 | bool foundTopLeft = false; |
| 244 | bool foundTopRight = false; |
| 245 | bool foundLeft = false; |
| 246 | bool foundRight = false; |
| 247 | bool foundBottomLeft = false; |
| 248 | bool foundBottomRight = false; |
| 249 | bool foundBottom = false; |
| 250 | Tile* tile = mCoveredTiles[i]; |
| 251 | int tileX = tile->getX(); |
| 252 | int tileY = tile->getY(); |
| 253 | |
| 254 | // Check all other tiles to know whether we have one center tile. |
| 255 | for(unsigned int j = 0; j < size; ++j) |
| 256 | { |
| 257 | // Don't check the tile itself |
| 258 | if (tile == mCoveredTiles[j]) |
| 259 | continue; |
| 260 | |
| 261 | // Check whether the tile around the tile checked is already a center spot |
| 262 | // as we can't have two center spots next to one another. |
| 263 | if (std::find(centralActiveSpotTiles.begin(), centralActiveSpotTiles.end(), mCoveredTiles[j]) != centralActiveSpotTiles.end()) |
| 264 | continue; |
| 265 | |
| 266 | int tile2X = mCoveredTiles[j]->getX(); |
| 267 | int tile2Y = mCoveredTiles[j]->getY(); |
| 268 | |
| 269 | if(tile2X == tileX - 1) |
| 270 | { |
| 271 | if (tile2Y == tileY + 1) |
| 272 | foundTopLeft = true; |
| 273 | else if (tile2Y == tileY) |
| 274 | foundLeft = true; |
| 275 | else if (tile2Y == tileY - 1) |
| 276 | foundBottomLeft = true; |
| 277 | } |
| 278 | else if(tile2X == tileX) |
| 279 | { |
| 280 | if (tile2Y == tileY + 1) |
| 281 | foundTop = true; |
| 282 | else if (tile2Y == tileY - 1) |
| 283 | foundBottom = true; |
| 284 | } |
| 285 | else if(tile2X == tileX + 1) |
| 286 | { |
| 287 | if (tile2Y == tileY + 1) |
| 288 | foundTopRight = true; |
no test coverage detected