From 7650fca0405f62e62bdf81cb9f2acd8e7f14ca69 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sat, 28 Jan 2012 17:46:04 +0100 Subject: GOB: Air gets used up and is refilled by breathing --- engines/gob/minigames/geisha/diving.cpp | 19 +++++++++++++++++++ engines/gob/minigames/geisha/diving.h | 3 +++ engines/gob/minigames/geisha/oko.cpp | 4 ++-- engines/gob/minigames/geisha/oko.h | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/engines/gob/minigames/geisha/diving.cpp b/engines/gob/minigames/geisha/diving.cpp index 59ebe7f7b1..bd87be8e7f 100644 --- a/engines/gob/minigames/geisha/diving.cpp +++ b/engines/gob/minigames/geisha/diving.cpp @@ -39,6 +39,9 @@ namespace Gob { namespace Geisha { +static const uint8 kAirDecreaseRate = 15; + + const uint16 Diving::kEvilFishTypes[kEvilFishTypeCount][5] = { { 0, 14, 8, 9, 3}, // Shark {15, 1, 12, 13, 3}, // Moray @@ -105,6 +108,7 @@ bool Diving::play(uint16 playerCount, bool hasPearlLocation) { while (!_vm->shouldQuit()) { checkShots(); + updateAirMeter(); updateEvilFish(); updateDecorFish(); updatePlants(); @@ -245,6 +249,8 @@ void Diving::init() { _airMeter->setValue(38); _healthMeter->setValue(38); + + _airCycle = 0; } void Diving::deinit() { @@ -393,6 +399,19 @@ void Diving::enterPearl(int16 x) { _pearl.pearl->setPause(false); } +void Diving::updateAirMeter() { + if (_oko->isBreathing()) { + _airCycle = 0; + _airMeter->increase(); + return; + } + + _airCycle = (_airCycle + 1) % kAirDecreaseRate; + + if (_airCycle == 0) + _airMeter->decrease(); +} + void Diving::updateEvilFish() { for (uint i = 0; i < kEvilFishCount; i++) { ManagedEvilFish &fish = _evilFish[i]; diff --git a/engines/gob/minigames/geisha/diving.h b/engines/gob/minigames/geisha/diving.h index 50a5d49a8c..2915e85a93 100644 --- a/engines/gob/minigames/geisha/diving.h +++ b/engines/gob/minigames/geisha/diving.h @@ -136,6 +136,8 @@ private: Meter *_airMeter; Meter *_healthMeter; + uint8 _airCycle; + uint8 _currentShot; SoundDesc _soundShoot; @@ -161,6 +163,7 @@ private: void foundBlackPearl(); void foundWhitePearl(); + void updateAirMeter(); void updateEvilFish(); void updateDecorFish(); void updatePlants(); diff --git a/engines/gob/minigames/geisha/oko.cpp b/engines/gob/minigames/geisha/oko.cpp index 5da1947acf..23f460fdba 100644 --- a/engines/gob/minigames/geisha/oko.cpp +++ b/engines/gob/minigames/geisha/oko.cpp @@ -131,8 +131,8 @@ Oko::State Oko::getState() const { return _state; } -bool Oko::isAtBottom() const { - return _level >= (kLevelCount - 1); +bool Oko::isBreathing() const { + return (_state == kStateBreathe) && ((getFrame() >= 9) && (getFrame() <= 30)); } } // End of namespace Geisha diff --git a/engines/gob/minigames/geisha/oko.h b/engines/gob/minigames/geisha/oko.h index 0dee53ce45..37824936e3 100644 --- a/engines/gob/minigames/geisha/oko.h +++ b/engines/gob/minigames/geisha/oko.h @@ -57,7 +57,7 @@ public: State getState() const; - bool isAtBottom() const; + bool isBreathing() const; private: Sound *_sound; -- cgit v1.2.3