Skip to content

Commit

Permalink
PINK: added implementation of mini-games (PubPink and ParlSqPink)
Browse files Browse the repository at this point in the history
  • Loading branch information
voltya authored and sev- committed Jun 28, 2018
1 parent 181b890 commit d83022b
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 1 deletion.
17 changes: 16 additions & 1 deletion engines/pink/constants.h
Expand Up @@ -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";
Expand All @@ -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

Expand Down
86 changes: 86 additions & 0 deletions engines/pink/objects/actors/lead_actor.cpp
Expand Up @@ -319,11 +319,97 @@ 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) {
_actions[i]->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<SupportingActor*>(_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
17 changes: 17 additions & 0 deletions engines/pink/objects/actors/lead_actor.h
Expand Up @@ -32,6 +32,7 @@ namespace Pink {

class CursorMgr;
class WalkMgr;
class WalkLocation;
class Sequencer;

class SupportingActor;
Expand Down Expand Up @@ -70,6 +71,7 @@ class LeadActor : public Actor {
void onWalkEnd();
virtual void onClick();
void onInventoryClosed(bool isItemClicked);
virtual void onVariableSet() {};

virtual void onMouseOver(Common::Point point, CursorMgr *mgr);

Expand Down Expand Up @@ -100,12 +102,27 @@ class LeadActor : public Actor {

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();
};


Expand Down

0 comments on commit d83022b

Please sign in to comment.