This commit is contained in:
parent
c08cf02803
commit
148b4416de
8 changed files with 62 additions and 21 deletions
|
@ -133,6 +133,7 @@ void CNpcEnemy::processCloseAnemone1Attack( int _frames )
|
||||||
CProjectile *projectile;
|
CProjectile *projectile;
|
||||||
projectile = new( "test projectile" ) CProjectile;
|
projectile = new( "test projectile" ) CProjectile;
|
||||||
projectile->init( Pos, m_heading );
|
projectile->init( Pos, m_heading );
|
||||||
|
projectile->setLayerCollision( m_layerCollision );
|
||||||
|
|
||||||
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
||||||
m_timerTimer = GameState::getOneSecondInFrames();
|
m_timerTimer = GameState::getOneSecondInFrames();
|
||||||
|
@ -200,6 +201,7 @@ void CNpcEnemy::processCloseAnemone2Attack( int _frames )
|
||||||
|
|
||||||
projectile = new( "anemone lev2 projectile" ) CProjectile;
|
projectile = new( "anemone lev2 projectile" ) CProjectile;
|
||||||
projectile->init( spikePos, heading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE );
|
projectile->init( spikePos, heading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE );
|
||||||
|
projectile->setLayerCollision( m_layerCollision );
|
||||||
|
|
||||||
addChild( projectile );
|
addChild( projectile );
|
||||||
}
|
}
|
||||||
|
@ -230,6 +232,7 @@ void CNpcEnemy::processCloseAnemone3Attack( int _frames )
|
||||||
CProjectile::PROJECTILE_GAS_CLOUD,
|
CProjectile::PROJECTILE_GAS_CLOUD,
|
||||||
CProjectile::PROJECTILE_FINITE_LIFE,
|
CProjectile::PROJECTILE_FINITE_LIFE,
|
||||||
lifetime * GameState::getOneSecondInFrames() );
|
lifetime * GameState::getOneSecondInFrames() );
|
||||||
|
projectile->setLayerCollision( m_layerCollision );
|
||||||
|
|
||||||
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
||||||
m_timerFunc = NPC_TIMER_ATTACK_DONE;
|
m_timerFunc = NPC_TIMER_ATTACK_DONE;
|
||||||
|
|
|
@ -136,6 +136,7 @@ void CNpcEnemy::processStandardIronDogfishAttack( int _frames )
|
||||||
CProjectile *projectile;
|
CProjectile *projectile;
|
||||||
projectile = new( "test projectile" ) CProjectile;
|
projectile = new( "test projectile" ) CProjectile;
|
||||||
projectile->init( Pos, headingToPlayer );
|
projectile->init( Pos, headingToPlayer );
|
||||||
|
projectile->setLayerCollision( m_layerCollision );
|
||||||
|
|
||||||
m_state++;
|
m_state++;
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,7 @@ void CNpcEnemy::processCloseFlyingDutchmanAttack( int _frames )
|
||||||
CProjectile *projectile;
|
CProjectile *projectile;
|
||||||
projectile = new( "test projectile" ) CProjectile;
|
projectile = new( "test projectile" ) CProjectile;
|
||||||
projectile->init( Pos, heading );
|
projectile->init( Pos, heading );
|
||||||
|
projectile->setLayerCollision( m_layerCollision );
|
||||||
|
|
||||||
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
||||||
m_movementTimer = GameState::getOneSecondInFrames() * 3;
|
m_movementTimer = GameState::getOneSecondInFrames() * 3;
|
||||||
|
|
|
@ -68,6 +68,7 @@ void CNpcEnemy::processCloseGhostPirateAttack( int _frames )
|
||||||
|
|
||||||
projectile = new( "test projectile" ) CProjectile;
|
projectile = new( "test projectile" ) CProjectile;
|
||||||
projectile->init( Pos, heading );
|
projectile->init( Pos, heading );
|
||||||
|
projectile->setLayerCollision( m_layerCollision );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( m_extendDir == EXTEND_DOWN )
|
else if ( m_extendDir == EXTEND_DOWN )
|
||||||
|
|
|
@ -437,6 +437,7 @@ void CNpcEnemy::postInit()
|
||||||
CProjectile *projectile;
|
CProjectile *projectile;
|
||||||
projectile = new ( "eyeball projectile" ) CProjectile;
|
projectile = new ( "eyeball projectile" ) CProjectile;
|
||||||
projectile->init( Pos, m_fireHeading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE );
|
projectile->init( Pos, m_fireHeading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE );
|
||||||
|
projectile->setLayerCollision( m_layerCollision );
|
||||||
|
|
||||||
addChild( projectile );
|
addChild( projectile );
|
||||||
|
|
||||||
|
@ -461,6 +462,7 @@ void CNpcEnemy::postInit()
|
||||||
|
|
||||||
projectile = new( "anemone lev2 projectile" ) CProjectile;
|
projectile = new( "anemone lev2 projectile" ) CProjectile;
|
||||||
projectile->init( spikePos, heading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE );
|
projectile->init( spikePos, heading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE );
|
||||||
|
projectile->setLayerCollision( m_layerCollision );
|
||||||
|
|
||||||
addChild( projectile );
|
addChild( projectile );
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ void CNpcEnemy::processSubSharkMovement( int _frames )
|
||||||
CProjectile *projectile;
|
CProjectile *projectile;
|
||||||
projectile = new( "test projectile" ) CProjectile;
|
projectile = new( "test projectile" ) CProjectile;
|
||||||
projectile->init( Pos, 1024 );
|
projectile->init( Pos, 1024 );
|
||||||
|
projectile->setLayerCollision( m_layerCollision );
|
||||||
|
|
||||||
m_salvoCount--;
|
m_salvoCount--;
|
||||||
|
|
||||||
|
|
|
@ -230,30 +230,38 @@ void CProjectile::think(int _frames)
|
||||||
|
|
||||||
case PROJECTILE_USER_SEEK:
|
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:
|
||||||
|
|
||||||
case PROJECTILE_ATTACK:
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
CPlayer *player = GameScene.getPlayer();
|
|
||||||
DVECTOR playerPos = player->getPos();
|
|
||||||
|
|
||||||
if ( processTargetSeek( _frames, playerPos ) )
|
|
||||||
{
|
{
|
||||||
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:
|
case PROJECTILE_DUMBFIRE:
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
Pos.vx += ( _frames * 3 * rcos( m_heading ) ) >> 12;
|
if ( m_layerCollision->Get( Pos.vx >> 4, Pos.vy >> 4 ) )
|
||||||
Pos.vy += ( _frames * 3 * rsin( m_heading ) ) >> 12;
|
{
|
||||||
|
shutdown();
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Pos.vx += ( _frames * 3 * rcos( m_heading ) ) >> 12;
|
||||||
|
Pos.vy += ( _frames * 3 * rsin( m_heading ) ) >> 12;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -416,8 +432,16 @@ void CPlayerProjectile::think(int _frames)
|
||||||
case PLAYER_PROJECTILE_DUMBFIRE:
|
case PLAYER_PROJECTILE_DUMBFIRE:
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
Pos.vx += ( _frames * 3 * rcos( m_heading ) ) >> 12;
|
if ( m_layerCollision->Get( Pos.vx >> 4, Pos.vy >> 4 ) )
|
||||||
Pos.vy += ( _frames * 3 * rsin( m_heading ) ) >> 12;
|
{
|
||||||
|
shutdown();
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Pos.vx += ( _frames * 3 * rcos( m_heading ) ) >> 12;
|
||||||
|
Pos.vy += ( _frames * 3 * rsin( m_heading ) ) >> 12;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,10 @@ public:
|
||||||
void setState( PROJECTILE_STATE newState );
|
void setState( PROJECTILE_STATE newState );
|
||||||
void setLifeTime( PROJECTILE_LIFETIME_TYPE lifeType );
|
void setLifeTime( PROJECTILE_LIFETIME_TYPE lifeType );
|
||||||
void setPosition( DVECTOR newPos );
|
void setPosition( DVECTOR newPos );
|
||||||
|
void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
class CLayerCollision *m_layerCollision;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DVECTOR getScreenOffset();
|
DVECTOR getScreenOffset();
|
||||||
|
@ -100,6 +104,10 @@ public:
|
||||||
PLAYER_PROJECTILE_MOVEMENT_TYPE getMovementType();
|
PLAYER_PROJECTILE_MOVEMENT_TYPE getMovementType();
|
||||||
void setLifeTime( PLAYER_PROJECTILE_LIFETIME_TYPE lifeType );
|
void setLifeTime( PLAYER_PROJECTILE_LIFETIME_TYPE lifeType );
|
||||||
void setPosition( DVECTOR newPos );
|
void setPosition( DVECTOR newPos );
|
||||||
|
void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
class CLayerCollision *m_layerCollision;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DVECTOR getScreenOffset();
|
DVECTOR getScreenOffset();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue