1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
//#ident "$Id: ModuleProfessor.cpp,v 1.8 2003/07/16 20:02:04 rzr Exp $"
/***************************************************************************
Score.cpp - description
-------------------
begin : Fri Jan 26 2001
copyright : (C) 2001 by Henrik Enqvist
email : henqvist@excite.com
***************************************************************************/
#include "Private.h"
//#include "Keyboard.h"
#include "Config.h"
#include "Behavior.h"
#include "Group.h"
#include "Pinball.h"
#include "Loader.h"
#include "StateMachine.h"
#include "Table.h"
#include "Score.h"
class ProfessorBehavior : public Behavior {
public:
ProfessorBehavior() : Behavior() {
this->clear();
};
~ProfessorBehavior() {};
void onTick() {
Table * table = Table::getInstance();
Score * score = table->getScore();
Loader * loader = Loader::getInstance();
// init signals
EmAssert(score != NULL, "ProfessorBehavior::onTick socre NULL");
// launch ball
string launch("launch");
if (table->active() == 0 &&
table->getCurrentBall() < MAX_BALL) {
switch (table->getCurrentBall()) {
case 0 :
if (table->isBallDead(0) ) {
SendSignal( loader->getSignal("game_start"), 0, this->getParent(), NULL );
SendSignal( PBL_SIG_BALL_ON, 0, this->getParent(), NULL );
table->activateBall(0, 19.5f, 0.0f, 30.0f);
//score->clearText();
break;
}
case 1 :
if (table->isBallDead(1)) {
SendSignal( PBL_SIG_BALL_ON, 0, this->getParent(), NULL );
table->activateBall(1, 19.5f, 0.0f, 30.0f);
//score->clearText();
break;
}
case 2 :
if (table->isBallDead(2)) {
SendSignal( PBL_SIG_BALL_ON, 0, this->getParent(), NULL );
table->activateBall(2, 19.5f, 0.0f, 30.0f);
//score->clearText();
break;
}
if (table->isBallDead(0)) {
SendSignal( PBL_SIG_BALL_ON, 0, this->getParent(), NULL );
table->activateBall(0, 19.5f, 0.0f, 30.0f);
//score->clearText();
break;
}
if (table->isBallDead(1)) {
SendSignal( PBL_SIG_BALL_ON, 0, this->getParent(), NULL );
table->activateBall(1, 19.5f, 0.0f, 30.0f);
//score->clearText();
break;
}
default:
throw string("all balls busy");
}
EM_COUT("Table::onTick() new ball", 1);
}
};
void StdOnCollision() {};
void StdOnSignal() {
//EM_COUT((int)em_signal, 1);
Table * table = Table::getInstance();
Score * score = table->getScore();
Loader * loader = Loader::getInstance();
OnSignal( PBL_SIG_RESET_ALL ) {
this->clear();
}
// ball dead
ElseOnSignal( PBL_SIG_BALL_OFF ) {
if (table->active() == 1) {
SendSignal( loader->getSignal("multiball_off"), 0, this->getParent(), NULL );
}
if (table->active() == 0) {
SendSignal( loader->getSignal("allballs_off"), 0, this->getParent(), NULL );
if (table->getCurrentBall() < MAX_BALL) {
table->setCurrentBall(table->getCurrentBall()+1);
if (table->getCurrentBall() == MAX_BALL) {
SendSignal( PBL_SIG_GAME_OVER, 0, this->getParent(), NULL );
EM_COUT("game over", 1);
}
}
}
}
ElseOnSignal(loader->getSignal("bump")) {
score->addScore(450);
}
}
void clear() {
};
private:
};
extern "C" void * new_object_fct(void) {
return new ProfessorBehavior();
}
|