This commit is contained in:
Charles 2001-04-12 14:55:55 +00:00
parent c08cf02803
commit 148b4416de
8 changed files with 62 additions and 21 deletions

View File

@ -133,6 +133,7 @@ void CNpcEnemy::processCloseAnemone1Attack( int _frames )
CProjectile *projectile;
projectile = new( "test projectile" ) CProjectile;
projectile->init( Pos, m_heading );
projectile->setLayerCollision( m_layerCollision );
m_controlFunc = NPC_CONTROL_MOVEMENT;
m_timerTimer = GameState::getOneSecondInFrames();
@ -200,6 +201,7 @@ void CNpcEnemy::processCloseAnemone2Attack( int _frames )
projectile = new( "anemone lev2 projectile" ) CProjectile;
projectile->init( spikePos, heading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE );
projectile->setLayerCollision( m_layerCollision );
addChild( projectile );
}
@ -230,6 +232,7 @@ void CNpcEnemy::processCloseAnemone3Attack( int _frames )
CProjectile::PROJECTILE_GAS_CLOUD,
CProjectile::PROJECTILE_FINITE_LIFE,
lifetime * GameState::getOneSecondInFrames() );
projectile->setLayerCollision( m_layerCollision );
m_controlFunc = NPC_CONTROL_MOVEMENT;
m_timerFunc = NPC_TIMER_ATTACK_DONE;

View File

@ -136,6 +136,7 @@ void CNpcEnemy::processStandardIronDogfishAttack( int _frames )
CProjectile *projectile;
projectile = new( "test projectile" ) CProjectile;
projectile->init( Pos, headingToPlayer );
projectile->setLayerCollision( m_layerCollision );
m_state++;

View File

@ -151,6 +151,7 @@ void CNpcEnemy::processCloseFlyingDutchmanAttack( int _frames )
CProjectile *projectile;
projectile = new( "test projectile" ) CProjectile;
projectile->init( Pos, heading );
projectile->setLayerCollision( m_layerCollision );
m_controlFunc = NPC_CONTROL_MOVEMENT;
m_movementTimer = GameState::getOneSecondInFrames() * 3;

View File

@ -68,6 +68,7 @@ void CNpcEnemy::processCloseGhostPirateAttack( int _frames )
projectile = new( "test projectile" ) CProjectile;
projectile->init( Pos, heading );
projectile->setLayerCollision( m_layerCollision );
}
}
else if ( m_extendDir == EXTEND_DOWN )

View File

@ -437,6 +437,7 @@ void CNpcEnemy::postInit()
CProjectile *projectile;
projectile = new ( "eyeball projectile" ) CProjectile;
projectile->init( Pos, m_fireHeading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE );
projectile->setLayerCollision( m_layerCollision );
addChild( projectile );
@ -461,6 +462,7 @@ void CNpcEnemy::postInit()
projectile = new( "anemone lev2 projectile" ) CProjectile;
projectile->init( spikePos, heading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE );
projectile->setLayerCollision( m_layerCollision );
addChild( projectile );
}

View File

@ -59,6 +59,7 @@ void CNpcEnemy::processSubSharkMovement( int _frames )
CProjectile *projectile;
projectile = new( "test projectile" ) CProjectile;
projectile->init( Pos, 1024 );
projectile->setLayerCollision( m_layerCollision );
m_salvoCount--;

View File

@ -230,30 +230,38 @@ void CProjectile::think(int _frames)
case PROJECTILE_USER_SEEK:
{
switch( m_state )
if ( m_layerCollision->Get( Pos.vx >> 4, Pos.vy >> 4 ) )
{
case PROJECTILE_RETURN:
shutdown();
delete this;
}
else
{
switch( m_state )
{
if ( processTargetSeek( _frames, Parent->getPos() ) )
case PROJECTILE_RETURN:
{
Parent->processEvent( PROJECTILE_RETURNED_TO_SOURCE_EVENT, this );
if ( processTargetSeek( _frames, Parent->getPos() ) )
{
Parent->processEvent( PROJECTILE_RETURNED_TO_SOURCE_EVENT, this );
}
break;
}
break;
}
case PROJECTILE_ATTACK:
default:
{
CPlayer *player = GameScene.getPlayer();
DVECTOR playerPos = player->getPos();
if ( processTargetSeek( _frames, playerPos ) )
case PROJECTILE_ATTACK:
default:
{
m_state = PROJECTILE_RETURN;
}
CPlayer *player = GameScene.getPlayer();
DVECTOR playerPos = player->getPos();
break;
if ( processTargetSeek( _frames, playerPos ) )
{
m_state = PROJECTILE_RETURN;
}
break;
}
}
}
@ -283,8 +291,16 @@ void CProjectile::think(int _frames)
case PROJECTILE_DUMBFIRE:
default:
{
Pos.vx += ( _frames * 3 * rcos( m_heading ) ) >> 12;
Pos.vy += ( _frames * 3 * rsin( m_heading ) ) >> 12;
if ( m_layerCollision->Get( Pos.vx >> 4, Pos.vy >> 4 ) )
{
shutdown();
delete this;
}
else
{
Pos.vx += ( _frames * 3 * rcos( m_heading ) ) >> 12;
Pos.vy += ( _frames * 3 * rsin( m_heading ) ) >> 12;
}
break;
}
@ -416,8 +432,16 @@ void CPlayerProjectile::think(int _frames)
case PLAYER_PROJECTILE_DUMBFIRE:
default:
{
Pos.vx += ( _frames * 3 * rcos( m_heading ) ) >> 12;
Pos.vy += ( _frames * 3 * rsin( m_heading ) ) >> 12;
if ( m_layerCollision->Get( Pos.vx >> 4, Pos.vy >> 4 ) )
{
shutdown();
delete this;
}
else
{
Pos.vx += ( _frames * 3 * rcos( m_heading ) ) >> 12;
Pos.vy += ( _frames * 3 * rsin( m_heading ) ) >> 12;
}
break;
}

View File

@ -56,6 +56,10 @@ public:
void setState( PROJECTILE_STATE newState );
void setLifeTime( PROJECTILE_LIFETIME_TYPE lifeType );
void setPosition( DVECTOR newPos );
void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;}
private:
class CLayerCollision *m_layerCollision;
protected:
DVECTOR getScreenOffset();
@ -100,6 +104,10 @@ public:
PLAYER_PROJECTILE_MOVEMENT_TYPE getMovementType();
void setLifeTime( PLAYER_PROJECTILE_LIFETIME_TYPE lifeType );
void setPosition( DVECTOR newPos );
void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;}
private:
class CLayerCollision *m_layerCollision;
protected:
DVECTOR getScreenOffset();