本文整理汇总了C++中TilePosition::y方法的典型用法代码示例。如果您正苦于以下问题:C++ TilePosition::y方法的具体用法?C++ TilePosition::y怎么用?C++ TilePosition::y使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TilePosition
的用法示例。
在下文中一共展示了TilePosition::y方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unitDestroyed
void ExplorationManager::unitDestroyed(Unit* unit)
{
TilePosition uPos = unit->getTilePosition();
if (unit->getType().isBuilding())
{
bool removed = false;
for (int i = 0; i < (int)spottedBuildings.size(); i++)
{
TilePosition sPos = spottedBuildings.at(i)->getTilePosition();
if (uPos.x() == sPos.x() && uPos.y() == sPos.y())
{
spottedBuildings.at(i)->setInactive();
removed = true;
}
}
if (!removed)
{
//Broodwar->printf("[EM]: Building %s at (%d,%d) was not removed from EM!!!", unit->getType().getName().c_str(), uPos.x(), uPos.y());
}
}
else
{
for (int i = 0; i < (int)spottedUnits.size(); i++)
{
if (spottedUnits.at(i)->getUnitID() == unit->getID())
{
spottedUnits.at(i)->setInactive();
//Broodwar->printf("[EM]: Remove %s at (%d,%d)", unit->getType().getName().c_str(), uPos.x(), uPos.y());
}
}
}
}
示例2: isVisible
bool Squad::isVisible(TilePosition pos)
{
if (!ExplorationManager::canReach(Broodwar->self()->getStartLocation(), pos))
{
return true;
}
if (Broodwar->isVisible(pos))
{
return true;
}
if (getCenter().getDistance(pos) <= 3)
{
return true;
}
for (int i = 0; i < (int)hasVisited.size(); i++)
{
TilePosition vPos = hasVisited.at(i);
if (vPos.x() == pos.x() && vPos.y() == pos.y())
{
return true;
}
}
return false;
}
示例3: canBuildAt
bool CoverMap::canBuildAt(UnitType toBuild, TilePosition pos)
{
int maxW = w - toBuild.tileWidth() - 1;
int maxH = h - toBuild.tileHeight() - 1;
//Out of bounds check
if (pos.x() >= 0 && pos.x() < maxW && pos.y() >= 0 && pos.y() < maxH)
{
if (canBuild(toBuild, pos))
{
return true;
}
}
return false;
}
示例4: build
void UnitClass::build(TilePosition target, BWAPI::UnitType type)
{
if(exists())
{
const Position targetPosition(target.x()*32+type.tileWidth()*16, target.y()*32+type.tileHeight()*16);
if(getDistance(type, targetPosition) > 48 || !MapHelper::isAllVisible(target, type))
{
move(targetPosition, 0);
return;
}
if(mUnit->getOrder() == BWAPI::Orders::PlaceBuilding)
{
if(mUnit->getBuildType() == type && mUnit->getOrderTargetPosition() == targetPosition)
return;
}
if(mUnit->getLastCommand().getType() == BWAPI::UnitCommandTypes::Build && mUnit->getLastCommand().getUnitType() == type && mUnit->getLastCommand().getTargetTilePosition() == target)
{
if(mLastOrderExecuteTime >= BWAPI::Broodwar->getFrameCount())
return;
}
if(mUnit->build(target, type))
mLastOrderExecuteTime = BWAPI::Broodwar->getFrameCount() + BWAPI::Broodwar->getRemainingLatencyFrames();
else
move(targetPosition, 0);
}
}
示例5: getNextScanLocation
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);
}
示例6: findBuildSpot
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;
}
示例7: positionFree
bool CoverMap::positionFree(TilePosition pos)
{
if (cover_map[pos.x()][pos.y()] == BUILDABLE)
{
return true;
}
return false;
}
示例8: drawUnitTilePosition
void UnitClass::drawUnitTilePosition()
{
TilePosition tile = getTilePosition();
BWAPI::UnitType type = getType();
Player player = getPlayer();
BWAPI::Broodwar->drawBox(BWAPI::CoordinateType::Map, tile.x()*32, tile.y()*32, (tile.x()+type.tileWidth())*32, (tile.y()+type.tileHeight())*32, player->getColor());
}
示例9: unitsInArea
bool AgentManager::unitsInArea(TilePosition pos, int tileWidth, int tileHeight, int unitID)
{
for (int i = 0; i < (int)agents.size(); i++)
{
if (agents.at(i)->isAlive())
{
if (agents.at(i)->getUnit()->getID() != unitID)
{
TilePosition aPos = agents.at(i)->getUnit()->getTilePosition();
if (aPos.x() >= pos.x() && aPos.x() <= pos.x() + tileWidth && aPos.y() >= pos.y() && aPos.y() <= pos.y() + tileWidth)
{
return true;
}
}
}
}
return false;
}
示例10: canReach
bool ExplorationManager::canReach(TilePosition a, TilePosition b)
{
int w = Broodwar->mapWidth();
int h = Broodwar->mapHeight();
if (a.x() < 0 || a.x() >= w || a.y() < 0 || a.y() >= h)
{
return false;
}
if (b.x() < 0 || b.x() >= w || b.y() < 0 || b.y() >= h)
{
return false;
}
bool ok = true;
ok = a.hasPath(b);
return ok;
}
示例11: blockPosition
void CoverMap::blockPosition(TilePosition buildSpot)
{
if (buildSpot.x() == -1)
{
//Error check
return;
}
cover_map[buildSpot.x()][buildSpot.y()] = BLOCKED;
}
示例12: findSpotAtSide
TilePosition CoverMap::findSpotAtSide(UnitType toBuild, TilePosition start, TilePosition end)
{
int dX = end.x() - start.x();
if (dX != 0) dX = 1;
int dY = end.y() - start.y();
if (dY != 0) dY = 1;
TilePosition cPos = start;
bool done = false;
while (!done)
{
if (canBuildAt(toBuild, cPos)) return cPos;
int cX = cPos.x() + dX;
int cY = cPos.y() + dY;
cPos = TilePosition(cX, cY);
if (cPos.x() == end.x() && cPos.y() == end.y()) done = true;
}
return TilePosition(-1, -1);
}
示例13: defend
void Squad::defend(TilePosition mGoal)
{
if (mGoal.x() == -1 || mGoal.y() == -1) return;
if (currentState != STATE_DEFEND)
{
if (currentState == STATE_ASSIST && !isUnderAttack())
{
currentState = STATE_DEFEND;
}
}
setGoal(mGoal);
}
示例14: isThisGoal
bool Squad::isThisGoal(TilePosition mGoal)
{
int xDiff = goal.x() - mGoal.x();
if (xDiff < 0) xDiff *= -1;
int yDiff = goal.y() - mGoal.y();
if (yDiff < 0) yDiff *= -1;
//Broodwar->printf("SQ %d: (%d,%d) = (%d,%d)", id, goal.x(), goal.y(), mGoal.x(), mGoal.y());
if (xDiff <= 2 && yDiff <= 2)
{
return true;
}
return false;
}
示例15: onNukeDetect
void BTHAIModule::onNukeDetect(BWAPI::Position target)
{
// TODO: React on this! Make all units move outside of the blast radius?
// Notify the commander and let it make a decision?
if (target != Positions::Unknown)
{
TilePosition t = TilePosition(target);
Broodwar->printf("Nuclear Launch Detected at (%d,%d)",t.x(),t.y());
Commander::Instance().onNukeDetect(target);
}
else
{
Broodwar->printf("Nuclear Launch Detected");
}
}