unsigned int AIManager::updatePathProgress(unsigned int playerNum) { while ((pointOnPath[playerNum] < pathToGoal[playerNum].size()) && (atPoint(playerNum, pathToGoal[playerNum][pointOnPath[playerNum]]))) { pointOnPath[playerNum]++; } if (pointOnPath[playerNum] >= pathToGoal[playerNum].size()) return AI_COMPLETED_PATH; else return AI_IN_PATH; }
void View::click(ScreenCoord sc, ScreenCoord down, int button) { // calculate isometric coord IsoCoord ic = toIso(sc); Tile *clicked_tile = state->getTile(ic.ne, ic.se); Tile *mmt = mm.onTile(sc); if ( mmt ) { if (button == 0) scrollTo(mmt); else if (button == 1) { ic.ne = mmt->x; ic.se = mmt->y; for (unordered_set<Instance *>::iterator i = select.begin(); i != select.end(); ++i) { state->issueCommand((*i), ic); } } return; } if ( state->withinMap(ic) ) { if (button == 0) { select.clear(); int lowx = sc.x, lowy = sc.y, highx = down.x, highy = down.y; if (highx < lowx) { highx = sc.x; lowx = down.x; } if (highy < lowy) { highy = sc.y; lowy = down.y; } for (int x = lowx; x <= highx; ++x) { for (int y = lowy; y <= highy; ++y) { ScreenCoord sci; sci.x = x; sci.y = y; Instance *test = atPoint(sci); if (test) { if (select.count(test) == 0) { select.insert( test ); cout << "select " << test->getTask()->graphic_id << endl; } } } } } /* button 2 issues commands to selection */ else if (button == 1) { Instance *ins = atPoint(sc); for (unordered_set<Instance *>::iterator i = select.begin(); i != select.end(); ++i) { if (ins) { state->issueCommand((*i), ins); } else { state->issueCommand((*i), ic); } } } } }