2001-06-05 23:21:23 +02:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
psswitch.cpp
|
|
|
|
|
|
|
|
Author: CRB
|
|
|
|
Created:
|
|
|
|
Project: Spongebob
|
|
|
|
Purpose:
|
|
|
|
|
|
|
|
Copyright (c) 2001 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
#ifndef __PLATFORM_PSSWITCH_H__
|
|
|
|
#include "platform\psswitch.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __GAME_GAME_H__
|
|
|
|
#include "game\game.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __UTILS_HEADER__
|
|
|
|
#include "utils\utils.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcSteamSwitchPlatform::postInit()
|
|
|
|
{
|
|
|
|
CNpcPlatform::postInit();
|
|
|
|
|
|
|
|
m_state = NPC_STEAM_SWITCH_STOP;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcSteamSwitchPlatform::processMovement( int _frames )
|
|
|
|
{
|
|
|
|
switch( m_state )
|
|
|
|
{
|
|
|
|
case NPC_STEAM_SWITCH_STOP:
|
|
|
|
{
|
|
|
|
if ( m_contact )
|
|
|
|
{
|
2001-07-06 23:18:06 +02:00
|
|
|
//CPlayer *player = GameScene.getPlayer();
|
|
|
|
//ATTACK_STATE playerState = player->getAttackState();
|
2001-06-05 23:21:23 +02:00
|
|
|
|
2001-07-06 23:18:06 +02:00
|
|
|
//if ( playerState == ATTACK_STATE__BUTT_BOUNCE )
|
2001-06-05 23:21:23 +02:00
|
|
|
{
|
|
|
|
m_state = NPC_STEAM_SWITCH_DEPRESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPC_STEAM_SWITCH_DEPRESS:
|
|
|
|
{
|
|
|
|
s32 extension = m_maxExtension - m_extension;
|
|
|
|
s32 maxMove = m_speed * _frames;
|
|
|
|
|
|
|
|
if ( extension > maxMove )
|
|
|
|
{
|
|
|
|
extension = maxMove;
|
|
|
|
}
|
|
|
|
else if ( extension < -maxMove )
|
|
|
|
{
|
|
|
|
extension = -maxMove;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( extension )
|
|
|
|
{
|
|
|
|
m_extension += extension;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-06-06 15:27:46 +02:00
|
|
|
trigger->toggleVisible();
|
|
|
|
|
|
|
|
m_state = NPC_STEAM_SWITCH_OFF;
|
|
|
|
m_timer = GameState::getOneSecondInFrames();
|
2001-06-05 23:21:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-06-06 15:27:46 +02:00
|
|
|
case NPC_STEAM_SWITCH_OFF:
|
2001-06-05 23:21:23 +02:00
|
|
|
{
|
2001-06-06 15:27:46 +02:00
|
|
|
if ( m_timer <= 0 )
|
2001-06-05 23:21:23 +02:00
|
|
|
{
|
2001-06-06 15:27:46 +02:00
|
|
|
trigger->toggleVisible();
|
2001-06-05 23:21:23 +02:00
|
|
|
|
2001-06-06 15:27:46 +02:00
|
|
|
m_state = NPC_STEAM_SWITCH_RETURN;
|
|
|
|
m_timer = 5 * GameState::getOneSecondInFrames();
|
2001-06-05 23:21:23 +02:00
|
|
|
}
|
2001-06-06 15:27:46 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPC_STEAM_SWITCH_RETURN:
|
|
|
|
{
|
|
|
|
if ( m_timer <= 0 )
|
2001-06-05 23:21:23 +02:00
|
|
|
{
|
2001-06-06 15:27:46 +02:00
|
|
|
s32 extension = -m_extension;
|
|
|
|
s32 maxMove = m_speed * _frames;
|
|
|
|
|
|
|
|
if ( extension > maxMove )
|
|
|
|
{
|
|
|
|
extension = maxMove;
|
|
|
|
}
|
|
|
|
else if ( extension < -maxMove )
|
|
|
|
{
|
|
|
|
extension = -maxMove;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( extension )
|
|
|
|
{
|
|
|
|
m_extension += extension;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_state = NPC_STEAM_SWITCH_STOP;
|
|
|
|
}
|
2001-06-05 23:21:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Pos.vy = m_base.vy + m_extension;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcSteamSwitchPlatform::setWaypoints( sThingPlatform *ThisPlatform )
|
|
|
|
{
|
2001-06-06 15:27:46 +02:00
|
|
|
ASSERT( ThisPlatform->PointCount == 3 );
|
|
|
|
|
2001-06-05 23:21:23 +02:00
|
|
|
int pointNum;
|
|
|
|
|
|
|
|
u16 *PntList=(u16*)MakePtr(ThisPlatform,sizeof(sThingPlatform));
|
|
|
|
|
|
|
|
u16 newXPos, newYPos;
|
|
|
|
|
|
|
|
newXPos = (u16) *PntList;
|
|
|
|
PntList++;
|
|
|
|
newYPos = (u16) *PntList;
|
|
|
|
PntList++;
|
|
|
|
|
|
|
|
DVECTOR startPos;
|
|
|
|
startPos.vx = ( newXPos << 4 ) + 8;
|
|
|
|
startPos.vy = ( newYPos << 4 ) + 16;
|
|
|
|
|
|
|
|
init( startPos );
|
|
|
|
|
2001-06-06 15:27:46 +02:00
|
|
|
newXPos = (u16) *PntList;
|
|
|
|
PntList++;
|
|
|
|
newYPos = (u16) *PntList;
|
|
|
|
PntList++;
|
2001-06-05 23:21:23 +02:00
|
|
|
|
2001-06-06 15:27:46 +02:00
|
|
|
m_maxExtension = ( ( newYPos << 4 ) + 16 ) - startPos.vy;
|
|
|
|
|
|
|
|
newXPos = (u16) *PntList;
|
|
|
|
PntList++;
|
|
|
|
newYPos = (u16) *PntList;
|
|
|
|
PntList++;
|
|
|
|
|
|
|
|
trigger=(CSteamSwitchEmitterTrigger*)CTrigger::Create(CTrigger::TRIGGER_STEAM_SWITCH_EMITTER);
|
|
|
|
trigger->setPositionAndSize( ( newXPos << 4 ) + 8, ( newYPos << 4 ) + 16 - 50, 100, 100 );
|
|
|
|
trigger->toggleVisible();
|
2001-06-19 22:07:57 +02:00
|
|
|
|
|
|
|
s32 minX, maxX, minY, maxY;
|
|
|
|
|
|
|
|
m_npcPath.getPathXExtents( &minX, &maxX );
|
|
|
|
m_npcPath.getPathYExtents( &minY, &maxY );
|
|
|
|
|
2001-06-19 23:51:07 +02:00
|
|
|
m_thinkArea.x1 = startPos.vx;
|
|
|
|
m_thinkArea.x2 = startPos.vx + 1;
|
|
|
|
m_thinkArea.y1 = startPos.vy;
|
|
|
|
m_thinkArea.y2 = startPos.vy + m_maxExtension;
|
2001-06-06 15:27:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcSteamSwitchPlatform::processTimer( int _frames )
|
|
|
|
{
|
|
|
|
if ( m_timer > 0 )
|
2001-06-05 23:21:23 +02:00
|
|
|
{
|
2001-06-06 15:27:46 +02:00
|
|
|
m_timer -= _frames;
|
2001-06-05 23:21:23 +02:00
|
|
|
}
|
|
|
|
}
|