This commit is contained in:
parent
dac52e3fc7
commit
25e5813c79
3 changed files with 46 additions and 15 deletions
|
@ -61,6 +61,7 @@ void CNpcGaryFriend::postInit()
|
||||||
setCollisionCentreOffset( 0, -14 );
|
setCollisionCentreOffset( 0, -14 );
|
||||||
|
|
||||||
m_garySpeech = false;
|
m_garySpeech = false;
|
||||||
|
m_isStopping = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -227,13 +228,46 @@ void CNpcGaryFriend::think( int _frames )
|
||||||
//return;
|
//return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int garyXMovement = multiplier * GARY_SPEED * _frames;
|
||||||
|
|
||||||
|
if ( m_isStopping )
|
||||||
|
{
|
||||||
|
int garyRequiredXMovement = m_xStopPos - Pos.vx;
|
||||||
|
|
||||||
|
if ( garyRequiredXMovement > 0 )
|
||||||
|
{
|
||||||
|
if ( garyXMovement > garyRequiredXMovement )
|
||||||
|
{
|
||||||
|
garyXMovement = garyRequiredXMovement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( garyRequiredXMovement < 0 )
|
||||||
|
{
|
||||||
|
if ( garyXMovement < garyRequiredXMovement )
|
||||||
|
{
|
||||||
|
garyXMovement = garyRequiredXMovement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_isStopping = false;
|
||||||
|
m_startMoving = false;
|
||||||
|
m_started = false;
|
||||||
|
m_animNo = m_data[m_type].idleAnim;
|
||||||
|
m_animPlaying = true;
|
||||||
|
m_frame = 0;
|
||||||
|
m_garyMeow = false;
|
||||||
|
m_garySB = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( groundHeight <= 0 )
|
if ( groundHeight <= 0 )
|
||||||
{
|
{
|
||||||
// groundHeight <= 0 indicates either on ground or below ground
|
// groundHeight <= 0 indicates either on ground or below ground
|
||||||
|
|
||||||
// check horizontal collision
|
// check horizontal collision
|
||||||
|
|
||||||
if ( CGameScene::getCollision()->getHeightFromGroundNonSB( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight )
|
if ( CGameScene::getCollision()->getHeightFromGroundNonSB( Pos.vx + garyXMovement, Pos.vy ) < -maxHeight )
|
||||||
{
|
{
|
||||||
// reverse direction
|
// reverse direction
|
||||||
|
|
||||||
|
@ -255,7 +289,7 @@ void CNpcGaryFriend::think( int _frames )
|
||||||
|
|
||||||
if ( !conveyorOverride && !m_obstructed )
|
if ( !conveyorOverride && !m_obstructed )
|
||||||
{
|
{
|
||||||
Pos.vx += multiplier * GARY_SPEED * _frames;
|
Pos.vx += garyXMovement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,7 +304,7 @@ void CNpcGaryFriend::think( int _frames )
|
||||||
|
|
||||||
Pos.vy += groundHeight;
|
Pos.vy += groundHeight;
|
||||||
|
|
||||||
if ( CGameScene::getCollision()->getHeightFromGroundNonSB( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight )
|
if ( CGameScene::getCollision()->getHeightFromGroundNonSB( Pos.vx + garyXMovement, Pos.vy ) < -maxHeight )
|
||||||
{
|
{
|
||||||
// reverse direction
|
// reverse direction
|
||||||
|
|
||||||
|
@ -287,7 +321,7 @@ void CNpcGaryFriend::think( int _frames )
|
||||||
|
|
||||||
if ( !conveyorOverride && !m_obstructed )
|
if ( !conveyorOverride && !m_obstructed )
|
||||||
{
|
{
|
||||||
Pos.vx += multiplier * GARY_SPEED * _frames;
|
Pos.vx += garyXMovement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,16 +465,11 @@ void CNpcGaryFriend::start()
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void CNpcGaryFriend::stop()
|
void CNpcGaryFriend::stop( int xPos )
|
||||||
{
|
{
|
||||||
if ( m_started )
|
if ( m_started && !m_isStopping )
|
||||||
{
|
{
|
||||||
m_started = false;
|
m_isStopping = true;
|
||||||
m_startMoving = false;
|
m_xStopPos = xPos;
|
||||||
m_animNo = m_data[m_type].idleAnim;
|
|
||||||
m_animPlaying = true;
|
|
||||||
m_frame = 0;
|
|
||||||
m_garyMeow = false;
|
|
||||||
m_garySB = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
bool alwaysThink() {return(true);}
|
bool alwaysThink() {return(true);}
|
||||||
DVECTOR const &getTriggerPos() {return( m_triggerPos );}
|
DVECTOR const &getTriggerPos() {return( m_triggerPos );}
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop( int xPos );
|
||||||
void startLeft();
|
void startLeft();
|
||||||
void startRight();
|
void startRight();
|
||||||
void render();
|
void render();
|
||||||
|
@ -49,6 +49,8 @@ protected:
|
||||||
u8 m_garyMeow;
|
u8 m_garyMeow;
|
||||||
static u8 m_garySpeech;
|
static u8 m_garySpeech;
|
||||||
static u8 m_hasReachedDoor;
|
static u8 m_hasReachedDoor;
|
||||||
|
u8 m_isStopping;
|
||||||
|
int m_xStopPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -88,7 +88,7 @@ void CGaryStopTrigger::collidedWith(CThing *_thisThing)
|
||||||
{
|
{
|
||||||
CNpcGaryFriend *gary = (CNpcGaryFriend *) _thisThing;
|
CNpcGaryFriend *gary = (CNpcGaryFriend *) _thisThing;
|
||||||
|
|
||||||
gary->stop();
|
gary->stop( Pos.vx );
|
||||||
|
|
||||||
if ( !m_dropped )
|
if ( !m_dropped )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue