This commit is contained in:
parent
330078a40f
commit
8279dc2a13
2 changed files with 79 additions and 33 deletions
|
@ -19,14 +19,28 @@
|
|||
#include "level\layercollision.h"
|
||||
#endif
|
||||
|
||||
#ifndef __GAME_GAME_H__
|
||||
#include "game\game.h"
|
||||
#endif
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcSpikesHazard::init()
|
||||
{
|
||||
CNpcHazard::init();
|
||||
|
||||
m_state = SPIKES_RISING;
|
||||
|
||||
m_respawnRate = 8;
|
||||
m_timerActive = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcSpikesHazard::processMovement( int _frames )
|
||||
{
|
||||
if ( m_timer <= 0 )
|
||||
{
|
||||
s32 minY, maxY;
|
||||
m_npcPath.getPathYExtents( &minY, &maxY );
|
||||
|
@ -38,10 +52,12 @@ void CNpcSpikesHazard::processMovement( int _frames )
|
|||
if ( maxY - Pos.vy == 0 )
|
||||
{
|
||||
m_state = SPIKES_RISING;
|
||||
|
||||
m_timer = ( m_respawnRate * GameState::getOneSecondInFrames() ) >> 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
Pos.vy += 3 * _frames;
|
||||
Pos.vy += 8 * _frames;
|
||||
|
||||
if ( Pos.vy > maxY )
|
||||
{
|
||||
|
@ -58,10 +74,12 @@ void CNpcSpikesHazard::processMovement( int _frames )
|
|||
if ( minY - Pos.vy == 0 )
|
||||
{
|
||||
m_state = SPIKES_DROPPING;
|
||||
|
||||
m_timer = ( m_respawnRate * GameState::getOneSecondInFrames() ) >> 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
Pos.vy -= 3 * _frames;
|
||||
Pos.vy -= 8 * _frames;
|
||||
|
||||
if ( Pos.vy < minY )
|
||||
{
|
||||
|
@ -73,3 +91,29 @@ void CNpcSpikesHazard::processMovement( int _frames )
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const CRECT *CNpcSpikesHazard::getThinkBBox()
|
||||
{
|
||||
CRECT objThinkBox = getCollisionArea();
|
||||
|
||||
sBBox &thinkBBox = CThingManager::getThinkBBox();
|
||||
objThinkBox.x1 = thinkBBox.XMin;
|
||||
objThinkBox.x2 = thinkBBox.XMax;
|
||||
objThinkBox.y1 = thinkBBox.YMin;
|
||||
objThinkBox.y2 = thinkBBox.YMax;
|
||||
|
||||
return &objThinkBox;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcSpikesHazard::processTimer( int _frames )
|
||||
{
|
||||
if ( m_timer > 0 )
|
||||
{
|
||||
m_timer -= _frames;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,9 @@ class CNpcSpikesHazard : public CNpcHazard
|
|||
{
|
||||
public:
|
||||
void init();
|
||||
virtual CRECT const *getThinkBBox();
|
||||
protected:
|
||||
virtual void processTimer( int _frames );
|
||||
void processMovement( int _frames );
|
||||
|
||||
enum SPIKES_STATE
|
||||
|
|
Loading…
Add table
Reference in a new issue