SBSPSS/source/triggers/tteleprt.cpp

155 lines
3.3 KiB
C++
Raw Normal View History

2001-05-01 23:33:51 +02:00
/*=========================================================================
tteleprt.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
2001-05-29 22:31:02 +02:00
#include "triggers\trigger.h"
2001-05-01 23:33:51 +02:00
#include "triggers\tteleprt.h"
2001-08-02 14:45:12 +02:00
#ifndef __GAME_GAME_H__
2001-08-17 21:23:09 +02:00
#include "game\game.h"
2001-08-02 14:45:12 +02:00
#endif
2001-05-01 23:33:51 +02:00
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
2001-08-02 14:45:12 +02:00
#ifndef __FRIEND_FRIEND_H__
#include "friend\friend.h"
#endif
#ifndef __FRIEND_FGARY_H__
#include "friend\fgary.h"
#endif
2001-08-17 21:23:09 +02:00
#ifndef __SOUND_SOUND_H__
#include "sound\sound.h"
#endif
2001-05-01 23:33:51 +02:00
/* Std Lib
------- */
/* Data
---- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CTeleportTrigger::collidedWith(CThing *_thisThing)
{
2001-08-02 14:45:12 +02:00
int chapter=GameScene.getChapterNumber();
int level=GameScene.getLevelNumber();
2001-06-04 14:54:44 +02:00
switch( _thisThing->getThingType() )
{
case TYPE_PLAYER:
{
2001-08-17 20:54:26 +02:00
// SB *might* be chopping to hit this trigger, so we only do the collision
// if he would normally hit it.
int x,y,w,h;
DVECTOR pos;
CRECT thisRect;
CRECT const &thatRect=getCollisionArea();
int collided=true;
((CPlayer*)_thisThing)->getPlayerNormalCollisionSize(&x,&y,&w,&h);
pos=_thisThing->getPos();
thisRect.x1=pos.vx+x-(w/2);
thisRect.y1=pos.vy+y-(h/2);
thisRect.x2=thisRect.x1+w;
thisRect.y2=thisRect.y1+h;
if (thisRect.x2<thatRect.x1 || thisRect.x1>thatRect.x2) collided=false;
if (thisRect.y2<thatRect.y1 || thisRect.y1>thatRect.y2) collided=false;
if(collided)
2001-08-02 14:45:12 +02:00
{
2001-08-17 20:54:26 +02:00
// Ok.. so we've actually hit the thing properly :)
if ( chapter == 5 && level == 5 )
2001-08-02 14:45:12 +02:00
{
2001-08-17 20:54:26 +02:00
if ( !CNpcGaryFriend::hasReachedDoor() )
{
// if we're on chapter 1, level 5, check Gary has reached the teleport point
// if he hasn't, don't let Spongey through
2001-08-02 14:45:12 +02:00
2001-08-17 20:54:26 +02:00
return;
}
2001-08-02 14:45:12 +02:00
}
2001-08-17 20:54:26 +02:00
if(GameScene.triggerTeleportEffect())
{
2001-08-17 21:23:09 +02:00
CSoundMediator::SFXID sfx;
2001-08-17 20:54:26 +02:00
((CPlayer*)_thisThing)->clearPlatform();
((CPlayer*)_thisThing)->teleportTo(m_boxX1+8,m_boxY1+16);
2001-08-17 21:23:09 +02:00
if(chapter==5&&level==4)
{
sfx=CSoundMediator::SFX_TELEPORT1;
}
else
{
sfx=CSoundMediator::SFX_TELEPORT2;
}
CSoundMediator::playSfx(sfx);
2001-08-17 20:54:26 +02:00
}
2001-08-04 21:16:11 +02:00
}
2001-06-04 14:54:44 +02:00
break;
}
2001-08-02 14:45:12 +02:00
case TYPE_NPC:
{
if ( _thisThing->getThingSubType() == CNpcFriend::NPC_FRIEND_GARY )
{
2001-08-02 15:19:11 +02:00
if ( chapter == 5 && level == 5 )
2001-08-02 14:45:12 +02:00
{
// if Gary has touched a teleport on chapter 1, level 5, remember that he has done so
CNpcGaryFriend::setReachedDoor();
}
}
break;
}
2001-06-04 14:54:44 +02:00
default:
break;
}
2001-05-01 23:33:51 +02:00
}
/*===========================================================================
end */