void PlayScene::DestroyBubble(Bubble* bubble) { if (!bubble) return; m_bubbles.remove(bubble); // Scene ending if (bubble->GetBubbleType() == eBubbles::Player) m_status = Status::Lose; else if (bubble->GetBubbleType() == eBubbles::Good) { // Set good bubbles score const uint32 goodBubbles = std::count_if(m_bubbles.cbegin(), m_bubbles.cend(), [](const Bubble* b) { return b->GetBubbleType() == eBubbles::Good; }); m_scorePanel->SetValue(eScores::GOOD_BUBBLES, goodBubbles); if (!GetBubble(eBubbles::Good)) { Bubble* plBubble = GetBubble(eBubbles::Player); Assert(plBubble == nullptr, "PlayScene::DestroyBubble: Player bubble not found for finish game"); m_playerBubbleSizeOnEnd = plBubble->GetCircle()->getRadius() * 2; m_status = Status::Win; } } delete bubble; }
void PlayScene::OnBubbleMove(Bubble* bubble) { // Check collision if (Bubble* collisedBubble = CheckBubbleCollision(bubble)) { bubble->OnTouch(collisedBubble); collisedBubble->OnTouch(bubble); // Set player score Bubble* player = nullptr; if (bubble->GetBubbleType() == eBubbles::Player) player = bubble; else if (collisedBubble->GetBubbleType() == eBubbles::Player) player = collisedBubble; if (player) m_scorePanel->SetValue(eScores::PLAYER, (uint32)player->GetCircle()->getRadius() * 2); } }