本文整理汇总了C++中TilePosition函数的典型用法代码示例。如果您正苦于以下问题:C++ TilePosition函数的具体用法?C++ TilePosition怎么用?C++ TilePosition使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TilePosition函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TilePosition
void MapDataReader::addEntry(string line)
{
int i = line.find(" ");
string t1 = line.substr(0, i);
line = line.substr(i + 1, line.length());
i = line.find(" ");
string t2 = line.substr(0, i);
line = line.substr(i + 1, line.length());
i = line.find(" ");
string t3 = line.substr(0, i);
line = line.substr(i + 1, line.length());
i = line.find(" ");
string t4 = line.substr(0, i);
line = line.substr(i + 1, line.length());
string t5 = line;
MapData entry;
entry.basePos = TilePosition(toInt(t1), toInt(t2));
entry.pos = TilePosition(toInt(t3), toInt(t4));
entry.dist = toInt(t5);
data.push_back(entry);
}
示例2: TilePosition
TilePosition Squad::getNextStartLocation()
{
for(set<BaseLocation*>::const_iterator i=getStartLocations().begin();i!=getStartLocations().end();i++)
{
TilePosition basePos = (*i)->getTilePosition();
if (!isVisible(basePos))
{
return basePos;
}
else
{
if ((int)agents.size() > 0)
{
UnitAgent* uagent = (UnitAgent*)agents.at(0);
int eCnt = uagent->enemyUnitsWithinRange(10 * 32);
if (eCnt > 0)
{
return TilePosition(-1, -1);
}
}
hasVisited.push_back(basePos);
}
}
return TilePosition(-1, -1);
}
示例3: TilePosition
TilePosition Commander::findUnfortifiedChokePoint()
{
double bestDist = 0;
Chokepoint* bestChoke = NULL;
for(set<BWTA::Region*>::const_iterator i=getRegions().begin();i!=getRegions().end();i++)
{
if (isOccupied((*i)))
{
for(set<Chokepoint*>::const_iterator c=(*i)->getChokepoints().begin();c!=(*i)->getChokepoints().end();c++)
{
if (isEdgeChokepoint((*c)))
{
if (!chokePointFortified(TilePosition((*c)->getCenter())))
{
double cDist = Broodwar->self()->getStartLocation().getDistance(TilePosition((*c)->getCenter()));
if (cDist > bestDist)
{
bestDist = cDist;
bestChoke = (*c);
}
}
}
}
}
}
TilePosition buildPos = TilePosition(-1, -1);
if (bestChoke != NULL)
{
buildPos = TilePosition(bestChoke->getCenter());
}
return buildPos;
}
示例4: TilePosition
TilePosition StructureAgent::getNextScanLocation()
{
TilePosition ePos = ExplorationManager::getInstance()->getClosestSpottedBuilding(Broodwar->self()->getStartLocation());
if (ePos.x() > -1)
{
//Already found enemy base
return TilePosition(-1, -1);
}
for(set<BaseLocation*>::const_iterator i=getStartLocations().begin();i!=getStartLocations().end();i++)
{
TilePosition basePos = (*i)->getTilePosition();
bool needScan = true;
//1. Check previous scans
for (int i = 0; i < (int)hasScanned.size(); i++)
{
if (hasScanned.at(i).x() == basePos.x() && hasScanned.at(i).y() == basePos.y())
{
needScan = false;
}
}
//2. Check if we have this base
vector<BaseAgent*> agents = AgentManager::getInstance()->getAgents();
for (int i = 0; i < (int)agents.size(); i++)
{
if (agents.at(i)->isAlive())
{
double dist = basePos.getDistance(agents.at(i)->getUnit()->getTilePosition());
if (dist <= 10)
{
needScan = false;
break;
}
}
}
//3. Check if enemy units are near
for(set<Unit*>::const_iterator j=Broodwar->enemy()->getUnits().begin();j!=Broodwar->enemy()->getUnits().end();j++)
{
if ((*j)->exists())
{
double dist = basePos.getDistance((*j)->getTilePosition());
if (dist <= 10)
{
needScan = false;
break;
}
}
}
if (needScan)
{
return basePos;
}
}
return TilePosition(-1, -1);
}
示例5: abs
void Monster::FindPath(Tile* p_start, Tile* p_goal)
{
Tile* toCheck[4];
vector<AstarItem> queue;
vector<AstarItem> visited;
AstarItem first;
first.toStart = 0;
TilePosition startdif = p_goal->getTilePosition() - p_start->getTilePosition();
first.toGoal = abs(startdif.x) + abs(startdif.y);
first.tile = p_start;
first.parent = NULL;
queue.push_back(first);
while (queue.size() > 0 && queue.back().tile != p_goal)
{
visited.push_back(queue.back());
TilePosition p = queue.back().tile->getTilePosition();
queue.pop_back();
toCheck[0] = m_map->getTile(p + TilePosition(0, 1));
toCheck[1] = m_map->getTile(p + TilePosition(0, -1));
toCheck[2] = m_map->getTile(p + TilePosition(1, 0));
toCheck[3] = m_map->getTile(p + TilePosition(-1, 0));
for (int i = 0; i < 4; i++)
{
if (toCheck[i])
{
bool skip = !toCheck[i]->isFree();
for (unsigned int j = 0; j < visited.size(); j++)
{
if (visited[j].tile == toCheck[i])
skip = true;
}
if (!skip)
{
int toStart = visited.back().toStart+1;
TilePosition dif = p_goal->getTilePosition() - toCheck[i]->getTilePosition();
int toGoal = abs(dif.x) + abs(dif.y);
UpdateQueue(toCheck[i], visited.size()-1, toStart, toGoal, queue);
}
}
}
}
if (queue.size() == 0)
return;
m_path.clear();
m_path.push_back(queue.back().tile);
int parent = queue.back().parent;
while (m_path.back() != p_start)
{
AstarItem asi = visited[parent];
m_path.push_back(asi.tile);
parent = asi.parent;
}
return;
}
示例6: assert
UINT RenderCache::Paint(HDC hdc, RectI bounds, DisplayModel *dm, int pageNo,
PageInfo *pageInfo, bool *renderOutOfDateCue)
{
assert(pageInfo->shown && 0.0 != pageInfo->visibleRatio);
int rotation = dm->Rotation();
float zoom = dm->ZoomReal();
USHORT targetRes = GetTileRes(dm, pageNo);
USHORT maxRes = GetMaxTileRes(dm, pageNo, rotation);
if (maxRes < targetRes)
maxRes = targetRes;
Vec<TilePosition> queue;
queue.Append(TilePosition(0, 0, 0));
UINT renderDelayMin = RENDER_DELAY_UNDEFINED;
bool neededScaling = false;
while (queue.Count() > 0) {
TilePosition tile = queue.At(0);
queue.RemoveAt(0);
RectI tileOnScreen = GetTileOnScreen(dm->engine, pageNo, rotation, zoom, tile, pageInfo->pageOnScreen);
tileOnScreen = pageInfo->pageOnScreen.Intersect(tileOnScreen);
RectI isect = bounds.Intersect(tileOnScreen);
if (isect.IsEmpty())
continue;
bool isTargetRes = tile.res == targetRes;
UINT renderDelay = PaintTile(hdc, isect, dm, pageNo, tile, tileOnScreen, isTargetRes,
renderOutOfDateCue, isTargetRes ? &neededScaling : NULL);
if (!(isTargetRes && 0 == renderDelay) && tile.res < maxRes) {
queue.Append(TilePosition(tile.res + 1, tile.row * 2, tile.col * 2));
queue.Append(TilePosition(tile.res + 1, tile.row * 2, tile.col * 2 + 1));
queue.Append(TilePosition(tile.res + 1, tile.row * 2 + 1, tile.col * 2));
queue.Append(TilePosition(tile.res + 1, tile.row * 2 + 1, tile.col * 2 + 1));
}
if (isTargetRes && renderDelay > 0)
neededScaling = true;
renderDelayMin = min(renderDelay, renderDelayMin);
// paint tiles from left to right from top to bottom
if (tile.res > 0 && queue.Count() > 0 && tile.res < queue.At(0).res)
queue.Sort(cmpTilePosition);
}
#ifdef CONSERVE_MEMORY
if (!neededScaling) {
if (renderOutOfDateCue)
*renderOutOfDateCue = false;
// free tiles with different resolution
TilePosition tile(targetRes, (USHORT)-1, 0);
FreePage(dm, pageNo, &tile);
}
FreeNotVisible();
#endif
return renderDelayMin;
}
示例7: TilePosition
TilePosition CoverMap::findBuildSpot(UnitType toBuild, TilePosition start)
{
//Check start pos
if (canBuildAt(toBuild, start)) return start;
//Search outwards
bool found = false;
int cDiff = 1;
TilePosition spot = TilePosition(-1, -1);
while (!found)
{
//Top
TilePosition s = TilePosition(start.x() - cDiff, start.y() - cDiff);
TilePosition e = TilePosition(start.x() + cDiff, start.y() - cDiff);
spot = findSpotAtSide(toBuild, s, e);
if (spot.x() != -1 && spot.y() != -1)
{
found = true;
break;
}
//Bottom
s = TilePosition(start.x() - cDiff, start.y() + cDiff);
e = TilePosition(start.x() + cDiff, start.y() + cDiff);
spot = findSpotAtSide(toBuild, s, e);
if (spot.x() != -1 && spot.y() != -1)
{
found = true;
break;
}
//Left
s = TilePosition(start.x() - cDiff, start.y() - cDiff);
e = TilePosition(start.x() - cDiff, start.y() + cDiff);
spot = findSpotAtSide(toBuild, s, e);
if (spot.x() != -1 && spot.y() != -1)
{
found = true;
break;
}
//Right
s = TilePosition(start.x() + cDiff, start.y() - cDiff);
e = TilePosition(start.x() + cDiff, start.y() + cDiff);
spot = findSpotAtSide(toBuild, s, e);
if (spot.x() != -1 && spot.y() != -1)
{
found = true;
break;
}
cDiff++;
if (cDiff > range) found = true;
}
return spot;
}
示例8: GetCenter
Bomb* GOFactory::CreateBomb(Tile* p_tile, Tilemap* p_map)
{
vector<pair<Tile*, SpriteInfo*> > flames;
fVector3 pos = GetCenter(p_tile, 0.6f);
fVector2 size = GetScaledSize(p_tile, 1.2f);
Rect r;
r.x = 0;
r.y = 0;
r.height = 64;
r.width = 64;
SpriteInfo* spriteInfo = CreateSpriteInfo("../Textures/Explosion_Animation.png",
pos, size, &r);
flames.push_back(pair<Tile*, SpriteInfo*>(p_tile, spriteInfo));
TilePosition dir[] = {TilePosition(1, 0), TilePosition(-1, 0), TilePosition(0, 1), TilePosition(0, -1)};
for (int i = 0; i < 4; i++)
{
Tile* curr = p_map->getTile(p_tile->getTilePosition() + dir[i]);
while (curr && curr->isFree())
{
pos = GetCenter(curr, 0.6f);
size = GetScaledSize(curr, 1.2f);
r.x = 0;
r.y = 0;
r.height = 64;
r.width = 64;
SpriteInfo* spriteInfo = CreateSpriteInfo("../Textures/Explosion_Animation.png",
pos, size, &r);
flames.push_back(pair<Tile*, SpriteInfo*>(curr, spriteInfo));
curr = p_map->getTile(curr->getTilePosition() + dir[i]);
}
}
pos = GetCenter(p_tile, 0.19f);
size = GetScaledSize(p_tile, 2.0f);
Rect br;
br.x = 0;
br.y = 0;
br.height = 64;
br.width = 64;
spriteInfo = CreateSpriteInfo("../Textures/bombitem_anim.png",
pos, size, &br);
return new Bomb(spriteInfo, flames, p_tile, p_map, CreateSoundInfo("../Sounds/Click.wav",100), CreateSoundInfo("../Sounds/blast_2.wav",100));
}
示例9: TilePosition
TilePosition ExplorationManager::scanForVulnerableBase()
{
TilePosition spot = TilePosition(-1, -1);
for (int i = 0; i < (int)spottedBuildings.size(); i++)
{
if (spottedBuildings.at(i)->isActive())
{
SpottedObject* obj = spottedBuildings.at(i);
if (obj->getType().isResourceDepot())
{
if (!isDetectorCovering(obj->getTilePosition()))
{
//Broodwar->printf("Found probable vulnerable base at (%d,%d)", obj->getTilePosition().x(), obj->getTilePosition().y());
spot = obj->getTilePosition();
}
}
}
}
if (spot.x() < 0)
{
//Broodwar->printf("Scan: No vulnerable base found");
}
return spot;
}
示例10: bindCameraToImage
void PosterPrinter::bindCameraToImage( osg::Camera* camera, int row, int col )
{
std::stringstream stream;
stream << "image_" << row << "_" << col;
osg::ref_ptr<osg::Image> image = new osg::Image;
image->setName( stream.str() );
image->allocateImage( (int)_tileSize.x(), (int)_tileSize.y(), 1, GL_RGBA, GL_UNSIGNED_BYTE );
_images[TilePosition(row,col)] = image.get();
// Calculate projection matrix offset of each tile
osg::Matrix offsetMatrix =
osg::Matrix::scale(_tileColumns, _tileRows, 1.0) *
osg::Matrix::translate(_tileColumns-1-2*col, _tileRows-1-2*row, 0.0);
camera->setViewMatrix( _currentViewMatrix );
camera->setProjectionMatrix( _currentProjectionMatrix * offsetMatrix );
// Check intersections between the image-tile box and the model
osgUtil::IntersectionVisitor iv( _intersector.get() );
iv.setReadCallback( g_pagedLoadingCallback.get() );
_intersector->reset();
camera->accept( iv );
if ( _intersector->containsIntersections() )
{
// Apply a cull calback to every paged node obtained, to force the highest level displaying.
// This will be done by the PosterVisitor, who already records all the paged nodes.
}
// Reattach cameras and new allocated images
camera->setRenderingCache( NULL ); // FIXME: Uses for reattaching camera with image, maybe inefficient?
camera->detach( osg::Camera::COLOR_BUFFER );
camera->attach( osg::Camera::COLOR_BUFFER, image.get(), 0, 0 );
}
示例11: getRegion
bool Commander::isOccupied(BWTA::Region* region)
{
BWTA::Polygon p = region->getPolygon();
vector<BaseAgent*> agents = AgentManager::getInstance()->getAgents();
for (int i = 0; i < (int)agents.size(); i++)
{
BaseAgent* agent = agents.at(i);
if (agent->isAlive() && agent->getUnitType().isResourceDepot())
{
BWTA::Region* aRegion = getRegion(agents.at(i)->getUnit()->getTilePosition());
Position c1 = region->getCenter();
Position c2 = aRegion->getCenter();
if (c2.x() == c1.x() && c2.y() == c1.y())
{
return true;
}
}
}
//Check expansion site
TilePosition expansionSite = ExplorationManager::getInstance()->getExpansionSite();
TilePosition center = TilePosition(region->getCenter());
if (expansionSite.x() >= 0)
{
double dist = expansionSite.getDistance(center);
if (dist <= 15)
{
return true;
}
}
return false;
}
示例12: TilePosition
ZerglingAgent::ZerglingAgent(Unit mUnit)
{
unit = mUnit;
type = unit->getType();
unitID = unit->getID();
agentType = "ZerglingAgent";
goal = TilePosition(-1, -1);
}
示例13: Entity
DoorEntity::DoorEntity(const TextureManager& textures, World* world)
: Entity(world)
{
mSprite.setTexture(textures.get(Textures::AutoDoors));
setTilePosition(TilePosition(5,1));
mSprite.setScale(world->getWorldScale());
initalize();
}
示例14: TilePosition
DragoonAgent::DragoonAgent(Unit* mUnit) {
unit = mUnit;
unitID = unit->getID();
//Broodwar->printf("DragoonAgent created (%s)", unit->getType().getName().c_str());
lastFrame = 0;
goal = TilePosition(-1, -1);
}
示例15: TilePosition
WraithAgent::WraithAgent(Unit mUnit)
{
unit = mUnit;
type = unit->getType();
unitID = unit->getID();
agentType = "WraithAgent";
goal = TilePosition(-1, -1);
}