本文整理汇总了C++中CanMove函数的典型用法代码示例。如果您正苦于以下问题:C++ CanMove函数的具体用法?C++ CanMove怎么用?C++ CanMove使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CanMove函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: HandleActionUnload
/**
** The transporter unloads a unit.
**
** @param unit Pointer to unit.
*/
void HandleActionUnload(CUnit *unit)
{
int i;
int x;
int y;
if (!CanMove(unit)) {
unit->SubAction = 2;
}
switch (unit->SubAction) {
//
// Move the transporter
//
case 0:
if (!unit->Orders[0]->Goal) {
if (!ClosestFreeDropZone(unit, unit->Orders[0]->X, unit->Orders[0]->Y,
&x, &y)) {
// Sorry... I give up.
unit->ClearAction();
return;
}
unit->Orders[0]->X = x;
unit->Orders[0]->Y = y;
}
NewResetPath(unit);
unit->SubAction = 1;
case 1:
// The Goal is the unit that we have to unload.
if (!unit->Orders[0]->Goal) {
// We have to unload everything
if ((i = MoveToDropZone(unit))) {
if (i == PF_REACHED) {
if (++unit->SubAction == 1) {
unit->ClearAction();
}
} else {
unit->SubAction = 2;
}
}
break;
}
//
// Leave the transporter
//
case 2:
// FIXME: show still animations ?
LeaveTransporter(unit);
if (CanMove(unit) && unit->Orders[0]->Action != UnitActionStill) {
HandleActionUnload(unit);
}
break;
}
}
开发者ID:OneSleepyDev,项目名称:boswars_osd,代码行数:59,代码来源:action_unload.cpp
示例2: rand
bool Oneal::Collision(Entity* E) {
// Entity-to-map collision
if (E == NULL) {
int dice = rand()%100;
if (abs(SpeedX) > 0) {
//50% to go in opposite direction
if (dice > 50 && CanMove(X - SpeedX, Y)) {
//std::cout << "Diced " << dice << " to go in the opposite direction. Speed " << SpeedX;
SpeedX = -SpeedX;
//std::cout << " to " << SpeedX << std::endl;
} else if (dice > 25 && CanMove(X, Y + SpeedX)) {
//std::cout << "Diced " << dice << " to go down. Speed " << SpeedX << " " << SpeedY;
if (SpeedY == 0) SpeedY = SpeedX;
SpeedX = 0;
//std::cout << " to " << SpeedX << " " << SpeedY << std::endl;
} else {
//std::cout << "Diced " << dice << " to go up. Speed " << SpeedX << " " << SpeedY;
if (SpeedY == 0) SpeedY = -SpeedX;
SpeedX = 0;
//std::cout << " to " << SpeedX << " " << SpeedY << std::endl;
}
}
if (abs(SpeedY) > 0) {
//50% to go in opposite direction
if (dice > 50) {
//std::cout << "Diced " << dice << " to go in the opposite direction. Speed " << SpeedY;
SpeedY = -SpeedY;
//std::cout << " to " << SpeedY << std::endl;
} else if (dice > 25) {
//std::cout << "Diced " << dice << " to go right direction. Speed " << SpeedY << " " << SpeedX;
if (SpeedX == 0) SpeedX = SpeedY;
SpeedY = 0;
//std::cout << " to " << SpeedX << " " << SpeedY << std::endl;
} else {
if (SpeedX == 0) SpeedX = -SpeedY;
SpeedY = 0;
}
}
return false;
} else {
;
}
return true;
}
开发者ID:charnad,项目名称:arcade-revolt,代码行数:49,代码来源:Oneal.cpp
示例3: MoveLeft
void MoveLeft()
{
struct Brick b = Brick;
b.pos.x--;
if (CanMove(b) == TRUE) {
b.pos.x++;
b.pos.y++;
if ( CanMove(b) == FALSE )
Delay=0;
DisplayBrick(Brick,FALSE);
Brick.pos.x--;
Expect();
DisplayBrick(Brick,TRUE);
}
}
开发者ID:Jn58,项目名称:Tetris,代码行数:15,代码来源:Tetris.c
示例4: MoveDown
BOOL MoveDown()
{
struct Brick b = Brick;
b.pos.y++;
if (CanMove(b) != TRUE) {
return TRUE;
}
if ( CanMove(b) == TRUE ){
DisplayBrick(Brick,FALSE);
Brick.pos.y++;
DisplayBrick(Brick,TRUE);
return FALSE;
}
}
开发者ID:Jn58,项目名称:Tetris,代码行数:15,代码来源:Tetris.c
示例5: MoveUp
void MoveUp()
{
struct Brick b = Brick;
if(++b.rotation == 4) b.rotation=0;
if (CanMove(b) == TRUE) {
DisplayBrick(Brick,FALSE);
Brick.rotation=b.rotation;
Expect();
DisplayBrick(Brick,TRUE);
b.rotation--;
b.pos.y++;
if ( CanMove(b) == FALSE )
Delay=0;
}
}
开发者ID:Jn58,项目名称:Tetris,代码行数:15,代码来源:Tetris.c
示例6: StartMove
bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 diff)
{
// Waypoint movement can be switched on/off
// This is quite handy for escort quests and other stuff
if (creature->HasUnitState(UNIT_STATE_NOT_MOVE))
{
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
return true;
}
// prevent a crash at empty waypoint path.
if (!i_path || i_path->empty())
return false;
if (Stopped())
{
if (CanMove(diff))
return StartMove(creature);
}
else
{
// Set home position at place on waypoint movement.
if (!creature->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) || !creature->GetTransGUID())
creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
if (creature->IsStopped())
Stop(STOP_TIME_FOR_PLAYER);
else if (creature->movespline->Finalized())
{
OnArrived(creature);
return StartMove(creature);
}
}
return true;
}
开发者ID:siknd,项目名称:TrinityCore,代码行数:34,代码来源:WaypointMovementGenerator.cpp
示例7: Stop
bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 diff)
{
// Waypoint movement can be switched on/off
// This is quite handy for escort quests and other stuff
if (creature->HasUnitState(UNIT_STATE_NOT_MOVE))
{
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
return true;
}
// prevent a crash at empty waypoint path.
if (!i_path || i_path->empty())
return false;
// Xinef: Dont allow dead creatures to move
if (!creature->IsAlive())
return false;
// prevent movement while casting spells with cast time or channel time
if (creature->HasUnitState(UNIT_STATE_CASTING))
{
bool stop = true;
if (Spell* spell = creature->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
if (!(spell->GetSpellInfo()->ChannelInterruptFlags & (AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING)) && !(spell->GetSpellInfo()->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT))
stop = false;
if (stop)
{
Stop(1000);
if (!creature->IsStopped())
creature->StopMoving();
return true;
}
}
if (Stopped())
{
if (CanMove(diff))
return StartMove(creature);
}
else
{
if (creature->IsStopped())
Stop(STOP_TIME_FOR_PLAYER);
else
{
// xinef: code to detect pre-empetively if we should start movement to next waypoint
// xinef: do not start pre-empetive movement if current node has delay or we are ending waypoint movement
bool finished = creature->movespline->Finalized();
if (!finished && !i_path->at(i_currentNode)->delay && ((i_currentNode != i_path->size() - 1) || repeating))
finished = (creature->movespline->_Spline().length(creature->movespline->_currentSplineIdx()+1) - creature->movespline->timePassed()) < 200;
if (finished)
{
OnArrived(creature);
return StartMove(creature);
}
}
}
return true;
}
开发者ID:Helias,项目名称:azerothcore-wotlk,代码行数:60,代码来源:WaypointMovementGenerator.cpp
示例8: StartMove
bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 diff)
{
// Waypoint movement can be switched on/off
// This is quite handy for escort quests and other stuff
if (creature->HasUnitState(UNIT_STATE_NOT_MOVE))
{
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
return true;
}
// prevent a crash at empty waypoint path.
if (!i_path || i_path->empty())
return false;
if (Stopped())
{
if (CanMove(diff))
return StartMove(creature);
}
else
{
if (creature->IsStopped())
Stop(STOP_TIME_FOR_PLAYER);
else if (creature->movespline->Finalized())
{
OnArrived(creature);
return StartMove(creature);
}
}
return true;
}
开发者ID:GiR-Zippo,项目名称:SkyFire_5xx,代码行数:30,代码来源:WaypointMovementGenerator.cpp
示例9: CommandFollow
/**
** Follow unit to new position
**
** @param unit pointer to unit.
** @param dest unit to be followed
** @param flush if true, flush command queue.
*/
void CommandFollow(CUnit *unit, CUnit *dest, int flush)
{
COrder *order;
//
// Check if unit is still valid? (NETWORK!)
//
if (!unit->Removed && unit->Orders[0]->Action != UnitActionDie) {
if (!CanMove(unit)) {
// FIXME: should find a better way for pending orders.
order = &unit->NewOrder;
ReleaseOrder(order);
} else if (!(order = GetNextOrder(unit, flush))) {
return;
}
order->Init();
order->Action = UnitActionFollow;
//
// Destination could be killed.
// Should be handled in action, but is not possible!
// Unit::Refs is used as timeout counter.
//
if (dest->Destroyed) {
order->X = dest->X + dest->Type->TileWidth / 2;
order->Y = dest->Y + dest->Type->TileHeight / 2;
} else {
order->Goal = dest;
dest->RefsIncrease();
order->Range = 1;
}
}
ClearSavedAction(unit);
}
开发者ID:k1643,项目名称:StratagusAI,代码行数:41,代码来源:command.cpp
示例10: CommandPatrolUnit
/**
** Let an unit patrol from current to new position
**
** FIXME: want to support patroling between units.
**
** @param unit pointer to unit.
** @param x X map position to patrol between.
** @param y Y map position to patrol between.
** @param flush if true, flush command queue.
*/
void CommandPatrolUnit(CUnit *unit, int x, int y, int flush)
{
COrder *order;
Assert(x >= 0 && y >= 0 && x < Map.Info.MapWidth && y < Map.Info.MapHeight);
//
// Check if unit is still valid? (NETWORK!)
//
if (!unit->Removed && unit->Orders[0]->Action != UnitActionDie) {
if (!CanMove(unit)) {
// FIXME: should find a better way for pending orders.
order = &unit->NewOrder;
ReleaseOrder(order);
} else if (!(order = GetNextOrder(unit, flush))) {
return;
}
order->Init();
order->Action = UnitActionPatrol;
order->X = x;
order->Y = y;
Assert(!(unit->X & ~0xFFFF) && !(unit->Y & ~0xFFFF));
order->Arg1.Patrol.X = unit->X;
order->Arg1.Patrol.Y = unit->Y;
}
ClearSavedAction(unit);
}
开发者ID:k1643,项目名称:StratagusAI,代码行数:38,代码来源:command.cpp
示例11: if
bool WaypointMovementGenerator<Creature>::Update(Creature& creature, const uint32& diff)
{
// Waypoint movement can be switched on/off
// This is quite handy for escort quests and other stuff
if (creature.hasUnitState(UNIT_STAT_NOT_MOVE))
{
creature.clearUnitState(UNIT_STAT_ROAMING_MOVE);
return true;
}
// prevent a crash at empty waypoint path.
if (!i_path || i_path->empty())
{
creature.clearUnitState(UNIT_STAT_ROAMING_MOVE);
return true;
}
if (Stopped(creature))
{
if (CanMove(diff, creature))
{ StartMove(creature); }
}
else
{
if (creature.IsStopped())
{ Stop(STOP_TIME_FOR_PLAYER); }
else if (creature.movespline->Finalized())
{
OnArrived(creature);
StartMove(creature);
}
}
return true;
}
开发者ID:mangostwo,项目名称:server,代码行数:34,代码来源:WaypointMovementGenerator.cpp
示例12: switch
/*
================
rvMonsterConvoyGround::State_Legs_Move
================
*/
stateResult_t rvMonsterConvoyGround::State_Legs_Move ( const stateParms_t& parms ) {
enum {
STAGE_INIT,
STAGE_MOVE
};
switch ( parms.stage ) {
case STAGE_INIT:
move.fl.allowAnimMove = true;
move.fl.allowPrevAnimMove = false;
move.fl.running = true;
move.currentDirection = MOVEDIR_FORWARD;
// TODO: Looks like current anim rate never gets reset, so they do not correctly accelerate from a stop
// unfortunately, adding this change (with a decent acceleration factor) caused them to do lots of
// not-so-good looking short moves.
// moveCurrentAnimRate = 0;
oldOrigin = physicsObj.GetOrigin ( );
PlayCycle ( ANIMCHANNEL_LEGS, "run", 0 );
StartSound( "snd_move", SND_CHANNEL_BODY3, 0, false, NULL );
return SRESULT_STAGE ( STAGE_MOVE );
case STAGE_MOVE:
// If not moving forward just go back to idle
if ( !move.fl.moving || !CanMove() ) {
StopSound( SND_CHANNEL_BODY3, 0 );
PostAnimState ( ANIMCHANNEL_LEGS, "Legs_Idle", 0 );
return SRESULT_DONE;
}
// If on the ground update the animation rate based on the normal of the ground plane
if ( !ai_debugHelpers.GetBool ( ) && physicsObj.HasGroundContacts ( ) ) {
float rate;
idVec3 dir;
dir = (physicsObj.GetOrigin ( ) - oldOrigin);
if ( DistanceTo ( move.moveDest ) < move.walkRange ) {
rate = moveAnimRateMin;
} else if ( dir.Normalize ( ) > 0.0f ) {
rate = idMath::ClampFloat ( -0.7f, 0.7f, physicsObj.GetGravityNormal ( ) * dir ) / 0.7f;
rate = moveAnimRateMin + moveAnimRateRange * (1.0f + rate) / 2.0f;
} else {
rate = moveAnimRateMin + moveAnimRateRange * 0.5f;
}
moveCurrentAnimRate += ((rate - moveCurrentAnimRate) * moveAccelRate);
animator.CurrentAnim ( ANIMCHANNEL_LEGS )->SetPlaybackRate ( gameLocal.time, moveCurrentAnimRate );
}
oldOrigin = physicsObj.GetOrigin ( );
return SRESULT_WAIT;
}
return SRESULT_ERROR;
}
开发者ID:AliKalkandelen,项目名称:quake4,代码行数:63,代码来源:Monster_ConvoyGround.cpp
示例13: Expect
void Expect(){
DisplayBrick(expect,FALSE);
expect=Brick;
expect.t=EXPECT;
while(CanMove(expect))
expect.pos.y++;
expect.pos.y--;
DisplayBrick(expect,TRUE);
}
开发者ID:Jn58,项目名称:Tetris,代码行数:9,代码来源:Tetris.c
示例14: Swipe
void Swipe(){
struct Brick b;
b=Brick;
b.type = Next.type;
if(CanMove(b)){
DisplayBrick( Brick,FALSE);
DisplayNext(FALSE);
Next.type=Brick.type;
Brick.type=b.type;
Expect();
DisplayBrick(Brick,TRUE);
DisplayNext(TRUE);
}
}
开发者ID:Jn58,项目名称:Tetris,代码行数:14,代码来源:Tetris.c
示例15: switch
END_CLASS_STATES
/*
================
rvMonsterRepairBot::State_Legs_Move
================
*/
stateResult_t rvMonsterRepairBot::State_Legs_Move ( const stateParms_t& parms ) {
enum {
STAGE_START,
STAGE_START_WAIT,
STAGE_MOVE,
STAGE_MOVE_WAIT,
STAGE_STOP,
STAGE_STOP_WAIT
};
switch ( parms.stage ) {
case STAGE_START:
PlayAnim ( ANIMCHANNEL_LEGS, "idle_to_run", 4 );
return SRESULT_STAGE ( STAGE_START_WAIT );
case STAGE_START_WAIT:
if ( AnimDone ( ANIMCHANNEL_LEGS, 4 ) ) {
return SRESULT_STAGE ( STAGE_MOVE );
}
return SRESULT_WAIT;
case STAGE_MOVE:
PlayCycle ( ANIMCHANNEL_LEGS, "run", 4 );
return SRESULT_STAGE ( STAGE_MOVE_WAIT );
case STAGE_MOVE_WAIT:
if ( !move.fl.moving || !CanMove() ) {
return SRESULT_STAGE ( STAGE_STOP );
}
return SRESULT_WAIT;
case STAGE_STOP:
PlayAnim ( ANIMCHANNEL_LEGS, "run_to_idle", 4 );
return SRESULT_STAGE ( STAGE_STOP_WAIT );
case STAGE_STOP_WAIT:
if ( AnimDone ( ANIMCHANNEL_LEGS, 4 ) ) {
PostAnimState ( ANIMCHANNEL_LEGS, "Legs_Idle", 4 );
return SRESULT_DONE;
}
return SRESULT_WAIT;
}
return SRESULT_ERROR;
}
开发者ID:ET-NiK,项目名称:amxxgroup,代码行数:50,代码来源:Monster_RepairBot.cpp
示例16: FixPolygon
void CPolygon::FixPolygon(CPoint &point)
{
int i;
if(CanMove(point, m_polygon, *countvertex) )
{
MessageBox("The polygon would reach over the map boundaries","Area editor",MB_ICONWARNING|MB_OK);
}
for(i=0;i<(*countvertex);i++)
{
m_polygon[i].x=(unsigned short) (m_polygon[i].x+point.x);
m_polygon[i].y=(unsigned short) (m_polygon[i].y+point.y);
}
RecalcBox((int) (*countvertex),m_polynum,(POINTS &) (bbox[BBMINX]),(POINTS &) (bbox[BBMAXX]) );
}
开发者ID:TeoTwawki,项目名称:dltcep,代码行数:15,代码来源:Polygon.cpp
示例17: ActionSpellCast
bool Heroes::ActionSpellCast(const Spell & spell)
{
std::string error;
if(! CanMove())
{
Dialog::Message("", _("Your hero is too tired to cast this spell today. Try again tomorrow."), Font::BIG, Dialog::OK);
return false;
}
else
if(spell == Spell::NONE || spell.isCombat() || ! CanCastSpell(spell, &error))
{
if(error.size()) Dialog::Message("Error", error, Font::BIG, Dialog::OK);
return false;
}
bool apply = false;
switch(spell())
{
case Spell::VIEWMINES: apply = ActionSpellViewMines(*this); break;
case Spell::VIEWRESOURCES: apply = ActionSpellViewResources(*this); break;
case Spell::VIEWARTIFACTS: apply = ActionSpellViewArtifacts(*this); break;
case Spell::VIEWTOWNS: apply = ActionSpellViewTowns(*this); break;
case Spell::VIEWHEROES: apply = ActionSpellViewHeroes(*this); break;
case Spell::VIEWALL: apply = ActionSpellViewAll(*this); break;
case Spell::IDENTIFYHERO: apply = ActionSpellIdentifyHero(*this); break;
case Spell::SUMMONBOAT: apply = ActionSpellSummonBoat(*this); break;
case Spell::DIMENSIONDOOR: apply = ActionSpellDimensionDoor(*this); break;
case Spell::TOWNGATE: apply = isShipMaster() ? false : ActionSpellTownGate(*this); break;
case Spell::TOWNPORTAL: apply = isShipMaster() ? false : ActionSpellTownPortal(*this); break;
case Spell::VISIONS: apply = ActionSpellVisions(*this); break;
case Spell::HAUNT: apply = ActionSpellSetGuardian(*this, spell, Monster::GHOST); break;
case Spell::SETEGUARDIAN: apply = ActionSpellSetGuardian(*this, spell, Monster::EARTH_ELEMENT); break;
case Spell::SETAGUARDIAN: apply = ActionSpellSetGuardian(*this, spell, Monster::AIR_ELEMENT); break;
case Spell::SETFGUARDIAN: apply = ActionSpellSetGuardian(*this, spell, Monster::FIRE_ELEMENT); break;
case Spell::SETWGUARDIAN: apply = ActionSpellSetGuardian(*this, spell, Monster::WATER_ELEMENT); break;
default: break;
}
if(apply)
{
DEBUG(DBG_GAME, DBG_INFO, GetName() << " cast spell: " << spell.GetName());
SpellCasted(spell);
return true;
}
return false;
}
开发者ID:infsega,项目名称:fheroes2-playbook,代码行数:48,代码来源:heroes_spell.cpp
示例18: MoveTo
void CWizFolder::MoveTo(QObject* dest)
{
CWizFolder* pFolder = dynamic_cast<CWizFolder*>(dest);
if (!pFolder)
return;
if (IsDeletedItems())
return;
if (!CanMove(this, pFolder)) {
TOLOG2("Can move %1 to %2", Location(), pFolder->Location());
return;
}
return MoveToLocation(pFolder->Location());
}
开发者ID:runforprogram,项目名称:WizQTClient,代码行数:16,代码来源:wizDatabase.cpp
示例19: UpdateGhost
void UpdateGhost(Unit &ghost)
{
ChoosePath(ghost);
TryChase(ghost, Pacman);
if(CanMove(ghost) == true)
{
if(MoveForward(ghost, Speed * 0.5f))
{
ghost.Rotating = false;
}
}
else
{
ghost.Face = (Direction) (rand() % 4);
}
}
开发者ID:BlindJoker,项目名称:pacman,代码行数:17,代码来源:Ghost.cpp
示例20: ChoosePath
void ChoosePath(Unit &ghost)
{
int choices = CanMoveTo(ghost, Right)
+ CanMoveTo(ghost, Left)
+ CanMoveTo(ghost, Up)
+ CanMoveTo(ghost, Down);
if(ghost.Rotating == false && choices >= 3)
{
Direction backwards = Invert(ghost.Face);
do
{
ghost.Face = (Direction) (rand() % 4);
} while(CanMove(ghost) == false || ghost.Face == backwards);
ghost.Rotating = true;
}
}
开发者ID:BlindJoker,项目名称:pacman,代码行数:18,代码来源:Ghost.cpp
注:本文中的CanMove函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论