本文整理汇总了C++中CMonster::SetCurrentGame方法的典型用法代码示例。如果您正苦于以下问题:C++ CMonster::SetCurrentGame方法的具体用法?C++ CMonster::SetCurrentGame怎么用?C++ CMonster::SetCurrentGame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMonster
的用法示例。
在下文中一共展示了CMonster::SetCurrentGame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Process
//*****************************************************************************************
void CRoachQueen::Process(
//Process a roach queen for movement.
//
//Params:
const int nLastCommand, //(in) Last swordsman command.
CCueEvents &CueEvents) //(in/out) Accepts pointer to an IDList object that will be populated
//with codes indicating events that happened that may correspond to
//sound or graphical effects.
{
//Get movement offsets.
int dxFirst, dyFirst, dx, dy;
if (this->pCurrentGame->pRoom->IsBrainPresent())
GetBrainDirectedMovement(dxFirst, dyFirst, dx, dy);
else
{
if (CanFindSwordsman())
{
// Run away!
dx = dxFirst = -sgn(this->pCurrentGame->swordsman.wX - this->wX);
dy = dyFirst = -sgn(this->pCurrentGame->swordsman.wY - this->wY);
GetBestMove(dx, dy);
}
else return; //no change -- and don't lay eggs
}
// Save previous location
const UINT oX = this->wX;
const UINT oY = this->wY;
//Move roach queen to new destination square.
MakeStandardMove(CueEvents,dx,dy);
SetOrientation(dxFirst, dyFirst);
//Shall we lay some eggs?
//The criteria for laying an egg in a square should be:
//1. Square does not contain a monster (including mimic).
//2. Square does not contain a swordsman or sword.
//3. Square does not contain a mimic sword.
//4. T-square is T_EMPTY.
//5. O-square is T_FLOOR.
if ((this->pCurrentGame->wSpawnCycleCount % TURNS_PER_CYCLE == 0) &&
CanFindSwordsman())
{
for (int y = -1; y <= 1; y++)
{
for (int x = -1; x <= 1; x++)
{
const UINT ex = this->wX + x;
const UINT ey = this->wY + y;
if (//Valid
this->pCurrentGame->pRoom->IsValidColRow(ex, ey) &&
// Not current queen position
!(ex == this->wX && ey == this->wY) &&
// Not old queen position (compat)
!(ex == oX && ey == oY) &&
// Not swordsman
!(ex == this->pCurrentGame->swordsman.wX &&
ey == this->pCurrentGame->swordsman.wY) &&
// Not monster or mimic or sword
!DoesSquareContainObstacle(ex, ey) &&
//And t-square is empty (compat).
this->pCurrentGame->pRoom->GetTSquare(ex, ey) == T_EMPTY &&
//And o-square is floor (compat).
this->pCurrentGame->pRoom->GetOSquare(ex, ey) == T_FLOOR
)
{
// Place an egg
CMonster *m = this->pCurrentGame->pRoom->AddNewMonster(M_REGG,
ex,ey);
m->SetCurrentGame(this->pCurrentGame);
m->bIsFirstTurn = true;
}
}
}
}
}