本文整理汇总了C++中IsMoving函数的典型用法代码示例。如果您正苦于以下问题:C++ IsMoving函数的具体用法?C++ IsMoving怎么用?C++ IsMoving使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsMoving函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
int CNPC_Bullsquid::RangeAttack1Conditions( float flDot, float flDist )
{
if ( IsMoving() && flDist >= 512 )
{
// squid will far too far behind if he stops running to spit at this distance from the enemy.
return ( COND_NONE );
}
if ( flDist > 85 && flDist <= 784 && flDot >= 0.5 && gpGlobals->curtime >= m_flNextSpitTime )
{
if ( GetEnemy() != NULL )
{
if ( fabs( GetAbsOrigin().z - GetEnemy()->GetAbsOrigin().z ) > 256 )
{
// don't try to spit at someone up really high or down really low.
return( COND_NONE );
}
}
if ( IsMoving() )
{
// don't spit again for a long time, resume chasing enemy.
m_flNextSpitTime = gpGlobals->curtime + 5;
}
else
{
// not moving, so spit again pretty soon.
m_flNextSpitTime = gpGlobals->curtime + 0.5;
}
return( COND_CAN_RANGE_ATTACK1 );
}
return( COND_NONE );
}
示例2: CheckRangeAttack1
//=========================================================
// CheckRangeAttack1
//=========================================================
BOOL CBullsquid :: CheckRangeAttack1 ( float flDot, float flDist )
{
if ( IsMoving() && flDist >= 512 )
{
// squid will far too far behind if he stops running to spit at this distance from the enemy.
return FALSE;
}
if ( flDist > 64 && flDist <= 784 && flDot >= 0.5 && gpGlobals->time >= m_flNextSpitTime )
{
if ( m_hEnemy != NULL )
{
if ( fabs( pev->origin.z - m_hEnemy->pev->origin.z ) > 256 )
{
// don't try to spit at someone up really high or down really low.
return FALSE;
}
}
if ( IsMoving() )
{
// don't spit again for a long time, resume chasing enemy.
m_flNextSpitTime = gpGlobals->time + 5;
}
else
{
// not moving, so spit again pretty soon.
m_flNextSpitTime = gpGlobals->time + 0.5;
}
return TRUE;
}
return FALSE;
}
示例3: IsMoving
// Update
void Game_Player::Update() {
bool last_moving = IsMoving();
if (!IsMoving() && !Game_Map::GetInterpreter().IsRunning()
/*move_route_forcing || Game_Temp::message_window_showing*/) {
switch (Input::dir4) {
case 2:
MoveDown();
break;
case 4:
MoveLeft();
break;
case 6:
MoveRight();
break;
case 8:
MoveUp();
}
}
int last_real_x = real_x;
int last_real_y = real_y;
Game_Character::Update();
UpdateScroll(last_real_x, last_real_y);
UpdateNonMoving(last_moving);
}
示例4: SetSpriteName
void Game_Event::Setup(RPG::EventPage* new_page) {
bool from_null = page == NULL;
page = new_page;
// Free resources if needed
if (interpreter) {
// If the new page is null and the interpreter is running, it should
// carry on executing its command list during this frame
if (page)
interpreter->Clear();
Game_Map::ReserveInterpreterDeletion(interpreter);
interpreter.reset();
}
if (page == NULL) {
tile_id = 0;
SetSpriteName("");
SetSpriteIndex(0);
SetDirection(RPG::EventPage::Direction_down);
//move_type = 0;
trigger = -1;
list.clear();
return;
}
SetSpriteName(page->character_name);
SetSpriteIndex(page->character_index);
tile_id = page->character_name.empty() ? page->character_index : 0;
if (original_pattern != page->character_pattern) {
pattern = page->character_pattern;
original_pattern = pattern;
}
move_type = page->move_type;
SetMoveSpeed(page->move_speed);
SetMoveFrequency(page->move_frequency);
max_stop_count = (GetMoveFrequency() > 7) ? 0 : (int)pow(2.0, 8 - GetMoveFrequency());
original_move_frequency = page->move_frequency;
original_move_route = page->move_route;
SetOriginalMoveRouteIndex(0);
bool last_direction_fixed = IsDirectionFixed() || IsFacingLocked();
animation_type = page->animation_type;
if (from_null || !(last_direction_fixed || IsMoving()) || IsDirectionFixed())
SetSpriteDirection(page->character_direction);
if (!IsMoving())
SetDirection(page->character_direction);
SetOpacity(page->translucent ? 160 : 255);
SetLayer(page->layer);
data.overlap_forbidden = page->overlap_forbidden;
trigger = page->trigger;
list = page->event_commands;
if (trigger == RPG::EventPage::Trigger_parallel) {
interpreter.reset(new Game_Interpreter_Map());
}
}
示例5: IsMoving
void Game_Player::Update() {
bool last_moving = IsMoving();
if (!IsMoving() && !Game_Map::GetInterpreter().IsRunning()
&& !IsMoveRouteOverwritten() && !Game_Message::message_waiting) {
switch (Input::dir4) {
case 2:
MoveDown();
break;
case 4:
MoveLeft();
break;
case 6:
MoveRight();
break;
case 8:
MoveUp();
}
}
int last_real_x = real_x;
int last_real_y = real_y;
Game_Character::Update();
UpdateScroll(last_real_x, last_real_y);
UpdateNonMoving(last_moving);
}
示例6: TakeDamage
//=========================================================
// TakeDamage - overridden for bullsquid so we can keep track
// of how much time has passed since it was last injured
//=========================================================
int CBullsquid :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{
float flDist;
Vector vecApex;
// if the squid is running, has an enemy, was hurt by the enemy, hasn't been hurt in the last 3 seconds, and isn't too close to the enemy,
// it will swerve. (whew).
if ( m_hEnemy != NULL && IsMoving() && pevAttacker == m_hEnemy->pev && gpGlobals->time - m_flLastHurtTime > 3 )
{
flDist = ( pev->origin - m_hEnemy->pev->origin ).Length2D();
if ( flDist > SQUID_SPRINT_DIST )
{
flDist = ( pev->origin - m_Route[ m_iRouteIndex ].vecLocation ).Length2D();// reusing flDist.
if ( FTriangulate( pev->origin, m_Route[ m_iRouteIndex ].vecLocation, flDist * 0.5, m_hEnemy, &vecApex ) )
{
InsertWaypoint( vecApex, bits_MF_TO_DETOUR | bits_MF_DONT_SIMPLIFY );
}
}
}
if ( !FClassnameIs ( pevAttacker, "monster_headcrab" ) )
{
// don't forget about headcrabs if it was a headcrab that hurt the squid.
m_flLastHurtTime = gpGlobals->time;
}
return CBaseMonster :: TakeDamage ( pevInflictor, pevAttacker, flDamage, bitsDamageType );
}
示例7: WriteToPacket
// ------------------------------------------------------------------------------------------------
Uint32 ProjectileBase :: WriteToPacket(Uint32 dataWritePos, Uint8 data[])
{
Uint32 sendId = Id();
ProjectileType sendType = Type();
Vector2df sendPos = Pos();
Uint32 sendHeadingDeg = HeadingDeg();
float sendSpeed = Speed();
Uint32 sendOwnerPlayerId = OwnerPlayerId();
float sendLife = Life();
Uint32 sendHealth = Health();
bool sendIsMoving = IsMoving();
memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_ID], &sendId, 4);
memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_TYPE], &sendType, 4);
memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_POSX], &sendPos.x, 4);
memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_POSY], &sendPos.y, 4);
memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_HEADING], &sendHeadingDeg, 4);
memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_SPEED], &sendSpeed, 4);
memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_LIFE], &sendLife, 4);
memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_HEALTH], &sendHealth, 4);
memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_PLAYER_ID], &sendOwnerPlayerId, 4);
memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_ISMOVING], &sendIsMoving, 1);
return PACKET_WRITE_PROJECTILE_LENGTH;
} // ----------------------------------------------------------------------------------------------
示例8: if
void SmoothFollowProcess::VUpdate(unsigned int elapsedTime)
{
float diffX = m_posX - m_pImage->GetPosX();
float diffY = m_posY - m_pImage->GetPosY();
float deltaX = diffX*m_speed*elapsedTime;
float deltaY = diffY*m_speed*elapsedTime;
if(fabs(deltaX) > fabs(diffX))
deltaX = diffX;
if(fabs(deltaY) > fabs(diffY))
deltaY = diffY;
m_pImage->Translate(deltaX, deltaY);
double diffAngle = m_angle - m_pImage->GetAngle();
if(diffAngle < -180)
diffAngle += 360;
else if(diffAngle > 180)
diffAngle -= 360;
double deltaAngle = diffAngle*m_speed*elapsedTime;
if(fabs(deltaAngle) > fabs(diffAngle))
deltaAngle = diffAngle;
m_pImage->SetAngle(m_pImage->GetAngle() + deltaAngle);
if(!IsMoving(0.5f) && m_bEndIfStatic)
Success();
}
示例9: UpdateMovement
void CEntity::UpdateMovement(Ogre::Real ElapsedTime)
{
//Also update walk/idle animation?
if( IsMoving() ){
Ogre::Real LenghtLeftToGo = (GetDestination() - GetPosition()).length();
Ogre::Vector3 Movement = GetMovement();
Ogre::Vector3 CorrectedMovement = ( Movement * ElapsedTime );
//Set the right angle for the entity
mNode->lookAt( GetDestination(), Ogre::Node::TS_WORLD );
if( CorrectedMovement.length() < LenghtLeftToGo ){ //Not at destination yet, just move
mNode->translate( CorrectedMovement );
}else{ //Arrived at destination
mNode->setPosition( GetDestination() );
ReachedDestination();
//TODO: If there is a next destination then go there with the frametime left of this movement.
//(Loop till all frametime is used for movement)
//Example: if there are 3 destinations left, and the first 2 will be reached
//in 2 seconds.
//If the user has a slow computer that updates the frame every 2,5 seconds,
//then it should first use x seconds to reach destination one, then check
//for how many seconds left, and use those to go to the next node and so on.
}
}
}
示例10: switch
void CAI_PlayerAlly::RunTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_TALKER_CLIENT_STARE:
case TASK_TALKER_LOOK_AT_CLIENT:
if ( pTask->iTask == TASK_TALKER_CLIENT_STARE )
{
// Get edict for one player
CBasePlayer *pPlayer = (CBasePlayer *)CBaseEntity::Instance( engine->PEntityOfEntIndex( 1 ) );
Assert( pPlayer );
// fail out if the player looks away or moves away.
if ( ( pPlayer->GetLocalOrigin() - GetLocalOrigin() ).Length2D() > TLK_STARE_DIST )
{
// player moved away.
TaskFail("Player moved away");
}
Vector forward;
AngleVectors( pPlayer->GetLocalAngles(), &forward );
if ( UTIL_DotPoints( pPlayer->GetLocalOrigin(), GetLocalOrigin(), forward ) < m_flFieldOfView )
{
// player looked away
TaskFail("Player looked away");
}
}
if ( gpGlobals->curtime > m_flWaitFinished )
{
TaskComplete();
}
break;
case TASK_TALKER_EYECONTACT:
if (IsMoving() || !GetExpresser()->IsSpeaking() || GetSpeechTarget() == NULL)
{
TaskComplete();
}
break;
case TASK_WAIT_FOR_MOVEMENT:
if (!GetExpresser()->IsSpeaking() || GetSpeechTarget() == NULL)
{
// override so that during walk, a scientist may talk and greet player
FIdleHello();
if (random->RandomInt(0,m_nSpeak * 20) == 0)
{
FIdleSpeak();
}
}
BaseClass::RunTask( pTask );
break;
default:
BaseClass::RunTask( pTask );
}
}
示例11: Move
void CObject::Move ( const CVector& vecPosition, const CVector& vecRotation, unsigned long ulTime )
{
// Are we already moving?
if ( IsMoving () )
{
// Stop our current movement
StopMoving ();
}
// If it's more than 0 milliseconds
if ( ulTime > 0 )
{
// Setup our move data
m_moveData.vecStartPosition = GetPosition ();
m_moveData.vecStopPosition = vecPosition;
GetRotation ( m_moveData.vecStartRotation );
m_moveData.vecStopRotation = vecRotation;
m_moveData.ulTime = ulTime;
m_moveData.ulTimeStart = GetTime ();
m_moveData.ulTimeStop = m_moveData.ulTimeStart + ulTime;
m_moveData.bActive = true;
}
// If we have a time of 0, move there now
else
{
SetPosition ( vecPosition );
CVector vecTemp;
GetRotation ( vecTemp );
SetRotation ( vecTemp + vecRotation );
}
}
示例12: StopFollowing
void CSyncCoreObjectMediator::DisbindConnection()
{
if( !m_pConn )
return;
if(!IsActive())
StopFollowing();
if(IsMoving())
StopMoving();
m_bDisbindingConn = false;
GetScene()->DelFromMulticast( m_pConn );
m_fDirKnownMaxSpeed = 0;
//cout<<"DisbindConnection DestroyObjForConnection "<<GetGlobalID()<<endl;
DestroyObjForConnection( m_pConn );
m_pConn->SetMediator(NULL);
AddConnBlockCount();
//关联某个连接,必须最后将m_pConn设置为NULL
IntSetConnection(NULL);
(new CCoreObjOnConnectionDisbindedResult(GetGlobalID()))->Add();
}
示例13: IsMovable
bool Game_Vehicle::IsMovable() {
if (!IsInUse())
return false;
if (type == Airship && (IsAscending() || IsDescending()))
return false;
return !IsMoving();
}
示例14: if
const CVector& CObject::GetPosition ( void )
{
// Are we attached to something?
if ( m_pAttachedTo )
{
m_vecPosition = m_pAttachedTo->GetPosition ();
m_vecPosition += m_vecAttachedPosition;
}
// Are we moving?
else if ( IsMoving () )
{
// Calculate our current Position
unsigned long ulCurrentTime = GetTime ();
// Grab the difference between start and finish
CVector vecJourney = m_moveData.vecStopPosition - m_moveData.vecStartPosition;
// Grab the duration the object takes to move
float fDuration = static_cast < float > ( m_moveData.ulTime );
// Grab the time that has passed since we started moving
float fTimePassed = static_cast < float > ( ulCurrentTime - m_moveData.ulTimeStart );
// How far along our journey should we be?
vecJourney /= fDuration;
vecJourney *= fTimePassed;
// Update our stored position
m_vecPosition = m_moveData.vecStartPosition + vecJourney;
}
// Finally, return it
return m_vecPosition;
}
示例15: GetAbsOrigin
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CNPC_Monster::PrescheduleThink( void )
{
bool bNearEnemy = false;
if ( GetEnemy() != NULL )
{
float flDist = (GetEnemy()->GetAbsOrigin() - GetAbsOrigin()).Length();
if ( flDist < ZOMBIE_ENEMY_BREATHE_DIST )
{
bNearEnemy = true;
}
}
if ( bNearEnemy )
{
if ( !m_bNearEnemy )
{
m_bNearEnemy = true;
}
}
else if ( m_bNearEnemy )
{
m_bNearEnemy = false;
}
BaseClass::PrescheduleThink();
// We're chopped off! And we're moving! Add some blood trail...
if (m_fIsTorso && IsMoving() && (m_flLastBloodTrail < gpGlobals->curtime))
{
m_flLastBloodTrail = gpGlobals->curtime + 1.0f; // We don't want to spam blood all over the place.
trace_t tr;
UTIL_TraceLine((GetAbsOrigin() + Vector(0, 0, 50)), (GetAbsOrigin() + Vector(0, 0, -300)), MASK_ALL, this, COLLISION_GROUP_NONE, &tr);
UTIL_DecalTrace(&tr, "Blood");
}
}