This commit is contained in:
parent
330078a40f
commit
8279dc2a13
2 changed files with 79 additions and 33 deletions
|
@ -19,57 +19,101 @@
|
||||||
#include "level\layercollision.h"
|
#include "level\layercollision.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __GAME_GAME_H__
|
||||||
|
#include "game\game.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void CNpcSpikesHazard::init()
|
void CNpcSpikesHazard::init()
|
||||||
{
|
{
|
||||||
CNpcHazard::init();
|
CNpcHazard::init();
|
||||||
|
|
||||||
m_state = SPIKES_RISING;
|
m_state = SPIKES_RISING;
|
||||||
|
|
||||||
|
m_respawnRate = 8;
|
||||||
|
m_timerActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void CNpcSpikesHazard::processMovement( int _frames )
|
void CNpcSpikesHazard::processMovement( int _frames )
|
||||||
{
|
{
|
||||||
s32 minY, maxY;
|
if ( m_timer <= 0 )
|
||||||
m_npcPath.getPathYExtents( &minY, &maxY );
|
|
||||||
|
|
||||||
switch ( m_state )
|
|
||||||
{
|
{
|
||||||
case SPIKES_DROPPING:
|
s32 minY, maxY;
|
||||||
|
m_npcPath.getPathYExtents( &minY, &maxY );
|
||||||
|
|
||||||
|
switch ( m_state )
|
||||||
{
|
{
|
||||||
if ( maxY - Pos.vy == 0 )
|
case SPIKES_DROPPING:
|
||||||
{
|
{
|
||||||
m_state = SPIKES_RISING;
|
if ( maxY - Pos.vy == 0 )
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Pos.vy += 3 * _frames;
|
|
||||||
|
|
||||||
if ( Pos.vy > maxY )
|
|
||||||
{
|
{
|
||||||
Pos.vy = maxY;
|
m_state = SPIKES_RISING;
|
||||||
|
|
||||||
|
m_timer = ( m_respawnRate * GameState::getOneSecondInFrames() ) >> 3;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case SPIKES_RISING:
|
|
||||||
{
|
|
||||||
if ( minY - Pos.vy == 0 )
|
|
||||||
{
|
|
||||||
m_state = SPIKES_DROPPING;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Pos.vy -= 3 * _frames;
|
|
||||||
|
|
||||||
if ( Pos.vy < minY )
|
|
||||||
{
|
{
|
||||||
Pos.vy = minY;
|
Pos.vy += 8 * _frames;
|
||||||
|
|
||||||
|
if ( Pos.vy > maxY )
|
||||||
|
{
|
||||||
|
Pos.vy = maxY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
case SPIKES_RISING:
|
||||||
|
{
|
||||||
|
if ( minY - Pos.vy == 0 )
|
||||||
|
{
|
||||||
|
m_state = SPIKES_DROPPING;
|
||||||
|
|
||||||
|
m_timer = ( m_respawnRate * GameState::getOneSecondInFrames() ) >> 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Pos.vy -= 8 * _frames;
|
||||||
|
|
||||||
|
if ( Pos.vy < minY )
|
||||||
|
{
|
||||||
|
Pos.vy = minY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
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:
|
public:
|
||||||
void init();
|
void init();
|
||||||
|
virtual CRECT const *getThinkBBox();
|
||||||
protected:
|
protected:
|
||||||
|
virtual void processTimer( int _frames );
|
||||||
void processMovement( int _frames );
|
void processMovement( int _frames );
|
||||||
|
|
||||||
enum SPIKES_STATE
|
enum SPIKES_STATE
|
||||||
|
|
Loading…
Add table
Reference in a new issue