[rabahyo@quark Software_Engineering] diff -c ModuleProfessor_old.cpp ModuleProfessor_new.cpp *** ModuleProfessor_old.cpp Tue Apr 22 20:34:18 2003 --- ModuleProfessor_new.cpp Wed Apr 23 14:57:48 2003 *************** *** 20,31 **** class ProfessorBehavior : public Behavior { public: ProfessorBehavior() : Behavior() { ! this->clear(); }; ~ProfessorBehavior() {}; void onTick() { Table * table = Table::getInstance(); // launch ball string launch("launch"); if (table->active() == 0 && --- 20,72 ---- class ProfessorBehavior : public Behavior { public: ProfessorBehavior() : Behavior() { ! Loader * loader = Loader::getInstance(); ! // init signals ! m_sigGameStart = loader->getSignal("game_start"); ! m_sigBump = loader->getSignal("bump"); ! m_sigJackpot = loader->getSignal("jackpot"); ! m_sigExtraBall = loader->getSignal("extraball"); ! m_sigAllBallsOff = loader->getSignal("allballs_off"); ! m_sigMultiballOff = loader->getSignal("multiball_off"); ! m_sigReleaseLock = loader->getSignal("releaselock"); ! m_sigLeftLoop = loader->getSignal("leftloop"); ! m_sigRightLoop = loader->getSignal("rightloop"); ! m_sigProfessorAll = loader->getSignal("professor_all"); ! m_sigProfessor[0] = loader->getSignal("professort"); ! m_sigProfessor[1] = loader->getSignal("professoru"); ! m_sigProfessor[2] = loader->getSignal("professorx"); ! m_sigProfessorOn[0] = loader->getSignal("professort_on"); ! m_sigProfessorOn[1] = loader->getSignal("professoru_on"); ! m_sigProfessorOn[2] = loader->getSignal("professorx_on"); ! m_sigProfessorOff[0] = loader->getSignal("professort_off"); ! m_sigProfessorOff[1] = loader->getSignal("professoru_off"); ! m_sigProfessorOff[2] = loader->getSignal("professorx_off"); ! m_sigBootAll = loader->getSignal("boot_all"); ! m_sigBoot[0] = loader->getSignal("bootb"); ! m_sigBoot[1] = loader->getSignal("booto"); ! m_sigBoot[2] = loader->getSignal("bootoo"); ! m_sigBoot[3] = loader->getSignal("boott"); ! m_sigBootOn[0] = loader->getSignal("bootb_on"); ! m_sigBootOn[1] = loader->getSignal("booto_on"); ! m_sigBootOn[2] = loader->getSignal("bootoo_on"); ! m_sigBootOn[3] = loader->getSignal("boott_on"); ! m_sigBootOff[0] = loader->getSignal("bootb_off"); ! m_sigBootOff[1] = loader->getSignal("booto_off"); ! m_sigBootOff[2] = loader->getSignal("bootoo_off"); ! m_sigBootOff[3] = loader->getSignal("boott_off"); ! m_sigMultiplier[0] = loader->getSignal("multiplier1"); ! m_sigMultiplier[1] = loader->getSignal("multiplier2"); ! m_sigMultiplier[2] = loader->getSignal("multiplier3"); ! m_sigMultiplier[3] = loader->getSignal("multiplier4"); ! m_sigMultiplier[4] = loader->getSignal("multiplier5"); ! this->clear(); }; ~ProfessorBehavior() {}; void onTick() { Table * table = Table::getInstance(); + Score * score = table->getScore(); + EmAssert(score != NULL, "ProfessorBehavior::onTick socre NULL"); // launch ball string launch("launch"); if (table->active() == 0 && *************** *** 34,40 **** switch (table->getCurrentBall()) { case 0 : if (table->isBallDead(0) ) { - // SendSignal( m_sigGameStart, 0, this->getParent(), NULL ); SendSignal( PBL_SIG_BALL_ON, 0, this->getParent(), NULL ); table->activateBall(0); //score->clearText(); --- 75,80 ---- *************** *** 71,76 **** --- 111,117 ---- } EM_COUT("Table::onTick() new ball", 1); } + EM_COUT("ProfessorBehavior::onTick done", 0); }; void StdOnCollision() {}; *************** *** 78,107 **** void StdOnSignal() { //EM_COUT((int)em_signal, 1); Table * table = Table::getInstance(); OnSignal( PBL_SIG_RESET_ALL ) { this->clear(); ! } else ! // ball dead ! OnSignal( PBL_SIG_BALL_OFF ) { if (table->active() == 1) { SendSignal( PBL_SIG_MULTIBALL_OFF, 0, this->getParent(), NULL ); } if (table->active() == 0) { //NO ACTIVE BALL ! EM_COUT("game over", 1);*/ ! if (table->getCurrentBall() < MAX_BALL) { table->setCurrentBall(table->getCurrentBall()+1); ! }else { SendSignal( PBL_SIG_GAME_OVER, 0, this->getParent(), NULL ); ! } } } } ! void clear() { }; private: }; extern "C" void * new_object_fct(void) { return new ProfessorBehavior(); } - --- 119,325 ---- void StdOnSignal() { //EM_COUT((int)em_signal, 1); Table * table = Table::getInstance(); + Score * score = table->getScore(); + EmAssert(score != NULL, "ProfessorBehavior::StdOnSignal score NULL"); OnSignal( PBL_SIG_RESET_ALL ) { this->clear(); ! } ! // ball dead ! ElseOnSignal( PBL_SIG_BALL_OFF ) { if (table->active() == 1) { SendSignal( PBL_SIG_MULTIBALL_OFF, 0, this->getParent(), NULL ); } if (table->active() == 0) { //NO ACTIVE BALL ! if (table->getCurrentBall() < MAX_BALL) { table->setCurrentBall(table->getCurrentBall()+1); ! }else { SendSignal( PBL_SIG_GAME_OVER, 0, this->getParent(), NULL ); ! EM_COUT("game over", 1); ! } ! } ! } ! ! // multiball ! ElseOnSignal( m_sigReleaseLock ) { ! table->unLockBall(0); ! table->unLockBall(1); ! table->unLockBall(2); ! m_bMultiBallOn = false; ! score->addScore(10000); ! } ! ! // bump ! ElseOnSignal(m_sigBump) { ! score->addScore(450 * m_iMultiplier); ! } ! ! // Professor ! ElseOnSignal(m_sigProfessor[0]) { ! if (!m_aProfessor[0]) { ! SendSignal(m_sigProfessorOn[0], 0, this->getParent(), NULL); ! m_aProfessor[0] = true; ! } ! score->addScore(500); ! } ! ElseOnSignal(m_sigProfessor[1]) { ! if (!m_aProfessor[1]) { ! SendSignal(m_sigProfessorOn[1], 0, this->getParent(), NULL); ! m_aProfessor[1] = true; ! } ! score->addScore(500); ! } ! ElseOnSignal(m_sigProfessor[2]) { ! if (!m_aProfessor[2]) { ! SendSignal(m_sigProfessorOn[2], 0, this->getParent(), NULL); ! m_aProfessor[2] = true; ! } ! score->addScore(500); ! } ! // BOOT ! ElseOnSignal( m_sigBoot[0] ) { ! if (m_aBoot[0]) { ! SendSignal(m_sigBootOff[0], 0, this->getParent(), NULL); ! m_aBoot[0] = false; ! } else { ! SendSignal(m_sigBootOn[0], 0, this->getParent(), NULL); ! m_aBoot[0] = true; ! } ! score->addScore(50); ! } ! ElseOnSignal( m_sigBoot[1] ) { ! if (m_aBoot[1]) { ! SendSignal(m_sigBootOff[1], 0, this->getParent(), NULL); ! m_aBoot[1] = false; ! } else { ! SendSignal(m_sigBootOn[1], 0, this->getParent(), NULL); ! m_aBoot[1] = true; ! } ! score->addScore(50); ! } ! ElseOnSignal( m_sigBoot[2] ) { ! if (m_aBoot[2]) { ! SendSignal(m_sigBootOff[2], 0, this->getParent(), NULL); ! m_aBoot[2] = false; ! } else { ! SendSignal(m_sigBootOn[2], 0, this->getParent(), NULL); ! m_aBoot[2] = true; ! } ! score->addScore(50); ! } ! ElseOnSignal( m_sigBoot[3] ) { ! if (m_aBoot[3]) { ! SendSignal(m_sigBootOff[3], 0, this->getParent(), NULL); ! m_aBoot[3] = false; ! } else { ! SendSignal(m_sigBootOn[3], 0, this->getParent(), NULL); ! m_aBoot[3] = true; ! } ! score->addScore(50); ! } ! ElseOnSignal( PBL_SIG_LEFTARM_ON ) { ! // BOOT ! bool tmp = m_aBoot[0]; ! for (int a=0; a<3; ++a) { ! if (m_aBoot[a] != m_aBoot[a+1]) { ! m_aBoot[a] = m_aBoot[a+1]; ! if (m_aBoot[a]) SendSignal(m_sigBootOn[a], 0, this->getParent(), NULL); ! else SendSignal(m_sigBootOff[a], 0, this->getParent(), NULL); ! } ! } ! if (m_aBoot[3] != tmp) { ! m_aBoot[3] = tmp; ! if (m_aBoot[3]) SendSignal(m_sigBootOn[3], 0, this->getParent(), NULL); ! else SendSignal(m_sigBootOff[3], 0, this->getParent(), NULL); ! } ! } ! ! ElseOnSignal( PBL_SIG_RIGHTARM_ON ) { ! // BOOT ! bool tmp = m_aBoot[3]; ! for (int a=3; a>0; --a) { ! if (m_aBoot[a] != m_aBoot[a-1]) { ! m_aBoot[a] = m_aBoot[a-1]; ! if (m_aBoot[a]) SendSignal(m_sigBootOn[a], 0, this->getParent(), NULL); ! else SendSignal(m_sigBootOff[a], 0, this->getParent(), NULL); } } + if (m_aBoot[0] != tmp) { + m_aBoot[0] = tmp; + if (m_aBoot[0]) SendSignal(m_sigBootOn[0], 0, this->getParent(), NULL); + else SendSignal(m_sigBootOff[0], 0, this->getParent(), NULL); + } + } + + ElseOnSignal(m_sigRightLoop) { + if (m_bExtraBallWaiting) { + SendSignal( m_sigExtraBall, 0, this->getParent(), NULL ); + m_bExtraBall = true; + m_bExtraBallWaiting = false; + } + score->addScore(1500); + } + ElseOnSignal(m_sigLeftLoop) { + if (m_bMultiBallOn) { + SendSignal( m_sigJackpot, 0, this->getParent(), NULL ); + score->addScore(100000); + } + score->addScore(1500); + } + + // PROFESSOR for all + if (m_aProfessor[0] && m_aProfessor[1] && m_aProfessor[2]) { + SendSignal(m_sigProfessorAll, 0, this->getParent(), NULL); + m_aProfessor[0] = m_aProfessor[1] = m_aProfessor[2] = false; + m_bExtraBallWaiting = true; + score->addScore(5000); + } + // BOOT all + if (m_aBoot[0] && m_aBoot[1] && m_aBoot[2] && m_aBoot[3]) { + SendSignal(m_sigBootAll, 0, this->getParent(), NULL); + m_aBoot[0] = m_aBoot[1] = m_aBoot[2] = m_aBoot[3] = false; + score->addScore(5000); } } ! ! void clear() { ! m_iMultiplier = 1; ! m_aBoot[0] = false; ! m_aBoot[1] = false; ! m_aBoot[2] = false; ! m_aBoot[3] = false; ! m_aProfessor[0] = false; ! m_aProfessor[1] = false; ! m_aProfessor[2] = false; ! m_bExtraBall = false; ! m_bExtraBallWaiting = false; ! m_bMultiBallOn = false; }; private: + int m_iMultiplier; + int m_sigGameStart; + int m_sigBump; + int m_sigJackpot; + int m_sigAllBallsOff; + int m_sigExtraBall; + int m_sigMultiballOff; + int m_sigReleaseLock; + int m_sigLeftLoop; + int m_sigRightLoop; + int m_sigProfessorAll; + int m_sigProfessor[3]; + int m_sigProfessorOn[3]; + int m_sigProfessorOff[3]; + int m_sigBootAll; + int m_sigBoot[4]; + int m_sigBootOn[4]; + int m_sigBootOff[4]; + int m_sigMultiplier[4]; + bool m_aBoot[4]; + bool m_aProfessor[3]; + bool m_bExtraBall; + bool m_bExtraBallWaiting; + bool m_bMultiBallOn; }; extern "C" void * new_object_fct(void) { return new ProfessorBehavior(); } [1]- Done emacs ModuleProfessor_old.cpp [2]+ Done emacs ModuleProfessor_new.cpp [rabahyo@quark Software_Engineering]