2001-07-17 21:34:40 +02:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
hcheck.h
|
|
|
|
|
|
|
|
Author: CRB
|
|
|
|
Created:
|
|
|
|
Project: Spongebob
|
|
|
|
Purpose:
|
|
|
|
|
|
|
|
Copyright (c) 2001 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
#ifndef __HAZARD_HCHECK_H__
|
|
|
|
#include "hazard\hcheck.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PLAYER_PLAYER_H__
|
|
|
|
#include "player\player.h"
|
|
|
|
#endif
|
|
|
|
|
2001-07-17 22:15:28 +02:00
|
|
|
#ifndef __SPR_SPRITES_H__
|
|
|
|
#include <sprites.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __GAME_GAME_H__
|
|
|
|
#include "game\game.h"
|
|
|
|
#endif
|
|
|
|
|
2001-07-17 21:34:40 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcCheckpointHazard::init()
|
|
|
|
{
|
|
|
|
CNpcHazard::init();
|
|
|
|
|
|
|
|
m_triggered = false;
|
2001-07-17 22:15:28 +02:00
|
|
|
m_spriteFrame = FRM__CHECKPOINT;
|
2001-07-17 22:30:13 +02:00
|
|
|
m_timer = 0;
|
|
|
|
m_flick = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcCheckpointHazard::think(int _frames)
|
|
|
|
{
|
|
|
|
m_timer -= _frames;
|
|
|
|
|
|
|
|
if ( m_timer <= 0 )
|
|
|
|
{
|
|
|
|
m_flick = !m_flick;
|
|
|
|
|
|
|
|
m_timer = GameState::getOneSecondInFrames();
|
|
|
|
}
|
2001-07-17 21:34:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcCheckpointHazard::render()
|
|
|
|
{
|
2001-07-17 22:15:28 +02:00
|
|
|
sFrameHdr *frameHdr;
|
2001-07-17 22:30:13 +02:00
|
|
|
POLY_FT4 *Ft4;
|
2001-07-17 22:15:28 +02:00
|
|
|
|
|
|
|
if ( m_isActive )
|
|
|
|
{
|
|
|
|
CHazardThing::render();
|
|
|
|
|
|
|
|
if (canRender())
|
|
|
|
{
|
|
|
|
DVECTOR &renderPos=getRenderPos();
|
|
|
|
|
|
|
|
m_modelGfx->Render(renderPos);
|
|
|
|
|
|
|
|
if ( m_triggered )
|
|
|
|
{
|
|
|
|
int x,y;
|
|
|
|
|
2001-07-23 21:26:37 +02:00
|
|
|
DVECTOR const &offset = CLevel::getCameraPos();
|
2001-07-17 22:15:28 +02:00
|
|
|
|
|
|
|
int spriteWidth = CGameScene::getSpriteBank()->getFrameWidth(m_spriteFrame);
|
|
|
|
int spriteHeight = CGameScene::getSpriteBank()->getFrameHeight(m_spriteFrame);
|
|
|
|
|
|
|
|
x = Pos.vx - offset.vx - ( spriteWidth >> 1 );
|
|
|
|
y = Pos.vy - 100 - offset.vy - ( spriteHeight >> 1 );
|
|
|
|
|
|
|
|
frameHdr = CGameScene::getSpriteBank()->getFrameHeader( m_spriteFrame );
|
2001-07-17 22:30:13 +02:00
|
|
|
Ft4 = CGameScene::getSpriteBank()->printFT4( frameHdr, x, y, 0, 0, 10 );
|
|
|
|
setSemiTrans( Ft4, m_flick );
|
2001-07-17 22:15:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-07-17 21:34:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcCheckpointHazard::collidedWith(CThing *_thisThing)
|
|
|
|
{
|
|
|
|
if ( m_isActive && !m_triggered )
|
|
|
|
{
|
|
|
|
switch(_thisThing->getThingType())
|
|
|
|
{
|
|
|
|
case TYPE_PLAYER:
|
|
|
|
{
|
2001-07-23 21:26:37 +02:00
|
|
|
CRECT const &collisionArea=getCollisionArea();
|
2001-07-17 21:34:40 +02:00
|
|
|
DVECTOR respawnPos;
|
|
|
|
respawnPos.vx=collisionArea.x1+((collisionArea.x2-collisionArea.x1)/2);
|
|
|
|
respawnPos.vy=collisionArea.y2;
|
|
|
|
((CPlayer*)_thisThing)->setRespawnPosAndRingTelephone(respawnPos);
|
|
|
|
m_triggered = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|