// --- // mouseMoveEvent() - called when the mouse is held down and moved // --- void MapItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { if (event != nullptr && event->buttons() & Qt::LeftButton) { // determine our delta const int deltaX = event->lastPos().x() - event->scenePos().x(); const int deltaY = event->lastPos().y() - event->scenePos().y(); moveMap(deltaY, deltaX); } }
void PlayScene::ccTouchMoved(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent) { mIsScrolling = true; CCPoint touchLocation = pTouch->getLocation(); touchLocation = this->convertToNodeSpace(touchLocation); CCPoint touchLocationToMap = mTileMap->convertToNodeSpace(touchLocation); float offsetX = touchLocation.x - mBeginLocation.x; float offsetY = touchLocation.y - mBeginLocation.y; moveMap(offsetX, offsetY); mBeginLocation = touchLocation; mBeginLocationToMap = touchLocationToMap; }
/** * the timer which will move the map into the center of the screen, and resize all areas and icons * */ void MapArea::timerEvent() { QVector<MapVectors*>::iterator iter = vecs.begin(); while(iter != vecs.end()) { (*iter)->update(lastMousePos); iter++; } QVector<FacilityIcon*>::iterator fiter = icons.begin(); while(fiter != icons.end()) { (*fiter)->update(lastMousePos); fiter++; } mapX->update(lastMousePos); moveMap(); setGeometry(0,0,middle.x()*2,middle.y()*2); repaint(); }
void Display::mouseMotionEvent(const int x, const int y) { if (dragging) { const auto page = static_cast<MapPage*>(subpage()); if (page != nullptr) { // get our ref lat, because we won't go passed 70 degrees lat (either way); const double lat = page->getReferenceLatDeg(); if (lat < 70 && lat > -70) { page->moveMap(startX, startY, x, y); } else { if (lat > 0) page->setReferenceLatDeg(65); else page->setReferenceLatDeg(-65); } startX = x; startY = y; } } setMouse(x, y); }
/******************************************************************* * Function: void map (void) * Input Variables: none * Output Return: none * Overview: Makes the robot map the world ********************************************************************/ void map (void) { // Initialize State isMapping = 1; // Mapping Loop while(isMapping) { //Sense checkIR(); checkWorld(); //Record setGateways(); //Plan using the Map planMap(); //Act on the Map moveMap(); //Shift the Map currentCellWorld = shiftMap(currentCellWorld, currentMove, currentOrientation); //Break? isMapping = !((currentCellWorldStart == currentCellWorld)&&(currentOrientationStart == currentOrientation)); if(!isMapping){ break; } //Print Map LCD_clear(); LCD_printf(" Move"BYTETOBINARYPATTERN"\n Cell"BYTETOBINARYPATTERN"\n Ornt"BYTETOBINARYPATTERN"\n\n",BYTETOBINARY(currentMove),BYTETOBINARY(currentCellWorld),BYTETOBINARY(currentOrientation)); printMap(currentOrientation,currentCellWorld,RESET); TMRSRVC_delay(500);//wait 3 seconds } }
void CBOT_main( void ) { // Initialize Robot ATopstat = ATTINY_open();//open the tiny microcontroller LEopstat = LED_open(); //open the LED module LCopstat = LCD_open(); //open the LCD module STEPPER_open(); // Open STEPPER module for use SPKR_open(SPKR_BEEP_MODE);//open the speaker in beep mode LED_open(); I2C_open(); ADC_open();//open the ADC module ADC_set_VREF( ADC_VREF_AVCC );// Set the Voltage Reference first so VREF=5V. // // Print a debug statement // LCD_printf("It's ALIVE\n\n\n\n"); // TMRSRVC_delay(3000);//wait 3 seconds // LCD_clear(); // Print the metric Map // printMetricMap(); // LCD_printf("%i %i %i %i \n%i %i %i %i \n%i %i %i %i \n%i %i %i %i \n",ROBOT_METRIC_WORLD[0][0],ROBOT_METRIC_WORLD[0][1],ROBOT_METRIC_WORLD[0][2],ROBOT_METRIC_WORLD[0][3],ROBOT_METRIC_WORLD[1][0],ROBOT_METRIC_WORLD[1][1],ROBOT_METRIC_WORLD[1][2],ROBOT_METRIC_WORLD[1][3],ROBOT_METRIC_WORLD[2][0],ROBOT_METRIC_WORLD[2][1],ROBOT_METRIC_WORLD[2][2],ROBOT_METRIC_WORLD[2][3],ROBOT_METRIC_WORLD[3][0],ROBOT_METRIC_WORLD[3][1],ROBOT_METRIC_WORLD[3][2],ROBOT_METRIC_WORLD[3][3]); // TMRSRVC_delay(10000);//wait 10 seconds // wavefrontMake(); // LCD_printf("%i %i %i %i \n%i %i %i %i \n%i %i %i %i \n%i %i %i %i \n",ROBOT_METRIC_WORLD[0][0],ROBOT_METRIC_WORLD[0][1],ROBOT_METRIC_WORLD[0][2],ROBOT_METRIC_WORLD[0][3],ROBOT_METRIC_WORLD[1][0],ROBOT_METRIC_WORLD[1][1],ROBOT_METRIC_WORLD[1][2],ROBOT_METRIC_WORLD[1][3],ROBOT_METRIC_WORLD[2][0],ROBOT_METRIC_WORLD[2][1],ROBOT_METRIC_WORLD[2][2],ROBOT_METRIC_WORLD[2][3],ROBOT_METRIC_WORLD[3][0],ROBOT_METRIC_WORLD[3][1],ROBOT_METRIC_WORLD[3][2],ROBOT_METRIC_WORLD[3][3]); // TMRSRVC_delay(10000);//wait 10 seconds // LCD_clear(); // Test the 4-Neighbor search // LCD_printf("%i %i %i %i \n%i %i %i %i \n%i %i %i %i \n%i %i %i %i \n",ROBOT_METRIC_WORLD[0][0],ROBOT_METRIC_WORLD[0][1],ROBOT_METRIC_WORLD[0][2],ROBOT_METRIC_WORLD[0][3],ROBOT_METRIC_WORLD[1][0],ROBOT_METRIC_WORLD[1][1],ROBOT_METRIC_WORLD[1][2],ROBOT_METRIC_WORLD[1][3],ROBOT_METRIC_WORLD[2][0],ROBOT_METRIC_WORLD[2][1],ROBOT_METRIC_WORLD[2][2],ROBOT_METRIC_WORLD[2][3],ROBOT_METRIC_WORLD[3][0],ROBOT_METRIC_WORLD[3][1],ROBOT_METRIC_WORLD[3][2],ROBOT_METRIC_WORLD[3][3]); // TMRSRVC_delay(5000); // LCD_clear(); currentCellWorld = WORLD_CELL[0][0]; wavefrontMake(); while(currentCellWorld!=reachedEnd){ nextOrientation = fourNeighborSearch(currentCellWorld); metricMove(); moveMap(); currentCellWorld = shiftMap(currentCellWorld, currentMove, currentOrientation); } LCD_printf("LOOOOOOOOOOOOLZ"); TMRSRVC_delay(5000); LCD_clear(); // Unit test the function // sqrt function // int xDelta, yDelta; // float distance; // xDelta = abs(-3); // yDelta = abs(0); // distance = sqrt(((xDelta*xDelta)+(yDelta*yDelta))); // LCD_printf("xDel = %d\nyDel = %d\ndist = %f\n\n",xDelta,yDelta,distance); // TMRSRVC_delay(5000); // LCD_clear(); // cell values }// end the CBOT_main()
void CBOT_main( void ) { // initialize the robot initializeRobot(); currentOrientation = NORTH; // Ask for Goal char isDone = 0; unsigned char btnHolder = UNPRESSED; LCD_clear(); LCD_printf(" Goal?\n\n\n\n"); while(!isDone){ btnHolder = EnterTopoCommand(); switch(btnHolder){ case MOVE_LEFT: currentGoalWorld--; currentGoalWorld = currentGoalWorld&0b1111; break; case MOVE_FORWARD: isDone = 1; break; case MOVE_RIGHT: currentGoalWorld++; currentGoalWorld = currentGoalWorld&0b1111; break; default: break; } printMap(currentOrientation,currentGoalWorld,RESET); TMRSRVC_delay(100);//wait .1 seconds } // Ask for starting orentation isDone = 0; btnHolder = UNPRESSED; LCD_clear(); LCD_printf(" Orient?\n\n\n\n"); while(!isDone){ btnHolder = EnterTopoCommand(); switch(btnHolder){ case MOVE_LEFT: // If we move left // shift our oriention CCW currentOrientation--; currentOrientation = currentOrientation&0b11; break; case MOVE_FORWARD: isDone = 1; break; case MOVE_RIGHT: // If we move right // shift our oriention CW currentOrientation++; currentOrientation = currentOrientation&0b11; break; default: break; } printMap(currentOrientation,currentGoalWorld,RESET); TMRSRVC_delay(100);//wait .1 seconds } // Ask to start isDone = 0; btnHolder = UNPRESSED; LCD_clear(); LCD_printf(" Start?\n\n\n\n"); while(!isDone){ btnHolder = EnterTopoCommand(); switch(btnHolder){ case MOVE_LEFT: break; case MOVE_FORWARD: isDone = 1; break; case MOVE_RIGHT: break; default: break; } printMap(currentOrientation,currentGoalWorld,RESET); TMRSRVC_delay(100);//wait .1 seconds } // Locilize the Robot // localize(); // Initialize State isLost = 1; oldMove = MOVE_STOP; // Localization Loop while(isLost) { // Break if not isLost if(!isLost){ break; } //Sense Gateway checkIR(); checkWorld(); //Plan using the Gateway planGateway(); //Localize from Gateways? isLost = localizeGateway(); //Act on the Gateway moveMap(); } // Update the currentOrientation using currentMove switch(currentMove){ // case MOVE_LEFT: // // If we move left // // shift our oriention CCW // currentOrientation--; // currentOrientation = currentOrientation&0b11; // break; case MOVE_FORWARD: break; // case MOVE_RIGHT: // // If we move right // // shift our oriention CW // currentOrientation++; // currentOrientation = currentOrientation&0b11; // break; default: LCD_printf("Whatz2?!"); break; } SPKR_beep(500); // LCD_clear(); // LCD_printf("LOLZ\nI'm found!"); // TMRSRVC_delay(3000);//wait 3 seconds LCD_clear(); LCD_printf(" New Map\n\n\n\n"); printMap(currentOrientation,currentCellWorld,RESET); TMRSRVC_delay(1000);//wait 1 seconds SPKR_beep(0); // currentCellWorld = 0; isFire = 0; // Go firefight while(!isFire){ //Sense Gateway checkIR(); checkWorld(); isFire = checkFire(); if(isFire){ break; } // Plan using Map planMap(); // Shift the map currentCellWorld = shiftMap(currentCellWorld, currentMove, currentOrientation); // Act on the Map moveMap(); } // // Beep for the fire SIREN // int ii; // for (ii=0; ii<=3; ii++){ // SPKR_beep(250); // TMRSRVC_delay(1000); // SPKR_beep(500); // TMRSRVC_delay(1000); // } // SPKR_beep(0); // // Print the fire cell location // LCD_clear(); // LCD_printf("Fire = %i\n\n\n\n", currentFireCell); // TMRSRVC_delay(5000); // Moves the Robot to the goal metric(); // Print that you are at home and the fire cell location LCD_clear(); LCD_printf("LOLZ\nI'm HOME\nFire at Cell: %i\n\n",currentFireCell); // Stop when home is reached STEPPER_stop(STEPPER_BOTH, STEPPER_BRK_OFF); // Beep when home is reached SPKR_beep(500); TMRSRVC_delay(3000);//wait 3 seconds SPKR_beep(0); TMRSRVC_delay(7000);//wait 7 seconds /** // Enter the robot's current (starting) position LCD_printf("START Map/nlocation\n\n\n"); TMRSRVC_delay(1000);//wait 1 seconds LCD_clear(); worldInput(); TMRSRVC_delay(1000);//wait 3 seconds LCD_clear(); // Enter the robot's current (starting) orientation LCD_printf("START Map/norientation\n\n\n"); TMRSRVC_delay(1000);//wait 1 seconds LCD_clear(); orientationInput(); TMRSRVC_delay(1000);//wait 3 seconds LCD_clear(); // Print the map LCD_clear(); printMap(currentOrientation,currentCellWorld,RESET); TMRSRVC_delay(10000);//wait 10 seconds LCD_clear(); // Enter the robot's current (starting) position LCD_printf("START Path\nlocation\n\n\n"); TMRSRVC_delay(1000);//wait 1 seconds LCD_clear(); worldInput(); TMRSRVC_delay(1000);//wait 3 seconds LCD_clear(); // Enter the robot's current (starting) orientation LCD_printf("START Path\norientation\n\n\n"); TMRSRVC_delay(1000);//wait 1 seconds LCD_clear(); orientationInput(); TMRSRVC_delay(1000);//wait 3 seconds LCD_clear(); // Enter the robot topological commands LCD_printf("ENTER Path\ncommands\n\n\n"); TMRSRVC_delay(1000);//wait 1 seconds LCD_clear(); movesInput(); TMRSRVC_delay(1000);//wait 1 seconds LCD_clear(); // Print the robot gateways LCD_printf("Robot Gateways:\n\n\n\n"); TMRSRVC_delay(1000);//wait 1 seconds LCD_clear(); getGateways(); TMRSRVC_delay(1000);//wait 1 seconds LCD_clear(); // Goal loop while (1) { checkIR(); checkWorld(); moveWorld(); //Test arc function // LCD_printf("Move Arc\n\n\n\n"); // TMRSRVC_delay(1000);//wait 1 seconds // move_arc_stwt(POINT_TURN, LEFT_TURN, 10, 10, 0); // //Test contact Sensors // LCD_printf("Right Contact: %i\nLeft Contact: %i\n\n\n",rightContact,leftContact); // TMRSRVC_delay(1000);//wait 1 seconds // // Test IR Sensors // LCD_clear(); // LCD_printf("FrontIR = %3.2f\nBackIR = %3.2f\nLeftIR = %3.2f\nRightIR = %3.2f\n", ftIR,bkIR,ltIR,rtIR); // TMRSRVC_delay(1000);//wait 1 seconds } **/ }// end the CBOT_main()
/******************************************************************* * Function: void metric(void) * Input Variables: none * Output Return: none * Overview: Moves the robot to the goal ********************************************************************/ void metric (void) { // currentCellWorld = 0b0000; // currentGoalWorld = 15; // Make metric map wavefrontMake(); // Initialize State isGoal = 0; unsigned char isSiren = 0; // Metric Loop while(!isGoal){ if(isSiren){ SPKR_beep(500); isSiren = 0; } else{ SPKR_beep(250); isSiren = 1; } LCD_clear(); switch(currentOrientation){ case NORTH: LCD_printf("CurtOrent:NORTH\n"); break; case EAST: LCD_printf("CurtOrent:EAST\n"); break; case SOUTH: LCD_printf("CurtOrent:SOUTH\n"); break; case WEST: LCD_printf("CurtOrent:WEST\n"); break; default: break; } // Find the next orentation isGoal = fourNeighborSearch(currentCellWorld); if(isGoal){ break; } switch(nextOrientation){ case NORTH: LCD_printf("NextOrent:NORTH\n"); break; case EAST: LCD_printf("NextOrent:EAST\n"); break; case SOUTH: LCD_printf("NextOrent:SOUTH\n"); break; case WEST: LCD_printf("NextOrent:WEST\n"); break; default: break; } switch(currentMove){ case MOVE_LEFT: LCD_printf("CurMOVE:LEFT\n"); break; case MOVE_RIGHT: LCD_printf("CurMOVE:RIGHT\n"); break; case MOVE_FORWARD: LCD_printf("CurMOVE:FORWARD\n"); break; default: break; } // Plan using metric map and next orientation planMetric(); // Act on the move moveMap(); // Shift the map currentCellWorld = shiftMap(currentCellWorld, currentMove, currentOrientation); // TMRSRVC_delay(2000);//wait 1 seconds } SPKR_beep(0); }
void RogueScene::touchEventExec(cocos2d::Point touchPoint) { auto pMapLayer = (TMXTiledMap*)getChildByTag(kTiledMapTag); // マップ移動分を考慮 MapIndex touchPointMapIndex = touchPointToIndex(touchPoint - pMapLayer->getPosition()); CCLOG("onTouchBegan touchPointMapIndex x = %d y = %d", touchPointMapIndex.x, touchPointMapIndex.y); // 画面外判定 if (isMapLayerOver(touchPointMapIndex)) { // タッチ判定とみなさない return; } // タッチした位置が有効なIndexか判定 MapIndex addMoveIndex = checkTouchEventIndex(touchPointMapIndex); if (addMoveIndex.x == 0 && addMoveIndex.y == 0) { // タッチ判定とみなさない return; } // キャラの向きを変更 auto pActorSprite = getPlayerActorSprite(1); pActorSprite->runMoveAction(addMoveIndex); // 敵をタッチした auto pEnemyMapItem = m_mapManager.getActorMapItem(&touchPointMapIndex); if (pEnemyMapItem->mapDataType == MapDataType::ENEMY) { auto pPlayerDto = pActorSprite->getActorDto(); auto pEnemyDto = getEnemyActorSprite(pEnemyMapItem->seqNo)->getActorDto(); int damage = BattleLogic::exec(pPlayerDto, pEnemyDto); // 攻撃イベント logMessage("%sの攻撃: %sに%dのダメージ", pPlayerDto->name.c_str(), pEnemyDto->name.c_str(), damage); } else { // 障害物判定 if (isTiledMapColisionLayer(touchPointMapIndex)) { // TODO: ぶつかるSE再生 logMessage("壁ドーン"); } else { changeGameStatus(GameStatus::PLAYER_ACTION); // アイテムに重なったときの拾う処理 auto pTouchPointMapItem = m_mapManager.getMapItem(&touchPointMapIndex); if (pTouchPointMapItem->mapDataType == MapDataType::MAP_ITEM) { // ドロップアイテムを拾う auto pDropMapItem = (DropMapItem*) pTouchPointMapItem; // TODO: 拾うSE再生 // itemを取得 auto pDropItemLayer = getChildByTag(RogueScene::kTiledMapTag)->getChildByTag(RogueScene::TiledMapTag::kTiledMapDropItemBaseTag); auto pDropItemSprite = (DropItemSprite*) pDropItemLayer->getChildByTag(RogueScene::TiledMapTag::kTiledMapDropItemBaseTag + pDropMapItem->seqNo); // メッセージログ auto pDropItemDto = pDropItemSprite->getDropItemDto(); logMessage("%sを拾った。", pDropItemDto->name.c_str()); // イベントリに追加する getItemWindowLayer()->addItemList(pDropItemDto); // mapManagerから消す m_mapManager.removeMapItem(pDropMapItem); // ミニマップを更新 auto pMiniMapLayer = getChildByTag(kMiniMapTag); pMiniMapLayer->removeChildByTag(pDropItemSprite->getTag()); // Map上からremoveする pDropItemLayer->removeChild(pDropItemSprite); } // 移動処理 moveMap(addMoveIndex, pActorSprite->getActorMapItem()->seqNo, pActorSprite->getActorMapItem()->mapDataType, CallFunc::create([this](void) { changeGameStatus(GameStatus::ENEMY_TURN); })); // コールバックまでgameStatusを更新はしない return; } } // TODO: 会話 // 会話イベント // ターン終了 changeGameStatus(GameStatus::ENEMY_TURN); }
void RogueScene::enemyTurn() { // モンスターの数だけ繰り返す std::list<ActorMapItem> enemyList = m_mapManager.findEnemyMapItem(); for (ActorMapItem enemyMapItem : enemyList) { // ランダムでとどまるか移動するかきめる int rand = GetRandom(2, 2); if (rand == 1) { auto pEnemySprite = getEnemyActorSprite(enemyMapItem.seqNo); pEnemySprite->getActorMapItem()->moveDone = true; // とどまる logMessage("様子を見ている seqNo = %d", enemyMapItem.seqNo); } else if (rand == 2) { // プレイヤーに向かって移動 or プレイヤーに攻撃 auto pPlayerActorSprite = getPlayerActorSprite(1); // プレイヤーの周辺で最もコストが低い箇所へ移動 auto playerMapIndex = pPlayerActorSprite->getActorMapItem()->mapIndex; std::list<MapIndex> searchMapIndexList; searchMapIndexList.clear(); // 右 MapIndex searchMapIndex = playerMapIndex; searchMapIndex.x += 1; searchMapIndex.y += 0; searchMapIndex.moveDictType = MoveDirectionType::MOVE_LEFT; searchMapIndexList.push_back(searchMapIndex); // 左 searchMapIndex = playerMapIndex; searchMapIndex.x += -1; searchMapIndex.y += 0; searchMapIndex.moveDictType = MoveDirectionType::MOVE_RIGHT; searchMapIndexList.push_back(searchMapIndex); // 上 searchMapIndex = playerMapIndex; searchMapIndex.x += 0; searchMapIndex.y += 1; searchMapIndex.moveDictType = MoveDirectionType::MOVE_DOWN; searchMapIndexList.push_back(searchMapIndex); // 下 searchMapIndex = playerMapIndex; searchMapIndex.x += 0; searchMapIndex.y += -1; searchMapIndex.moveDictType = MoveDirectionType::MOVE_UP; searchMapIndexList.push_back(searchMapIndex); // そもそもプレイヤーが隣接しているかチェック bool isPlayerAttack = false; { for (MapIndex mapIndex : searchMapIndexList) { if (MAP_INDEX_DIFF(enemyMapItem.mapIndex, mapIndex)) { isPlayerAttack = true; } } } MapIndex moveMapIndex = enemyMapItem.mapIndex; if (isPlayerAttack) { // 攻撃 moveMapIndex =pPlayerActorSprite->getActorMapItem()->mapIndex; } else { // 移動可能な経路情報を設定 m_mapManager.createActorFindDist(enemyMapItem.mapIndex, enemyMapItem.moveDist); // 最も移動コストがかからない場所を抽出 MapItem targetMoveDistMapItem = m_mapManager.searchTargetMapItem(searchMapIndexList); // 移動リスト作成 if (targetMoveDistMapItem.mapDataType == MapDataType::MOVE_DIST) { std::list<MapIndex> moveList = m_mapManager.createMovePointList(&targetMoveDistMapItem.mapIndex, &enemyMapItem); std::list<MapIndex>::iterator it = moveList.begin(); it++; moveMapIndex = *it; // 2件目を取得(1件目は自分なので) it = moveList.end(); } } // 移動有無関係なく向きは変える auto pEnemySprite = getEnemyActorSprite(enemyMapItem.seqNo); MapIndex addMoveIndex = { moveMapIndex.x - pEnemySprite->getActorMapItem()->mapIndex.x, moveMapIndex.y - pEnemySprite->getActorMapItem()->mapIndex.y, m_mapManager.checkMoveDirectionType(moveMapIndex, pEnemySprite->getActorMapItem()->mapIndex) }; pEnemySprite->runMoveAction(addMoveIndex); // 行動前にする pEnemySprite->getActorMapItem()->moveDone = false; pEnemySprite->getActorMapItem()->attackDone = false; if (isMapLayerOver(moveMapIndex)) { CCLOG("移動不可 seqNo = %d (%d, %d)", enemyMapItem.seqNo, moveMapIndex.x, moveMapIndex.y); pEnemySprite->getActorMapItem()->moveDone = true; } else if (isTiledMapColisionLayer(moveMapIndex)) { logMessage("壁ドーン seqNo = %d (%d, %d)", enemyMapItem.seqNo, moveMapIndex.x, moveMapIndex.y); pEnemySprite->getActorMapItem()->moveDone = true; } else if (m_mapManager.getActorMapItem(&moveMapIndex)->mapDataType == MapDataType::ENEMY) { if (MAP_INDEX_DIFF(enemyMapItem.mapIndex, moveMapIndex)) { //logMessage("待機 seqNo = %d (%d, %d)"); } else { logMessage("敵ドーン seqNo = %d (%d, %d)", enemyMapItem.seqNo, moveMapIndex.x, moveMapIndex.y); } pEnemySprite->getActorMapItem()->moveDone = true; } else if (m_mapManager.getActorMapItem(&moveMapIndex)->mapDataType == MapDataType::PLAYER) { auto pPlayerDto = pPlayerActorSprite->getActorDto(); auto pEnemyDto = pEnemySprite->getActorDto(); int damage = BattleLogic::exec(pEnemyDto, pPlayerDto); // 攻撃イベント logMessage("%sの攻撃: %sに%dダメージ", pEnemyDto->name.c_str(), pPlayerDto->name.c_str(), damage); pEnemySprite->getActorMapItem()->attackDone = true; } else { // 移動中のステータスへ changeGameStatus(GameStatus::ENEMY_ACTION); // 移動開始 moveMap(addMoveIndex, enemyMapItem.seqNo, enemyMapItem.mapDataType, CallFuncN::create([this, pEnemySprite](Object* pObj) { // 移動終わり次のモンスターへいきたいところ // listをメンバ変数で持っちゃえばいけるか? auto pEnemySprite = static_cast<ActorSprite*>(pObj); pEnemySprite->getActorMapItem()->moveDone = true; bool isTurnEnd = true; std::list<ActorMapItem> enemyList = m_mapManager.findEnemyMapItem(); for (ActorMapItem enemyMapItem : enemyList) { auto pEnemySprite = getEnemyActorSprite(enemyMapItem.seqNo); auto pEnemyMapItem = pEnemySprite->getActorMapItem(); if (!pEnemyMapItem->moveDone && !pEnemyMapItem->attackDone) { isTurnEnd = false; break; } } if (isTurnEnd) { changeGameStatus(GameStatus::PLAYER_TURN); } else { changeGameStatus(GameStatus::ENEMY_TURN); } })); } } } // 留まった時とかはここでターン終了 if (m_gameStatus != GameStatus::ENEMY_ACTION) { changeGameStatus(GameStatus::PLAYER_TURN); } bool isTurnEnd = true; for (ActorMapItem enemyMapItem : enemyList) { auto pEnemySprite = getEnemyActorSprite(enemyMapItem.seqNo); auto pEnemyMapItem = pEnemySprite->getActorMapItem(); if (!pEnemyMapItem->moveDone && !pEnemyMapItem->attackDone) { isTurnEnd = false; break; } } }