void RegularBattleScene::updateBall(int player, int index) { auto &poke = *data()->team(player).poke(index); gui.pokeballs[player][index]->setToolTip(tr("%1 lv %2 -- %3%%4").arg(PokemonInfo::Name(poke.num())).arg(poke.level()).arg(poke.lifePercent()).arg(poke.status() == 0 ? "" : QString(" (%1)").arg(StatInfo::ShortStatus(poke.status()).toUpper()))); updateBallStatus(player, index); }
void RegularBattleScene::updateBall(int player, int index) { auto &poke = *data()->team(player).poke(index); gui.pokeballs[player][index]->setToolTip(tr("%1 lv %2 -- %3%").arg(PokemonInfo::Name(poke.num())).arg(poke.level()).arg(poke.lifePercent())); updateBallStatus(player, index); }
void RegularBattleScene::onPokeballStatusChanged(int player, int poke, int) { updateBallStatus(player, poke); if (poke < data()->numberOfSlots()/2) { updatePoke(data()->spot(player, poke)); } }
void Robot::keepGoal() { int v_level = 0; abort = false; bool rotating=false; bool kmt_abort = false; cv::Point2f ballVelocity,ballPosition; bool vt_ballLocated; cv::Point2f keeper_center = ownGoal_coord + ownGoal_frontDir*KEEPER_DIST2GOAL; cv::Point2f keeper_dir(ownGoal_frontDir.y,-ownGoal_frontDir.x); moveTo(keeper_center,30); rotateTo(keeper_dir); void *kmt_params[6]; float targetDist = BOT_CENTER2CAM_CENTER; float moveDist = 0; kmt_params[0] = &targetDist; kmt_params[1] = &moveDist; kmt_params[2] = &v_level; kmt_params[3] = this; kmt_params[4] = &kmt_abort; kmt_params[5] = &rotating; pthread_t km_thread; pthread_create(&km_thread,NULL,&keeperMotionThread,(void*)kmt_params); usleep(1000); while(!kmt_abort) { if(v_level==0 && !rotating) { adjustWorldCoordinate(image_r,1); } float temp_dist = moveDist; cv::Point2f shift = temp_dist*cv::Point2f(ownGoal_frontDir.y,-ownGoal_frontDir.x); x = keeper_center.x+shift.x; y = keeper_center.y+shift.y; float temp_v_level = v_level; cv::Point2f robot_velocity(temp_v_level*DELTA_V*sin(ori),temp_v_level*DELTA_V*cos(ori)); updateBallStatus(); updateRadar(); if(!ballLocated) { continue; } if(length(ball_velocity)<MIN_BALL_SPEED_TO_KEEP || ball_velocity.dot(ownGoal_frontDir)/length(ball_velocity)>-0.1) { //targetDist = 0; continue; } float ball2goal_time = getTime(ball_coord,ball_velocity,ownGoal_coord,keeper_dir); float ball2keepline_time = getTime(ball_coord,ball_velocity,keeper_center,keeper_dir); cv::Point2f goalPoint = ball_coord + ball2goal_time*ball_velocity; cv::Point2f moveToPoint = ball_coord + ball2keepline_time*ball_velocity; if(ball2keepline_time<0 || length(goalPoint-ownGoal_coord)>ownGoal_width/2+GOAL_WIDTH_DELTA) { //targetDist = 0; continue; } shootRoute.clear(); shootRoute.push_back(cv::Point(x,y)); shootRoute.push_back(moveToPoint); targetDist = (moveToPoint - keeper_center).dot(keeper_dir)+BOT_CENTER2CAM_CENTER; } }