本文整理汇总了C++中Tile::IsWalkableAI方法的典型用法代码示例。如果您正苦于以下问题:C++ Tile::IsWalkableAI方法的具体用法?C++ Tile::IsWalkableAI怎么用?C++ Tile::IsWalkableAI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tile
的用法示例。
在下文中一共展示了Tile::IsWalkableAI方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckPathValidity
bool Enemy::CheckPathValidity(Level* level)
{
//Traverse the path and check all tiles for validity
for (int i = path.size() - 1; i >= 0; i--)
{
XMINT2 p = path.at(i);
Tile* tile = level->getTile(p.x, p.y);
if (!(tile && tile->IsWalkableAI()))
{
return false;
}
}
if (GetTileCoord() == end)
return false;
if (path.size() <= 0)
return false;
return true;
}
示例2: Update
bool Enemy::Update(Level* level, LightObject* spotlight, bool inLight)
{
if (path.size() > 0)
{
XMFLOAT3 nextPos = position;
if (!inLight)
{
nextPos.x += direction.x / SPEED;
nextPos.z += direction.z / SPEED;
}
else
{
float pushSpeed = SPEED / 2;
nextPos.x += spotlight->getDirection().x / pushSpeed;
nextPos.z += spotlight->getDirection().z / pushSpeed;
}
float radius = 0.5f;
bool result = false;
Tile* currentTile = level->getTile(tileCoord);
if (currentTile != nullptr)
{
Coord nextTileCoord = Coord((int)(abs(nextPos.x)), (int)(abs(nextPos.z)));
for (int x = nextTileCoord.x - 1; x <= nextTileCoord.x + 1; x++)
{
for (int y = nextTileCoord.y - 1; y <= nextTileCoord.y + 1; y++)
{
Coord iteratorTileCoord = Coord(x, y);
Tile* iteratorTile = level->getTile(iteratorTileCoord);
if (!iteratorTile->IsWalkableAI())
{
nextPos = NextPositionFromCollision(result, nextPos, radius, iteratorTileCoord);
if (result && iteratorTile)
{
Container* shadowContainer = iteratorTile->getShadowContainer();
if (shadowContainer && !shadowContainer->GetIsActivated())
{
shadowContainer->ActivateContainer();
return false;
}
}
}
}
}
}
float xRem = -(nextPos.x - (int)nextPos.x);
float zRem = -(nextPos.z - (int)nextPos.z);
if (tileCoord == next && xRem >= 0.45f && zRem >= 0.45f)
{
XMINT2 p = path.at(path.size() - 1);
this->path.pop_back();
next = Coord(p.x, p.y);
direction = XMFLOAT3((-position.x - (next.x + (TILE_SIZE / 2))), 0.0f, -position.z - (next.y + (TILE_SIZE / 2)));
//desiredRotation = -atan2(direction.z, direction.x) * 180 / XM_PI;
rotation.y = -atan2(direction.z, direction.x) * 180 / XM_PI;
SetRotationDeg(rotation);
}
//float difference = desiredRotation - rotation.y;
//cout << difference << endl;
//if (difference < 180)
// rotation.y += difference / 10;
//else
// rotation.y -= difference / 10;
//SetRotationDeg(rotation);
SetPosition(nextPos);
moved = 1;
}
else
{
moved = 0;
}
return true;
}