Exemple #1
0
bool Robot::checkCollision(bool pointBased)
{
	for (auto& bullet : Game::instance->bullets) {
		BBox other = bullet->getBBox();
    if (!bullet->shotByPlayer) continue;
		if (other.Intersects(getBBox()) && !(pointBased && !other.Contains(getWorldPos()))) {
      bullet->flaggedForRemoval = true;
			if (--health <= 0)
			{
        if (!flaggedForRemoval)
        {
          Game::instance->kills++;
        }
        flaggedForRemoval = true;
				return true;
			}
			break;
		}
	}

	for (auto& robot : Game::instance->robots) {
		BBox other = robot->getBBox();
		if (robot != this && other.Intersects(getBBox()) && !(pointBased && !other.Contains(getWorldPos()))) {
			return false;
		}
	}
	return CubeMesh::checkCollision(pointBased);
}