Commit e5d59ee9 authored by Ian Wadham's avatar Ian Wadham

Reconnect the scoring for trapping enemy, killing enemy and collecting gold.

svn path=/trunk/KDE/kdegames/kgoldrunner/; revision=950914
parent 40858894
......@@ -456,7 +456,7 @@ void KGrGame::startLevel (int startingAt, int requestedLevel)
/************************ MAIN GAME EVENT PROCEDURES ************************/
/******************************************************************************/
void KGrGame::incScore (int n)
void KGrGame::incScore (const int n)
{
#ifdef ENABLE_SOUND_SUPPORT
// I don't think this is the right place, but it's just for testing...
......
......@@ -95,7 +95,7 @@ public slots:
void showHighScores(); // Show high scores for current game.
void incScore (int); // Update the score.
void incScore (const int); // Update the score.
void showHiddenLadders(); // Show hidden ladders (nuggets gone).
void endLevel (const int result); // Hero completed the level or he died.
void herosDead(); // Hero was caught or he quit (key Q).
......
......@@ -37,6 +37,7 @@
KGrLevelPlayer::KGrLevelPlayer (QObject * parent)
:
QObject (parent),
game (parent),
hero (0),
controlMode (MOUSE),
nuggets (0),
......@@ -211,6 +212,14 @@ void KGrLevelPlayer::init (KGrCanvas * view, const int mode,
Direction, AnimationType)));
}
// Connect the scoring.
connect (hero, SIGNAL (incScore (const int)),
game, SLOT (incScore (const int)));
foreach (KGrEnemy * enemy, enemies) {
connect (enemy, SIGNAL (incScore (const int)),
game, SLOT (incScore (const int)));
}
// Connect the level player to the animation code (for use with dug bricks).
connect (this, SIGNAL (startAnimation (int, bool, int, int, int,
Direction, AnimationType)),
......
......@@ -275,6 +275,7 @@ private slots:
void doDig (int button); // Dig using mouse-buttons.
private:
QObject * game;
KGrLevelGrid * grid;
KGrRuleBook * rules;
KGrHero * hero;
......
......@@ -135,6 +135,7 @@ HeroStatus KGrHero::run (const int scaledTime)
char cell = grid->cellType (gridI, gridJ);
if (cell == NUGGET) {
nuggets = levelPlayer->runnerGotGold (spriteId, gridI, gridJ, true);
emit incScore (250); // Add to the human player's score.
}
Direction nextDirection = levelPlayer->getDirection (gridI, gridJ);
......@@ -289,6 +290,7 @@ void KGrEnemy::run (const int scaledTime)
// TODO - What if >1 enemy has occupied a cell somehow?
// TODO - Effect on CPU time of more frequent BRICK checks ...
releaseCell (gridI + deltaX, gridJ + deltaY);
emit incScore (75); // Add to the human player's score.
dieAndReappear(); // Move to a new (gridI, gridJ).
reserveCell (gridI, gridJ);
// No return: treat situation as EndCell.
......@@ -301,6 +303,7 @@ void KGrEnemy::run (const int scaledTime)
<< "Falling into hole at:" << gridI << (gridJ + 1);
grid->changeCellAt (gridI, gridJ + 1, USEDHOLE);
dropGold();
emit incScore (75); // Add to the human player's score.
return;
}
......
......@@ -66,6 +66,13 @@ public:
x = gridX; y = gridY; return pointsPerCell; }
signals:
/**
* Requests the KGoldrunner game to add to the human player's score.
*
* @param n The amount to add to the score.
*/
void incScore (const int n);
/**
* Requests the view-object to display an animation of a runner at a
* particular cell, cancelling and superseding any current animation.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment