void BoardHandler::slotNavNextBranch() { // if (gameMode == modeScore) // return; Q_CHECK_PTR(tree); Move *m = tree->getCurrent(), *remember = m; // Remember current in case we dont find a branch Q_CHECK_PTR(m); // We are already on a node with 2 or more sons? if (tree->getNumSons() > 1) { m = tree->nextMove(); updateAll_updateAll = true; updateMove(m); return; } // Descent tree to last son of main variation while (m->son != NULL && tree->getNumSons() <= 1) m = tree->nextMove(); if (m != NULL && m != remember) { if (m->son != NULL) m = tree->nextMove(); updateAll_updateAll = true; updateMove(m); } else tree->setCurrent(remember); }
void BoardHandler::gotoMove(Move *m) { Q_CHECK_PTR(m); tree->setCurrent(m); updateAll_updateAll = true; updateMove(m); }
void AvatarEntity::update(const float elapsedTime) { //Para actualizar el estado del avatar, miraremos primero en que estado estamos //Y despues llamamos a las funciones que actualizan segun el estado updateState(); switch(m_state) { case IDLE: updateIdle(elapsedTime); break; case PUNCH: updatePunch(elapsedTime); break; case JAB: updateJab(elapsedTime); break; case KICK: updateKick(elapsedTime); break; case LOWER: updateLower(elapsedTime); break; case MOVE: updateMove(elapsedTime); break; case JUMP: updateJump(elapsedTime); break; case DEFENSE: updateDefense(elapsedTime); break; } }
void Turret::serverProcessWaiting(DWORD in_currTime) { Parent::serverProcess(in_currTime); if (!getControlClient() && getState () == StaticBase::Enabled && isActive()) { targetsTracked = 0; Player *closePlayer = chooseTarget (); if (targetsTracked) sleepTime = manager->getCurrentTime() + 3.0; if (closePlayer) { if (state == EXTENDED) trackAndFire(closePlayer, 0.032); else extend (0.032); } else if (!targetsTracked && manager->getCurrentTime() > sleepTime) { if (state != RETRACTED) retract (0.032); } } if (!getControlClient()) updateMove (NULL, 0.032); else updateSkip++; }
void BoardHandler::slotNavNextComment() { // if (gameMode == modeScore) // return; Q_CHECK_PTR(tree); Move *m = tree->getCurrent()->son; while (m != NULL) { if (m->getComment() != "") break; if (m->son == NULL) break; m = m->son; } if (m != NULL) { tree->setCurrent(m); updateAll_updateAll = true; updateMove(m); } }
void Predator::update(){ this->setZOrder(MapManager::getInstance()->_mapHeight - this->getPositionY()); updateAI(); if (!isMoving() \ && GameManager::getInstance()->_gameState == (int)GameManager::GameState::IN_THE_GAME) { switch (_moveTrigger){ case CHARACTER_DIRECTION_DOWN: if (moveDown() == true){ _state = (int)State::WALK; _moveSpeed = PREDATOR_WALK_MOVE_SPEED; } break; case CHARACTER_DIRECTION_LEFT: if (moveLeft() == true){ _state = (int)State::WALK; _moveSpeed = PREDATOR_WALK_MOVE_SPEED; } break; case CHARACTER_DIRECTION_RIGHT: if (moveRight() == true){ _state = (int)State::WALK; _moveSpeed = PREDATOR_WALK_MOVE_SPEED; } break; case CHARACTER_DIRECTION_UP: if (moveUp() == true){ _state = (int)State::WALK; _moveSpeed = PREDATOR_WALK_MOVE_SPEED; } break; default: break; } } if (isMoving()) { updateMove(); } //若本帧不作任何移动 else { if (_state == (int)State::WALK) { _state = (int)State::STOP; } } updateFrame(); }
void BoardHandler::slotNavBackward() { // if (gameMode == modeScore) // return; Q_CHECK_PTR(tree); Move *m = tree->previousMove(); if (m != NULL) updateMove(m); }
void BoardHandler::slotNavForward() { // if (gameMode == modeScore) // return false; Q_CHECK_PTR(tree); Move *m = tree->nextMove(); if (m != NULL) updateMove(m); }
void BoardHandler::slotNavPrevVar() { // if (gameMode == modeScore) // return; Q_CHECK_PTR(tree); Move *m = tree->previousVariation(); if (m == NULL) return; updateMove(m); }
void ComponentAIBomber::update() { GameObject::removeDeadOnesFromList(onVisionList); GameObject::removeDeadOnesFromList(defenders); if(!parent->isDead()) { if( state == EnemyState::ATTACK && distanceFromThePath() > 60 ) { watching = false; shooting = false; target=NULL; selectedTarget = false; messageStopAIM(); state = EnemyState::RETURN; } //Comprueba que pases cerca del punto final del camino y si cambia el camino if(parent->position.getDistanceFrom(path->getEnd()) < 30 && state != EnemyState::ATTACK) { messageStopAIM(); changeTarget(true); } switch (state) { case ATTACK: updateAttack(); break; case MOVE: updateMove(); break; case RETURN: updateReturn(); break; default: break; } } else { std::list<GameObject*>::iterator it; for (it=defenders.begin(); it!=defenders.end(); ++it) { (*it)->kill(); } } }
void Turret::clientProcess (DWORD curTime) { Parent::clientProcess(curTime); if (getControlClient() == int(manager->getId())) { while (lastProcessTime < curTime) { DWORD endTick = (lastProcessTime + 32) & ~0x1F; if(endTick > curTime) endTick = curTime; if (PlayerMove *pm = cg.psc->getClientMove(lastProcessTime)) updateMove (pm, 0.001 * (endTick - lastProcessTime)); lastProcessTime = endTick; } } else { updateMove (NULL, 0.001 * (curTime - lastProcessTime)); lastProcessTime = curTime; } }
bool Scene::update() { if(pG_floor->pMovepath) { /* if(step>allSteps) { step=0; pfMoveStepNow[0]=-pfMoveStepNow[0]; pfMoveStepNow[1]=-pfMoveStepNow[1]; pfMoveStepNow[2]=-pfMoveStepNow[2]; } */ getMovesteps(); updateMove(); renewPhyScene(); //step++; }else { //LOGI("update 0"); pG_floor->draw(); //LOGI("num_coins: %d",num_coins); for(int i=0;i<num_coins;i++) {//LOGI("num_coins i: %d",i); vCoin[i]->update(pLR); } /* for(int i=0;i<num_enemys;i++) { if(vEnemy[i]->state==2) continue; updateOneEnemy( vEnemy[i]); } */ for(int i=0;i<num_thorns;i++) { vThorn[i]->update(pLR); } for(int i=0;i<num_thornballs;i++) { vThornball[i]->update(pLR); } } return true; }
void DynamicObjectController::update(const float elapsedTime) { m_dynamicObjectLogicCalculator->computeLogic(); updateState(); switch(m_dynamicObjectModel->getState()) { case DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_UP: updateMove(elapsedTime); break; case DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_DOWN: updateMove(elapsedTime); break; case DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_UP_LEFT: updateMove(elapsedTime); break; case DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_UP_RIGHT: updateMove(elapsedTime); break; case DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_DOWN_RIGHT: updateMove(elapsedTime); break; case DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_DOWN_LEFT: updateMove(elapsedTime); break; case DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_LEFT: updateMove(elapsedTime); break; case DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_RIGHT: updateMove(elapsedTime); break; case DynamicObjectModel::DYNAMIC_OBJECT_STATE_VANISHING: updateVanish(elapsedTime); break; case DynamicObjectModel::DYNAMIC_OBJECT_STATE_IMPACTING: updateVanish(elapsedTime); break; default: //nothing break; } updateBasicDynamicObjectMeasurements(); }
/* * Called by qgoboard when score button is pressed up, leaving score mode */ void BoardHandler::exitScore() { // Remove territory marks if (tree->getCurrent()->isTerritoryMarked()) { tree->getCurrent()->getMatrix()->clearTerritoryMarks(); tree->getCurrent()->setTerritoryMarked(false); tree->getCurrent()->setScored(false); } // Unshade dead stones //board->removeDeadMarks(); markedDead = false; tree->getCurrent()->getMatrix()->absMatrix(); updateMove(tree->getCurrent()); }
void Turret::serverUpdateMove(PlayerMove *moves, int moveCount) { while(moveCount--) { updateMove (&lastPlayerMove, 0.032); updateSkip--; if(updateSkip < 1) updateSkip = 1; lastPlayerMove = *moves++; } if(updateSkip > 3) updateSkip = 1; }
/* * Called after the preceding (slot nav Intersection) * When the intersection 'x/y' has been clicked on */ void BoardHandler::findMoveByPos(int x, int y) { Move *m = tree->findMoveInMainBranch(x, y); if(!m) tree->findMoveInCurrentBranch(x, y); //if (boardwindow->getGamePhase() == phaseNavTo) boardwindow->setGamePhase ( phaseOngoing ); if (m != NULL) { tree->setCurrent(m); updateAll_updateAll = true; updateMove(m); } else QApplication::beep(); }
void BoardHandler::slotNavLast() { // if (gameMode == modeScore) // return; Q_CHECK_PTR(tree); Move *m = tree->getCurrent(); Q_CHECK_PTR(m); // Descent tree to last son of main variation while (m->son != NULL) m = tree->nextMove(); if (m != NULL) { updateAll_updateAll = true; updateMove(m); } }
void Application::find(std::string what){ int matchPos; for(unsigned int i=current->position();i<current->string().length();i++){ } Line* temp = current->next(); while(temp != current){ if(!temp) temp = first; for(unsigned int i=0;i<temp->string().length();i++){ for(matchPos = 0;matchPos < what.length() && what[matchPos] == temp->string()[i]->ch();i++,matchPos++); if(matchPos == what.length()){ current = temp; Line* iter = top; for(unsigned int i2=0;i2<display->yMax() && iter;i2++){ if(iter == current){ display->mv(0,i2); iter = NULL; } iter = iter->next(); } if(!iter){ current = top; display->mv(0,0); } if(i > display->xMax()) xShift = i-display->xMax(); else xShift = 0; current->set_pos(i); updateMove(); return; } } } for(unsigned int i =0;i<current->position();i++){ //match check } }
/* * This function resumes back to the first move in the main branch */ void BoardHandler::slotNavMainBranch() { // if (gameMode == modeScore) // return; Q_CHECK_PTR(tree); if (tree->getCurrent()->parent == NULL) return; Move *m = tree->getCurrent(), *old = m, *lastOddNode = NULL; if (m == NULL) return; while ((m = m->parent) != NULL) { if (tree->getNumSons(m) > 1 && old != m->son) // Remember a node when we came from a branch lastOddNode = m; m->marker = old; old = m; } if (lastOddNode == NULL) return; Q_CHECK_PTR(lastOddNode); // Clear the marker, so we can proceed in the main branch lastOddNode->marker = NULL; tree->setCurrent(lastOddNode); updateAll_updateAll = true; updateMove(lastOddNode); }
void BoardHandler::slotNavFirst() { // if (gameMode == modeScore) // return; Q_CHECK_PTR(tree); // We need to set the markers. So go the tree upwards // Move *m = tree->getCurrent(); // CHECK_PTR(m); // Ascent tree until root reached // while (m->parent != NULL) // m = tree->previousMove(); tree->setToFirstMove(); // Set move to root Move *m = tree->getCurrent(); if (m != NULL) { updateAll_updateAll = true; updateMove(m); } }
void BoardHandler::slotNavStartVar() { // if (gameMode == modeScore) // return; Q_CHECK_PTR(tree); if (tree->getCurrent()->parent == NULL) return; Move *tmp = tree->previousMove(), *m = NULL; if (tmp == NULL) return; // Go up tree until we find a node that has > 1 sons while ((m = tree->previousMove()) != NULL && tree->getNumSons() <= 1) // Remember move+1, as we set current to the // first move after the start of the variation tmp = m; if (m == NULL) // No such node found, so we reached root. { tmp = tree->getRoot(); // For convinience, if we have Move 1, go there. Looks better. if (tmp->son != NULL) tmp = tree->nextMove(); } // If found, set current to the first move inside the variation Q_CHECK_PTR(tmp); tree->setCurrent(tmp); updateAll_updateAll = true; updateMove(tmp); }
void Character::update() { updateMove(); }
int Application::execute(std::string filename){ init(); this->filename = filename; load(); render(); renderNumbers(); renderControl(); move(0,5); display->mv(0,0); current->set_pos(0); while(running){ int in = getch(); if(in == 258 || in == 259 || in == 339 || in == 338){ if(tempPos == -1) tempPos = current->cursor_position(); } else{ tempPos = -1; } if(in > 0x1F && in < 0x7F){//typable current->insert(in); changed = true; renderLine(); updateMove(); } else if(in == 263/*CWin::key_backspace()*/){ if(current->cursor_position()){ changed = true; current->decrementPos(); current->del(); renderLine(); updateMove(); } else if(!display->xPos() && current->prev()){ changed = true; int temp = current->prev()-> current->prev()->set_pos(current->prev()->string().end());//move the cursor to the joining point current->prev()->append(current->string());//move the strings together //some magic in order to pop the one node current = current->prev(); Line* temp = current->next(); if(temp->next()){ temp->next()->prev(current); current->next(temp->next()); } else current->next(NULL); delete temp; current->set_num(current->number()); (*current->string().begin())->set_pos(); updateMove(-1); render(); renderNumbers(); } } else if(in == 330){//del if(!current->del()){ renderLine(); } else if(current->next()){ current->append(current->next()->string()); Line* temp = current->next(); if(temp->next()){ current->next(temp->next()); current->next()->prev(current); } else current->next(NULL); delete temp; current->set_num(current->number()); (*current->string().begin())->set_pos(); render(); renderNumbers(); } changed = true; } else if(in == 24){//^X if(changed){ int temp = promptBool("Save before exit? [y/n/c] "); if(temp == 1) saveAs(); if(temp > -1) running = false; } else running = false; } else if(in == 258){//dn todo check scrolling things if(current->next()){ current = current->next(); current->set_pos(tempPos); if(current->cursor_position() < xShift){ if((int)current->cursor_position()-(int)display->xMax() < 0) xShift = 0; else xShift = current->cursor_position()-display->xMax(); render(); } if(display->yPos() == display->yMax()-1){ top = top->next(); updateMove(); render(); renderNumbers(); } else updateMove(1); } } else if(in == 259){//up if(current->prev()){ current = current->prev(); current->set_pos(tempPos); if(current->cursor_position() < xShift){ if((int)current->cursor_position()-(int)display->xMax() < 0) xShift = 0; else xShift = current->cursor_position()-display->xMax(); render(); } if(display->yPos() == 0 && top->prev()){ top = top->prev(); updateMove(); render(); renderNumbers(); } else updateMove(-1); } } else if(in == 260){//left current->decrementPos(); if(current->cursor_position() < xShift && xShift){ xShift--; render(); } updateMove(); } else if(in == 261){//right current->incrementPos(); if(current->cursor_position() > xShift+display->xMax()-1){ xShift = current->cursor_position()-display->xMax()+1; render(); } updateMove(); } else if(in == CWin::key_end()){ //current->set_pos(current->string().length()); current->set_pos(-1); if(current->cursor_position() < display->xMax()){ updateMove(); } else{ xShift = current->cursor_position()-display->xMax()+1; updateMove(); render(); } } else if(in == 262){//home String::iterator tempChar = current->string().begin(); while((*tempChar)->ch() < 0x21 || (*tempChar)->ch() > 0x7E) ++tempChar; current->set_pos(tempChar); if(current->cursor_position() < display->xMax()) xShift = 0; else xShift = current->cursor_position()-display->xMax()-1; updateMove(); render(); } else if(in == 443){//ctrl-left page left if(xShift){ xShift--; render(); } } else if(in == 444){//ctrl-right page right xShift++; render(); } else if(in == 265){//F1 help } else if(in == 6){//^F find std::string what = promptString("String to search: "); } else if(in == 15){//^O Mode } else if(in == 19){//^S Save save(); } else if(in == 18){//^R Reload } else if(in == 339){//page up if(top->prev()){ top = top->prev(); render(); renderNumbers(); updateMove(1); if(display->yPos() == display->yMax()){ current->prev()->set_pos(tempPos); current = current->prev(); updateMove(-1); } } } else if(in == 338){//page dn if(top->next()){//should be a check for the bottom? top = top->next(); render(); renderNumbers(); updateMove(-1); if(display->yPos() == (unsigned int)-1){ current->next()->set_pos(tempPos); current = current->next(); updateMove(1); } } } } return 0; }
void Turret::serverProcess (DWORD time) { Parent::serverProcess(time); if (data->isSustained == false) { if (!getControlClient() && getState () == StaticBase::Enabled && isActive()) { targetsTracked = 0; Player *closePlayer = chooseTarget (); if (targetsTracked) sleepTime = manager->getCurrentTime() + 3.0; if (closePlayer) { if (state == EXTENDED) trackAndFire (closePlayer, 0.032); else extend (0.032); } else if (!targetsTracked && manager->getCurrentTime() > sleepTime) { if (state != RETRACTED) { retract (0.032); } } } if (!getControlClient()) updateMove (NULL, 0.032); else updateSkip++; } else { switch (m_fireState) { case Waiting: { serverProcessWaiting(time); } break; case Firing: { serverProcessFiring(time); } break; case Reloading: { serverProcessReloading(time); } break; default: AssertFatal(0, "invalid state"); } if (m_fireState == Firing) { float e = getEnergy(); e -= data->energyRate * 0.032; if(e < 0.0) { unshoot(); e = 0.0; } setEnergy(e); } } }
void TurretShape::processTick(const Move* move) { // Image Triggers if (getAllowManualFire() && move && mDamageState == Enabled) { switch(mDataBlock->weaponLinkType) { case TurretShapeData::FireTogether: { setImageTriggerState(0,move->trigger[0]); setImageTriggerState(1,move->trigger[0]); setImageTriggerState(2,move->trigger[0]); setImageTriggerState(3,move->trigger[0]); setImageAltTriggerState(0,move->trigger[1]); setImageAltTriggerState(1,move->trigger[1]); setImageAltTriggerState(2,move->trigger[1]); setImageAltTriggerState(3,move->trigger[1]); break; } case TurretShapeData::GroupedFire: { setImageTriggerState(0,move->trigger[0]); setImageTriggerState(1,move->trigger[1]); setImageTriggerState(2,move->trigger[0]); setImageTriggerState(3,move->trigger[1]); break; } case TurretShapeData::IndividualFire: { setImageTriggerState(0,move->trigger[0]); setImageTriggerState(1,move->trigger[1]); setImageTriggerState(2,move->trigger[2]); setImageTriggerState(3,move->trigger[3]); break; } } } Parent::processTick(move); // Change our type based on our rest state if (mAtRest) { // At rest so we're static mTypeMask &= ~DynamicShapeObjectType; mTypeMask |= StaticObjectType | StaticShapeObjectType; } else { // Not at rest so we're dynamic mTypeMask &= ~StaticObjectType; mTypeMask &= ~StaticShapeObjectType; mTypeMask |= DynamicShapeObjectType; } if (!isGhost()) updateAnimation(TickSec); if (isMounted()) { MatrixF mat; mMount.object->getMountTransform( mMount.node, mMount.xfm, &mat ); ShapeBase::setTransform(mat); ShapeBase::setRenderTransform(mat); } updateMove(move); }
void AvatarController::update(const float elapsedTime) { m_avatarLogicCalculator->computeLogic(); updateState(); switch(m_avatarModel->getState()) { case AvatarModel::AvatarState::AVATAR_STATE_IDLE: updateIdle(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_MOVE_UP: updateMove(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_MOVE_DOWN: updateMove(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_MOVE_LEFT: updateMove(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_MOVE_RIGHT: updateMove(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_MOVE_UP_LEFT: updateMove(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_MOVE_UP_RIGHT: updateMove(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_MOVE_DOWN_LEFT: updateMove(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_MOVE_DOWN_RIGHT: updateMove(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_UP: updateAttack(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_DOWN: updateAttack(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_LEFT: updateAttack(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_RIGHT: updateAttack(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_UP_LEFT: updateAttack(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_UP_RIGHT: updateAttack(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_DOWN_LEFT: updateAttack(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_DOWN_RIGHT: updateAttack(elapsedTime); break; case AvatarModel::AvatarState::AVATAR_STATE_DIE: updateDie(elapsedTime); break; default: updateIdle(elapsedTime); break; } updateBasicAvatarMeasurements(); }