From d83022b60754698054dc8dcb675ceee36f171bf8 Mon Sep 17 00:00:00 2001 From: whiterandrek Date: Fri, 11 May 2018 17:55:08 +0300 Subject: PINK: added implementation of mini-games (PubPink and ParlSqPink) --- engines/pink/constants.h | 17 +++++- engines/pink/objects/actors/lead_actor.cpp | 86 ++++++++++++++++++++++++++++++ engines/pink/objects/actors/lead_actor.h | 17 ++++++ 3 files changed, 119 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/pink/constants.h b/engines/pink/constants.h index b8874df317..8e70f5a86e 100644 --- a/engines/pink/constants.h +++ b/engines/pink/constants.h @@ -155,7 +155,6 @@ static const char *kPeril = "peril"; static const char *kUndefined = "UNDEFINED"; - static const char *kCloseAction = "Close"; static const char *kIdleAction = "Idle"; static const char *kOpenAction = "Open"; @@ -173,6 +172,22 @@ static const char *kCursorNameExitLeft = "ExitLeft"; static const char *kCursorNameExitRight = "ExitRight"; static const char *kCursorNameExitForward = "ExitForward"; +static const char *kClickable = "Clickable"; +static const char *kCursor = "Cursor"; + +static const char *kFoodPuzzle = "FoodPuzzle"; +static const char *kJackson = "Jackson"; +static const char *kBolted = "Bolted"; +static const char *kDrunkLocation = "DrunkLocation"; +static const char *kDrunk = "Drunk"; + +static const char *kFirstRound = "15.1"; +static const char *kSecondRound = "15.2"; +static const char *kThirdRound = "15.3"; + +static const char *kBoy = "Boy"; +static const char *kSirBaldley = "SirBaldley"; +static const char *kBoyBlocked = "BoyBlocked"; } // End of namespace Pink diff --git a/engines/pink/objects/actors/lead_actor.cpp b/engines/pink/objects/actors/lead_actor.cpp index bf6d330169..8c343543a3 100644 --- a/engines/pink/objects/actors/lead_actor.cpp +++ b/engines/pink/objects/actors/lead_actor.cpp @@ -319,6 +319,19 @@ void ParlSqPink::toConsole() { } } +WalkLocation *ParlSqPink::getWalkDestination() { + if (_recipient->getName() == kBoy && + _page->checkValueOfVariable(kBoyBlocked, kUndefined)) + { + return _walkMgr->findLocation(kSirBaldley); + } + return LeadActor::getWalkDestination(); +} + +PubPink::PubPink() : + LeadActor(), _round(0) +{} + void PubPink::toConsole() { debug("PubPink: _name = %s", _name.c_str()); for (int i = 0; i < _actions.size(); ++i) { @@ -326,4 +339,77 @@ void PubPink::toConsole() { } } +bool PubPink::playingMiniGame() { + return !(_page->checkValueOfVariable(kFoodPuzzle, "TRUE") || + _page->checkValueOfVariable(kFoodPuzzle, kUndefined)); +} + +void PubPink::onClick() { + if (!playingMiniGame()) + LeadActor::onClick(); +} + +void PubPink::updateCursor(Common::Point point) { + if (playingMiniGame()) { + SupportingActor *actor = static_cast(_page->getGame()->getDirector()->getActorByPoint(point)); + if (_state == kReady && + actor && + actor->isUseClickHandlers(_page->getModule()->getInventoryMgr()->getCurrentItem())) + { + _cursorMgr->setCursor(kClickableFirstFrameCursor, point, Common::String()); + } + else _cursorMgr->setCursor(kDefaultCursor, point, Common::String()); + } + else LeadActor::updateCursor(point); +} + +WalkLocation *PubPink::getWalkDestination() { + if (playingMiniGame()) + return nullptr; + + if (_recipient->getName() == kJackson && + !_page->checkValueOfVariable(kDrunkLocation, kBolted)) + { + return _walkMgr->findLocation(_page->findActor(kDrunk)->getName()); + } + + return LeadActor::getWalkDestination(); +} + +bool PubPink::sendUseClickMessage(SupportingActor *actor) { + if (!LeadActor::sendUseClickMessage(actor) && + playingMiniGame()) { + _nextState = _state; + _state = kInDialog1; + + const char *roundName; + switch (_round++ % 3) { + case 0: + roundName = kFirstRound; + break; + case 1: + roundName = kSecondRound; + break; + case 2: + roundName = kThirdRound; + break; + default: + roundName = nullptr; + assert(0); + break; + } + _sequencer->authorSequence(_sequencer->findSequence(roundName), 0); + } + + if (playingMiniGame()) + _isHaveItem = true; + + return true; +} + +void PubPink::onVariableSet() { + if (playingMiniGame()) + _isHaveItem = true; +} + } // End of namespace Pink diff --git a/engines/pink/objects/actors/lead_actor.h b/engines/pink/objects/actors/lead_actor.h index fe2b613188..977096bf82 100644 --- a/engines/pink/objects/actors/lead_actor.h +++ b/engines/pink/objects/actors/lead_actor.h @@ -32,6 +32,7 @@ namespace Pink { class CursorMgr; class WalkMgr; +class WalkLocation; class Sequencer; class SupportingActor; @@ -70,6 +71,7 @@ public: void onWalkEnd(); virtual void onClick(); void onInventoryClosed(bool isItemClicked); + virtual void onVariableSet() {}; virtual void onMouseOver(Common::Point point, CursorMgr *mgr); @@ -100,12 +102,27 @@ protected: class ParlSqPink : public LeadActor { public: + virtual WalkLocation *getWalkDestination(); void toConsole(); }; class PubPink : public LeadActor { public: + PubPink(); + void toConsole(); + + virtual void onClick(); + virtual void onVariableSet(); + +private: + int _round; + + virtual bool sendUseClickMessage(SupportingActor *actor); + virtual void updateCursor(Common::Point point); + virtual WalkLocation *getWalkDestination(); + + bool playingMiniGame(); }; -- cgit v1.2.3