SBSPSS/source/platform/pfgen.cpp

100 lines
2.2 KiB
C++
Raw Normal View History

2001-05-03 21:01:23 +02:00
/*=========================================================================
2001-05-29 17:29:56 +02:00
pfgen.cpp
2001-05-03 21:01:23 +02:00
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PFGEN_H__
#include "platform\pfgen.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
#ifndef __PLATFORM_PFALLNOR_H__
#include "platform\pfallnor.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFallingPlatformGenerator::collidedWith(CThing *_thisThing)
{
// do nothing
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFallingPlatformGenerator::render()
{
// no rendering
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFallingPlatformGenerator::think( int _frames )
{
2001-05-03 21:44:00 +02:00
m_timer -= _frames;
2001-05-03 21:01:23 +02:00
if ( m_timer < 0 )
{
2001-05-25 00:11:48 +02:00
s32 second = GameState::getOneSecondInFrames();
m_timer = second;
2001-05-29 20:40:38 +02:00
m_timer += m_dataPtr->initTimer * second;
2001-05-25 00:11:48 +02:00
m_timer += second - ( getRnd() % ( 2 * second ) );
//m_timer = ( 3 * GameState::getOneSecondInFrames() ) + ( getRnd() % ( ( m_data[m_type].initTimer - 1 ) * GameState::getOneSecondInFrames() ) );
2001-05-03 21:01:23 +02:00
// generate new falling platform
2001-05-03 21:44:00 +02:00
CNpcPlatform *newPlatform;
2001-05-03 21:01:23 +02:00
newPlatform = NULL;
switch( m_targetType )
{
case NPC_OILDRUM_PLATFORM:
case NPC_CRATE_PLATFORM:
2001-05-04 18:47:09 +02:00
case NPC_VERTICAL_OILDRUM_PLATFORM:
2001-05-03 21:01:23 +02:00
{
2001-05-25 22:00:13 +02:00
//newPlatform = new ("falling platform") CNpcFallingNoRespawnPlatform;
newPlatform = CNpcPlatform::Create( m_targetType );
2001-05-03 21:01:23 +02:00
break;
}
default:
{
ASSERT( 0 );
break;
}
}
ASSERT(newPlatform);
2001-05-29 20:40:38 +02:00
newPlatform->setThingSubType( m_targetType );
2001-05-03 21:01:23 +02:00
newPlatform->setGraphic( m_graphicNum );
2001-05-30 00:07:28 +02:00
DVECTOR startPos = Pos;
newPlatform->init( startPos );
newPlatform->setWaypointCount( m_npcPath.getWaypointCount() );
newPlatform->setWaypointPtr( m_npcPath.getWaypointPtr() );
2001-05-03 21:44:00 +02:00
newPlatform->setTiltable( false );
newPlatform->postInit();
}
2001-05-03 21:01:23 +02:00
}