void RoLoginState::serverConnectResponse(RoNetServerType type, RoOptionalString error) { if (error.is_initialized()) { std::cerr << "[FAILED]" << std::endl; std::cerr << "\tReason: " << error.get() << std::endl; auto currentState = getCurrentStage(); changeStage(currentState, RoLoginStage::NONE); return; } std::cout << "[SUCCESS]" << std::endl; auto currentStage = RoLoginStage::LOGIN_SERVER_CONNECTING; if (getCurrentStage() != currentStage) { std::cerr << "Punting logging in due to unexpected stage" << std::endl; return; } if (!mUsername || !mPassword) { std::cerr << "Login credential is not initialized! Aborting login!" << std::endl; mLoginServer->disconnect(); return; } if (changeStage(currentStage, RoLoginStage::LOGIN_REQUEST_SENT)) { std::cout << "Logging in using credentials provided... "; RoLoginServerInterface::LoginCallback callback = std::bind(&RoLoginState::loginResponse, this, std::placeholders::_1); mLoginServer->login(mUsername.get(), mPassword.get(), callback); mUsername.reset(); mPassword.reset(); } }
void CrdPlnrCtp::handleDpchAppDoClose( DbsPlnr* dbsplnr , DpchEngPlnr** dpcheng ) { *dpcheng = new DpchEngPlnrConfirm(true, jref, ""); changeStage(dbsplnr, VecVSge::CLOSE); };
/* ARGSUSED1 */ void keyboard(unsigned char key, int x, int y) { switch(key) { case '1': case '2': case '3': case '4': case '5': case '6': changeStage(key - '0'); break; case 's': case 'S': stencilDecalEnable(! useStencil); break; case 'q': case 'Q': case '\033': exit(0); break; default: fprintf(stderr, "Push right mouse button for menu\n"); break; } }
//--------------------------------------- // kiểm tra kết thúc game. Nếu người chơi hết mạng hoặc căn cứ bị phá huỷ thì vẽ dòng chữ “GAMEOVER”, //game sẽ kết thúc sau màn ScoreState (ScoreState::get()->setEndAfter(true)). Nếu người chơi đã tiêu diệt //hết tank địch thì game sẽ chuyển tới stage StartingState sau màn ScoreState. Trước khi chuyển state, phải //gọi hàm CleanStage() để xoá các đối tượng của stage vừa mới chơi xong //-------------------------------------- void Map::checkEndGame() { if (_player->getLife() < 0 || _eagle->getEagleStatus() == EAGLE_STATUS::DEAD) { if (_posGameOverText.y > POS_END_GAMEOVER_Y) { _posGameOverText.y -= 10; } if (GameTime::DelayTime(_delayEndStage)) { CleanStage(); ScoreState::get()->setEndAfter(true); GameState::switchState(ScoreState::get()); } return; } if (_numEnemy == _maxEnemy && _listEnemyOnMap->size() == 0) { if (GameTime::DelayTime(_delayEndStage)) { CleanStage(); StageManager::getInstance()->nextStage(); if (StageManager::getInstance()->getStage() <= DEFAULT_MAX_STAGE) { changeStage(); } GameState::switchState(ScoreState::get()); } } }
void CrdFmncArt::handleDpchAppDoMitAppAbtClick( DbsFmnc* dbsfmnc , DpchEngFmnc** dpcheng ) { // IP handleDpchAppDoMitAppAbtClick --- BEGIN changeStage(dbsfmnc, VecVSge::ALRFMNCABT, dpcheng); // IP handleDpchAppDoMitAppAbtClick --- END };
bool TMainStage::OnMessage( unsigned key , bool isDown ) { if ( !isDown ) return true; if ( key == VK_OEM_3 ) { changeStage( GS_CONSOLE ); return false; } else if ( key == VK_TAB ) { changeStage( GS_PROFILE , true ); return false; } return true; }
void CrdPlnrCtp::handleDpchAppDoMitAppAbtClick( DbsPlnr* dbsplnr , DpchEngPlnr** dpcheng ) { // IP handleDpchAppDoMitAppAbtClick --- BEGIN changeStage(dbsplnr, VecVSge::ALRPLNRABT, dpcheng); // IP handleDpchAppDoMitAppAbtClick --- END };
void DlgFmncPrjImpelb::handleUpload( DbsFmnc* dbsfmnc , const string& filename ) { // IP handleUpload --- BEGIN if (ixVSge == VecVSge::IDLE) { // IP handleUpload.prsidle --- IBEGIN infilename = filename; // IP handleUpload.prsidle --- IEND changeStage(dbsfmnc, VecVSge::PRSIDLE); } else if (ixVSge == VecVSge::IMPDONE) { // IP handleUpload.upkidle --- IBEGIN infilename = filename; // IP handleUpload.upkidle --- IEND changeStage(dbsfmnc, VecVSge::UPKIDLE); }; // IP handleUpload --- END };
void CrdFmncArt::handleDpchAppDoClose( DbsFmnc* dbsfmnc , DpchEngFmnc** dpcheng ) { muteRefresh = true; *dpcheng = new DpchEngFmncConfirm(true, jref, ""); changeStage(dbsfmnc, VecVSge::CLOSE); };
void RoLoginState::loginResponse(optional<RoLoginFailed> error) { auto currentStage = RoLoginStage::LOGIN_REQUEST_SENT; if (error) { std::cout << "[FAILED]" << std::endl; const auto& loginFailed = error.get(); std::cout << "\tReason: " << loginFailed.getReason() << std::endl; std::cout << "\tDetail: " << loginFailed.getDetail() << std::endl; if (changeStage(currentStage, RoLoginStage::LOGIN_SUCCEEDED)) { mLoginServer->disconnect(); } } else if (changeStage(currentStage, RoLoginStage::LOGIN_SUCCEEDED)) { mGame->setGameState(RoGameStates::CHARACTER_SERVER_SELECT); } }
void DlgFmncPrjImpelb::handleTimer( DbsFmnc* dbsfmnc , const string& sref ) { if (ixVSge == VecVSge::PRSIDLE) { changeStage(dbsfmnc, nextIxVSge); } else if (ixVSge == VecVSge::IMPIDLE) { changeStage(dbsfmnc, nextIxVSge); } else if ((ixVSge == VecVSge::IMPORT) && (sref == "mon")) { wrefLast = xchg->addWakeup(jref, "mon", 250000, true); // IP handleTimer.import.mon --- IBEGIN set<uint> moditems; refresh(dbsfmnc, moditems); xchg->submitDpch(getNewDpchEng(moditems)); // IP handleTimer.import.mon --- IEND } else if (ixVSge == VecVSge::UPKIDLE) { changeStage(dbsfmnc, nextIxVSge); }; };
void DlgFmncPrjImpelb::handleDpchAppFmncAlert( DbsFmnc* dbsfmnc , DpchAppFmncAlert* dpchappfmncalert , DpchEngFmnc** dpcheng ) { // IP handleDpchAppFmncAlert --- IBEGIN if (ixVSge == VecVSge::ALRFMNCPER) { changeStage(dbsfmnc, nextIxVSge); }; // IP handleDpchAppFmncAlert --- IEND };
void CrdPlnrCtp::handleDpchAppPlnrAlert( DbsPlnr* dbsplnr , DpchAppPlnrAlert* dpchappplnralert , DpchEngPlnr** dpcheng ) { if (ixVSge == VecVSge::ALRPLNRABT) { changeStage(dbsplnr, VecVSge::IDLE); }; *dpcheng = new DpchEngPlnrConfirm(true, jref, ""); };
void CrdFmncArt::handleDpchAppFmncAlert( DbsFmnc* dbsfmnc , DpchAppFmncAlert* dpchappfmncalert , DpchEngFmnc** dpcheng ) { if (ixVSge == VecVSge::ALRFMNCABT) { changeStage(dbsfmnc, VecVSge::IDLE); }; *dpcheng = new DpchEngFmncConfirm(true, jref, ""); };
void DlgFmncPrjImpelb::handleDpchAppDoImpButRunClick( DbsFmnc* dbsfmnc , DpchEngFmnc** dpcheng ) { // IP handleDpchAppDoImpButRunClick --- BEGIN if (statshrimp.ButRunActive) { if (ixVSge == VecVSge::PRSDONE) { changeStage(dbsfmnc, VecVSge::IMPIDLE, dpcheng); }; }; // IP handleDpchAppDoImpButRunClick --- END };
CrdFmncPrj::CrdFmncPrj( XchgFmnc* xchg , DbsFmnc* dbsfmnc , const ubigint jrefSup , const uint ixFmncVLocale , const ubigint ref ) : JobFmnc(xchg, VecFmncVJob::CRDFMNCPRJ, jrefSup, ixFmncVLocale) { // IP constructor.addJob --- BEGIN jref = xchg->addJob(this); // IP constructor.addJob --- END feedFMcbAlert.tag = "FeedFMcbAlert"; feedFSge.tag = "FeedFSge"; VecVSge::fillFeed(feedFSge); dlgexpelb = NULL; dlgimpelb = NULL; dlgnew = NULL; pnlrec = NULL; pnlheadbar = NULL; pnllist = NULL; // IP constructor.cust1 --- INSERT // initialize according to ref changeRef(dbsfmnc, jref, ((ref+1) == 0) ? 0 : ref, false); pnlrec = new PnlFmncPrjRec(xchg, dbsfmnc, jref, ixFmncVLocale); pnlheadbar = new PnlFmncPrjHeadbar(xchg, dbsfmnc, jref, ixFmncVLocale); pnllist = new PnlFmncPrjList(xchg, dbsfmnc, jref, ixFmncVLocale); // IP constructor.cust2 --- INSERT statshr.jrefHeadbar = pnlheadbar->jref; statshr.jrefList = pnllist->jref; statshr.jrefRec = pnlrec->jref; if ((ref+1) == 0) { dlgnew = new DlgFmncPrjNew(xchg, dbsfmnc, jref, ixFmncVLocale); statshr.jrefDlgnew = dlgnew->jref; }; changeStage(dbsfmnc, VecVSge::IDLE); xchg->addClstn(VecFmncVCall::CALLFMNCDLGCLOSE, jref, Clstn::VecVJobmask::IMM, 0, Arg(), Clstn::VecVJactype::LOCK); xchg->addClstn(VecFmncVCall::CALLFMNCSTATCHG, jref, Clstn::VecVJobmask::IMM, 0, Arg(), Clstn::VecVJactype::LOCK); xchg->addClstn(VecFmncVCall::CALLFMNCREFPRESET, jref, Clstn::VecVJobmask::TREE, 0, Arg(), Clstn::VecVJactype::LOCK); // IP constructor.cust3 --- INSERT // IP constructor.spec3 --- INSERT };
CrdPlnrLyr::CrdPlnrLyr( XchgPlnr* xchg , DbsPlnr* dbsplnr , const ubigint jrefSup , const uint ixPlnrVLocale , const ubigint ref , const uint ixPlnrVPreset , const ubigint preUref ) : JobPlnr(xchg, VecPlnrVJob::CRDPLNRLYR, jrefSup, ixPlnrVLocale) { // IP constructor.addJob --- BEGIN jref = xchg->addJob(this); // IP constructor.addJob --- END feedFMcbAlert.tag = "FeedFMcbAlert"; feedFSge.tag = "FeedFSge"; VecVSge::fillFeed(feedFSge); pnlrec = NULL; pnlheadbar = NULL; pnllist = NULL; // IP constructor.cust1 --- INSERT muteRefresh = false; xchg->addIxPreset(VecPlnrVPreset::PREPLNRIXPRE, jref, ixPlnrVPreset); if (ixPlnrVPreset != VecPlnrVPreset::VOID) xchg->addRefPreset(ixPlnrVPreset, jref, preUref); // initialize according to ref changeRef(dbsplnr, jref, ref, false); pnlrec = new PnlPlnrLyrRec(xchg, dbsplnr, jref, ixPlnrVLocale); pnlheadbar = new PnlPlnrLyrHeadbar(xchg, dbsplnr, jref, ixPlnrVLocale); pnllist = new PnlPlnrLyrList(xchg, dbsplnr, jref, ixPlnrVLocale); // IP constructor.cust2 --- INSERT statshr.jrefHeadbar = pnlheadbar->jref; statshr.jrefList = pnllist->jref; statshr.jrefRec = pnlrec->jref; changeStage(dbsplnr, VecVSge::IDLE); xchg->addClstn(VecPlnrVCall::CALLPLNRDLGCLOSE, jref, Clstn::VecVJobmask::IMM, 0, Arg(), Clstn::VecVJactype::LOCK); xchg->addClstn(VecPlnrVCall::CALLPLNRSTATCHG, jref, Clstn::VecVJobmask::IMM, 0, Arg(), Clstn::VecVJactype::LOCK); xchg->addClstn(VecPlnrVCall::CALLPLNRREFPRESET, jref, Clstn::VecVJobmask::TREE, 0, Arg(), Clstn::VecVJactype::LOCK); // IP constructor.cust3 --- INSERT // IP constructor.spec3 --- INSERT };
CrdFmncFus::CrdFmncFus( XchgFmnc* xchg , DbsFmnc* dbsfmnc , const ubigint jrefSup , const uint ixFmncVLocale , const ubigint ref , const uint ixFmncVPreset , const ubigint preUref ) : JobFmnc(xchg, VecFmncVJob::CRDFMNCFUS, jrefSup, ixFmncVLocale) { // IP constructor.addJob --- BEGIN jref = xchg->addJob(this); // IP constructor.addJob --- END feedFMcbAlert.tag = "FeedFMcbAlert"; feedFSge.tag = "FeedFSge"; VecVSge::fillFeed(feedFSge); pnlrec = NULL; pnlheadbar = NULL; pnllist = NULL; // IP constructor.cust1 --- INSERT xchg->addIxPreset(VecFmncVPreset::PREFMNCIXPRE, jref, ixFmncVPreset); if (ixFmncVPreset != VecFmncVPreset::VOID) xchg->addRefPreset(ixFmncVPreset, jref, preUref); // initialize according to ref changeRef(dbsfmnc, jref, ((ref+1) == 0) ? 0 : ref, false); pnlrec = new PnlFmncFusRec(xchg, dbsfmnc, jref, ixFmncVLocale); pnlheadbar = new PnlFmncFusHeadbar(xchg, dbsfmnc, jref, ixFmncVLocale); pnllist = new PnlFmncFusList(xchg, dbsfmnc, jref, ixFmncVLocale); // IP constructor.cust2 --- INSERT statshr.jrefHeadbar = pnlheadbar->jref; statshr.jrefList = pnllist->jref; statshr.jrefRec = pnlrec->jref; changeStage(dbsfmnc, VecVSge::IDLE); xchg->addClstn(VecFmncVCall::CALLFMNCDLGCLOSE, jref, Clstn::VecVJobmask::IMM, 0, Arg(), Clstn::VecVJactype::LOCK); xchg->addClstn(VecFmncVCall::CALLFMNCSTATCHG, jref, Clstn::VecVJobmask::IMM, 0, Arg(), Clstn::VecVJactype::LOCK); xchg->addClstn(VecFmncVCall::CALLFMNCREFPRESET, jref, Clstn::VecVJobmask::TREE, 0, Arg(), Clstn::VecVJactype::LOCK); // IP constructor.cust3 --- INSERT // IP constructor.spec3 --- INSERT };
bool TConsoleStage::OnMessage( unsigned key , bool isDown ) { if ( !isDown ) return false; switch( key ) { case VK_OEM_3: changeStage( GS_MAIN ); break;; case VK_RETURN: g_console.doCommand(); break; case VK_BACK: g_console.popChar(); break; case VK_UP: g_console.setSaveString(-1); break; case VK_DOWN: g_console.setSaveString(1); break; case VK_TAB: g_console.setFindCommand(1); break; } return false; }
void DlgFmncSmpNew::handleDpchAppDoButCreClick( DbsFmnc* dbsfmnc , DpchEngFmnc** dpcheng ) { // IP handleDpchAppDoButCreClick --- RBEGIN if (statshr.ButCreActive) { if (ixVSge == VecVSge::IDLE) { changeStage(dbsfmnc, VecVSge::CREATE); }; if (ixVSge == VecVSge::DONE) { if (!*dpcheng) *dpcheng = new DpchEngFmncConfirm(true, jref, ""); xchg->triggerCall(dbsfmnc, VecFmncVCall::CALLFMNCDLGCLOSE, jref); }; }; // IP handleDpchAppDoButCreClick --- REND };
bool RoLoginState::updateState(float timeSinceLastFrameInSecs) { auto stage = getCurrentStage(); bool continueState = true; switch (stage) { case RoLoginStage::NONE: if (mLoginServer->isConnected()) { mLoginServer->disconnect(); } changeStage(stage, RoLoginStage::LOGIN_PROMPT); roSCHEDULE_TASK_NAMED(LOGIN_PROMPT_TASK, RoEmptyArgs::INSTANCE); break; case RoLoginStage::LOGIN_CANCELLED: exitGame(); continueState = false; break; } return continueState; }
Map::Map(LPD3DXSPRITE spriteHandler) { //init rectangleRespawn _rectangleEnemyRespawn = new vector<MyRectangle*>; _playerRespawnPos = new vector<MyRectangle*>; for (int i = 0; i < NUM_RESPAWN_POS;i++) { _rectangleEnemyRespawn->push_back(new MyRectangle(POS_RESPAWN_Y, POS_RESPAWN_X + i*DISTANCE_RESPAWN_POS_X, SPRITE_WIDTH, SPRITE_WIDTH, 0, 0)); } for (int i = 0; i < NUM_RESPAWN_POS - 1; i++) { if (i == 0) { _playerRespawnPos->push_back(new MyRectangle(DEFAULT_PLAYER_POSITION_Y, DEFAULT_PLAYER_POSITION_X, SPRITE_WIDTH, SPRITE_HEIGHT)); } else if (i == 1) { _playerRespawnPos->push_back(new MyRectangle(DEFAULT_PLAYER_POSITION_Y, DEFAULT_PLAYER_POSITION_X_2, SPRITE_WIDTH, SPRITE_HEIGHT)); } } _spriteHandler = spriteHandler; _spriteHandler->GetDevice(&_d3ddev); _text = new Text(_spriteHandler); _spriteItemManager = new SpriteMapItemMagager(_spriteHandler); _powerUpItem = new PowerUp(_spriteItemManager->getPowerUpItem(),_text); _respawnEffect = _spriteItemManager->getRespawnSprite(); _eagle = new Eagle(_spriteItemManager->getEagleSprite(), getPositionFromMapMatrix(POS_EAGLE_IN_MATRIX_ROW, POS_EAGLE_IN_MATRIX_COL)); _player = new PlayerTank(_spriteHandler); _listEnemy = new vector<Enemy*>; _listEnemyOnMap = new vector<Enemy*>; _mapMatrix = new int*[NUM_ROW_TILE]; for (short i = 0; i < NUM_ROW_TILE; i++) { _mapMatrix[i] = new int[NUM_COLUMN_TILE]; } BulletManager::getInstance(); EffectManager::getInstance(_spriteHandler); changeStage(); }
void RoLoginState::loginPrompt(const RoTaskArgs& args) { auto currentStage = getCurrentStage(); if (RoLoginStage::LOGIN_PROMPT != currentStage) { std::cerr << "Invalid state for login prompt(" << roGetLoginStageString(currentStage) << "). Resetting!" << std::endl; mStage.store(RoLoginStage::NONE); return; } auto username = RoCli::ReadString("Enter Username: "******"Enter Password: "******"Connecting to login server... "; // FIXME: This should come from clientinfo.xml RoLoginServerInterface::ConnectCallback callback = std::bind( &RoLoginState::serverConnectResponse, this, std::placeholders::_1, std::placeholders::_2); mLoginServer->connect(L"127.0.0.1", L"6900", callback); } }
//--------------------------------------- // Dọn dẹp map game để chuẩn bị load map sau. //-------------------------------------- void Map::reset() { _player->reset(); changeStage(); }
void StageManager::changeFloor( int floorNum ) { initFloor(floorNum); changeStage( 1 , Point( 100 , 100 ) ); GET_EFFECT_MANAGER()->createSound( SoundType::SO_SAGA_BGM , true ); }
void StateSkill::execute(StateBase* parent) { BatCmdSkill* cmd = getCmd(); auto battleInfo = getBattleInfo(); auto ps = battleInfo->getPet(cmd->petUid); auto skill = ps->getSkillInfo(cmd->sid); ps->isActioned = true; if (ps->isDead || !ps->isBating) { return exitState(); } if (ps->isUnableAction) { return exitState(); } // 技能计算开始 // 生成技能运算公共数据 shared_ptr<FireSkill> fireInfo(new FireSkill); assign(fireInfo.get(), skill, skill->keySkill, 0); fireInfo->parent = nullptr; fireInfo->origin = battleInfo->topSkill() != nullptr ? battleInfo->topSkill().get() : nullptr; fireInfo->targets = fixedTargets(cmd->params, fireInfo.get(), skill->belongs.owner, skill->keySkill->target, 0); if (fireInfo->targets.size() == 0) { return exitState(); } // 压入栈 battleInfo->pushSkill(fireInfo); // 行动开始,可修改技能及目标 battleInfo->changeStage(Stage::ActionBegin); skill = fireInfo->skill; // 技能可能已被修改 // 技能释放 BatSeqSkill* s = new BatSeqSkill; s->petUid = fireInfo->firer; s->sid = fireInfo->skill->sid; s->params = fireInfo->targets; battleInfo->pushSeq(shared_ptr<ISeq>(s)); // 以次计算每个目标 // for (int i=0; i<fireInfo->targets.size(); i++) { // int dstuid = fireInfo->targets[i]; // // assign(fireInfo.get(), skill, skill->keySkill, dstuid); // createEffect(skill->keySkill->subType, skill->keySkill->subId)->execute(); // // if (!fireInfo->curr.isHit || fireInfo->isCancel) { // continue; // } // // // 计算次效果 // for (auto subsk : skill->keySkill->subs) { // shared_ptr<FireInfo> subfireInfo(new FireInfo); // subfireInfo->origin = fireInfo->origin; // subfireInfo->parent = fireInfo.get(); // fireInfo->children.push_back(subfireInfo); // // assign(subfireInfo.get(), skill, subsk.get(), dstuid); // pushSkill(subfireInfo); // // createEffect(subsk->subType, subsk->subId)->execute(); // // popSkill(); // } // // fireInfo->children.clear(); // } // // checkDead(fireInfo->targets); // // ps->onActioned(true); // // fireInfo->effect.cost.pp = 1; // changeStage(Stage::ActionEnd); // // if (keySkill->ppNum != -1) { // // BatSeqPP* pp = new BatSeqPP; // pp->petUid = fireInfo->firer; // pp->sid = fireInfo->sid; // pp->pp = fireInfo->effect.cost.pp; // pushSeq(BatSeqPtr(pp)); // } // // popSkill(); exitState(); }
ProtoGame::ProtoGame () : Game (Vector2D (800,600), "Proto-Game", true) { myStage = new MyStage (this); changeStage (myStage); }