@ -285,7 +285,7 @@ void Crawler::HandleUserInput(float fElapsedTime){
}
}
}
}
if ( player - > GetState ( ) ! = State : : NORMAL ) {
if ( player - > GetState ( ) ! = State : : NORMAL & & player - > GetState ( ) ! = State : : PREP_CAST ) {
setIdleAnimation = false ;
setIdleAnimation = false ;
}
}
@ -313,8 +313,9 @@ void Crawler::HandleUserInput(float fElapsedTime){
void Crawler : : UpdateCamera ( float fElapsedTime ) {
void Crawler : : UpdateCamera ( float fElapsedTime ) {
lastWorldShakeAdjust = std : : max ( 0.f , lastWorldShakeAdjust - fElapsedTime ) ;
lastWorldShakeAdjust = std : : max ( 0.f , lastWorldShakeAdjust - fElapsedTime ) ;
if ( worldShakeTime - fElapsedTime > 0 ) {
if ( worldShakeTime - fElapsedTime > 0 ) {
worldShakeVel = { 1000 , - 1000 } ;
if ( lastWorldShakeAdjust = = 0 ) {
if ( lastWorldShakeAdjust = = 0 ) {
lastWorldShakeAdjust = 0.02 ;
lastWorldShakeAdjust = 0.04 ;
worldShakeVel . x * = - 1 ;
worldShakeVel . x * = - 1 ;
worldShakeVel . y * = - 1 ;
worldShakeVel . y * = - 1 ;
}
}
@ -375,8 +376,8 @@ void Crawler::UpdateBullets(float fElapsedTime){
if ( ! b - > deactivated ) {
if ( ! b - > deactivated ) {
if ( b - > friendly ) {
if ( b - > friendly ) {
for ( Monster & m : MONSTER_LIST ) {
for ( Monster & m : MONSTER_LIST ) {
if ( b - > OnUpperLevel ( ) = = m . OnUpperLevel ( ) & & geom2d : : overlaps ( geom2d : : circle ( m . GetPos ( ) , 12 * m . GetSizeMult ( ) ) , geom2d : : circle ( b - > pos , b - > radius ) ) ) {
if ( geom2d : : overlaps ( geom2d : : circle ( m . GetPos ( ) , 12 * m . GetSizeMult ( ) ) , geom2d : : circle ( b - > pos , b - > radius ) ) ) {
if ( b - > hitList . find ( & m ) = = b - > hitList . end ( ) & & m . Hurt ( b - > damage ) ) {
if ( b - > hitList . find ( & m ) = = b - > hitList . end ( ) & & m . Hurt ( b - > damage , b - > OnUpperLevel ( ) ) ) {
if ( ! b - > hitsMultiple ) {
if ( ! b - > hitsMultiple ) {
if ( b - > MonsterHit ( m ) ) {
if ( b - > MonsterHit ( m ) ) {
it = BULLET_LIST . erase ( it ) ;
it = BULLET_LIST . erase ( it ) ;
@ -391,8 +392,8 @@ void Crawler::UpdateBullets(float fElapsedTime){
}
}
}
}
} else {
} else {
if ( b - > OnUpperLevel ( ) = = player - > OnUpperLevel ( ) & & geom2d : : overlaps ( geom2d : : circle ( player - > GetPos ( ) , 12 * player - > GetSizeMult ( ) / 2 ) , geom2d : : circle ( b - > pos , b - > radius ) ) ) {
if ( geom2d : : overlaps ( geom2d : : circle ( player - > GetPos ( ) , 12 * player - > GetSizeMult ( ) / 2 ) , geom2d : : circle ( b - > pos , b - > radius ) ) ) {
if ( player - > Hurt ( b - > damage ) ) {
if ( player - > Hurt ( b - > damage , b - > OnUpperLevel ( ) ) ) {
if ( b - > PlayerHit ( GetPlayer ( ) ) ) {
if ( b - > PlayerHit ( GetPlayer ( ) ) ) {
it = BULLET_LIST . erase ( it ) ;
it = BULLET_LIST . erase ( it ) ;
if ( it = = BULLET_LIST . end ( ) ) {
if ( it = = BULLET_LIST . end ( ) ) {
@ -427,8 +428,8 @@ void Crawler::UpdateBullets(float fElapsedTime){
}
}
void Crawler : : HurtEnemies ( vf2d pos , float radius , int damage , bool upperLevel ) {
void Crawler : : HurtEnemies ( vf2d pos , float radius , int damage , bool upperLevel ) {
for ( Monster & m : MONSTER_LIST ) {
for ( Monster & m : MONSTER_LIST ) {
if ( m . OnUpperLevel ( ) = = upperLevel & & geom2d : : overlaps ( geom2d : : circle ( pos , radius ) , geom2d : : circle ( m . GetPos ( ) , 12 * m . GetSizeMult ( ) ) ) ) {
if ( geom2d : : overlaps ( geom2d : : circle ( pos , radius ) , geom2d : : circle ( m . GetPos ( ) , 12 * m . GetSizeMult ( ) ) ) ) {
m . Hurt ( damage ) ;
m . Hurt ( damage , upperLevel ) ;
}
}
}
}
}
}
@ -575,11 +576,25 @@ void Crawler::RenderWorld(float fElapsedTime){
for ( Bullet * b : bulletsLower ) {
for ( Bullet * b : bulletsLower ) {
b - > Draw ( ) ;
b - > Draw ( ) ;
}
}
if ( player - > GetState ( ) = = State : : PREP_CAST ) {
auto RenderPrecastTargetingIndicator = [ & ] ( ) {
float precastSize = GetPlayer ( ) - > castPrepAbility - > precastInfo . size ;
if ( player - > GetState ( ) = = State : : PREP_CAST ) {
vf2d scale = vf2d { precastSize , precastSize } / 3.f ;
float precastSize = GetPlayer ( ) - > castPrepAbility - > precastInfo . size ;
vf2d centerPoint = GetWorldMousePos ( ) - vf2d { game - > GFX_Circle . Sprite ( ) - > width * scale . x / 2 , game - > GFX_Circle . Sprite ( ) - > height * scale . y / 2 } ;
float precastRange = GetPlayer ( ) - > castPrepAbility - > precastInfo . range ;
view . DrawDecal ( centerPoint , GFX_Circle . Decal ( ) , scale , { 255 , 0 , 0 , 96 } ) ;
vf2d scale = vf2d { precastSize , precastSize } * 2 / 3.f ;
vf2d centerPoint = GetWorldMousePos ( ) - vf2d { game - > GFX_Circle . Sprite ( ) - > width * scale . x / 2 , game - > GFX_Circle . Sprite ( ) - > height * scale . y / 2 } ;
float distance = sqrt ( pow ( player - > GetX ( ) - GetWorldMousePos ( ) . x , 2 ) + pow ( player - > GetY ( ) - GetWorldMousePos ( ) . y , 2 ) ) ;
if ( distance > precastRange ) { //Clamp the distance.
vf2d pointToCursor = { GetWorldMousePos ( ) . x - player - > GetX ( ) , GetWorldMousePos ( ) . y - player - > GetY ( ) } ;
pointToCursor = pointToCursor . norm ( ) * precastRange ;
vf2d centerPoint = player - > GetPos ( ) + pointToCursor - vf2d { game - > GFX_Circle . Sprite ( ) - > width * scale . x / 2 , game - > GFX_Circle . Sprite ( ) - > height * scale . y / 2 } ;
view . DrawDecal ( centerPoint , GFX_Circle . Decal ( ) , scale , { 255 , 0 , 0 , 96 } ) ;
} else {
view . DrawDecal ( centerPoint , GFX_Circle . Decal ( ) , scale , { 255 , 0 , 0 , 96 } ) ;
}
}
} ;
if ( ! player - > OnUpperLevel ( ) ) {
RenderPrecastTargetingIndicator ( ) ;
}
}
# pragma region Foreground Rendering
# pragma region Foreground Rendering
for ( TileGroup & group : foregroundTileGroups ) {
for ( TileGroup & group : foregroundTileGroups ) {
@ -642,6 +657,9 @@ void Crawler::RenderWorld(float fElapsedTime){
for ( Bullet * b : bulletsUpper ) {
for ( Bullet * b : bulletsUpper ) {
b - > Draw ( ) ;
b - > Draw ( ) ;
}
}
if ( player - > OnUpperLevel ( ) ) {
RenderPrecastTargetingIndicator ( ) ;
}
# pragma region Upper Foreground Rendering
# pragma region Upper Foreground Rendering
for ( TileGroup & group : upperForegroundTileGroups ) {
for ( TileGroup & group : upperForegroundTileGroups ) {
if ( geom2d : : overlaps ( group . GetFadeRange ( ) , player - > pos ) ) {
if ( geom2d : : overlaps ( group . GetFadeRange ( ) , player - > pos ) ) {