@ -123,7 +123,12 @@ bool Crawler::OnUserCreate(){
bool Crawler : : OnUserUpdate ( float fElapsedTime ) {
fElapsedTime = std : : clamp ( fElapsedTime , 0.f , 1 / 30.f ) ; //HACK fix. We can't have a negative time. Although using a more precise system clock should make this never occur. Also make sure if the game is too slow we advance by only 1/30th of a second.
levelTime + = fElapsedTime ;
bossDisplayTimer = std : : max ( 0.f , bossDisplayTimer - fElapsedTime ) ;
if ( totalBossEncounterMobs > 0 ) {
bossDisplayTimer = std : : max ( 0.f , bossDisplayTimer - fElapsedTime ) ;
}
if ( encounterStarted ) {
encounterDuration + = fElapsedTime ;
}
HandleUserInput ( fElapsedTime ) ;
UpdateEffects ( fElapsedTime ) ;
player - > Update ( fElapsedTime ) ;
@ -1025,21 +1030,7 @@ void Crawler::RenderHud(){
std : : string displayText = player - > notificationDisplay . first ;
DrawShadowStringPropDecal ( vf2d { float ( ScreenWidth ( ) / 2 ) , float ( ScreenHeight ( ) / 4 ) - 24 } - GetTextSizeProp ( displayText ) / 2 , displayText , BLUE , VERY_DARK_BLUE ) ;
}
if ( bossDisplayTimer > 0 ) {
std : : string displayText = " - " + bossName + " - " ;
uint8_t alpha = 0 ;
if ( bossDisplayTimer > 4 ) {
alpha = uint8_t ( ( 5 - bossDisplayTimer ) * 255 ) ;
} else
if ( bossDisplayTimer > 1 ) {
alpha = 255 ;
} else {
alpha = uint8_t ( ( bossDisplayTimer ) * 255 ) ;
}
vf2d textScale = { 3 , 5 } ;
DrawShadowStringPropDecal ( vf2d { float ( ScreenWidth ( ) / 2 ) , float ( ScreenHeight ( ) / 2 ) } - vf2d { GetTextSizeProp ( displayText ) } * textScale / 2 , displayText , { 252 , 186 , 3 , alpha } , { 128 , 0 , 0 , alpha } , textScale , 2 ) ;
}
DisplayBossEncounterInfo ( ) ;
std : : string versionStr ( " v " + std : : to_string ( VERSION_MAJOR ) + " . " + std : : to_string ( VERSION_MINOR ) + " . " + std : : to_string ( VERSION_PATCH ) + " . " + std : : to_string ( VERSION_BUILD ) ) ;
DrawShadowStringDecal ( vf2d { GetScreenSize ( ) } - vf2d { GetTextSize ( versionStr ) } * 0.4 , versionStr , WHITE , BLACK , { 0.4 , 0.4 } , 0.4 ) ;
if ( " debug_player_info " _I ) {
@ -1163,6 +1154,11 @@ void Crawler::LoadLevel(MapName map){
currentLevel = map ;
WORLD_SIZE = { MAP_DATA [ map ] . MapData . width , MAP_DATA [ map ] . MapData . height } ;
levelTime = 0 ;
bossName = " " ;
encounterDuration = 0 ;
totalDamageDealt = 0 ;
encounterStarted = false ;
totalBossEncounterMobs = 0 ;
# pragma region Monster Spawn Data Setup
for ( auto key : MAP_DATA [ map ] . SpawnerData ) {
@ -1581,8 +1577,11 @@ void Crawler::InitializeLevels(){
LEVEL_NAMES . SetInitialized ( ) ;
}
void Crawler : : SpawnMonster ( vf2d pos , MonsterData * data , bool upperLevel ) {
monstersToBeSpawned . push_back ( Monster ( pos , * data , upperLevel ) ) ;
void Crawler : : SpawnMonster ( vf2d pos , MonsterData * data , bool upperLevel , bool isBossSpawn ) {
monstersToBeSpawned . push_back ( Monster ( pos , * data , upperLevel , isBossSpawn ) ) ;
if ( isBossSpawn ) {
totalBossEncounterMobs + + ;
}
}
void Crawler : : DrawPie ( vf2d center , float radius , float degreesCut , Pixel col ) {
@ -1609,4 +1608,59 @@ void Crawler::InitializeDefaultKeybinds(){
void Crawler : : SetBossNameDisplay ( std : : string name , float time ) {
bossName = name ;
bossDisplayTimer = time ;
}
bool Crawler : : InBossEncounter ( ) {
return bossName ! = " " ;
}
void Crawler : : StartBossEncounter ( ) {
if ( ! encounterStarted ) {
encounterStarted = true ;
totalDamageDealt = encounterDuration = 0 ;
}
}
void Crawler : : DisplayBossEncounterInfo ( ) {
if ( bossDisplayTimer > 0 ) {
std : : string displayText = " - " + bossName + " - " ;
uint8_t alpha = 0 ;
if ( bossDisplayTimer > 4 ) {
alpha = uint8_t ( ( 5 - bossDisplayTimer ) * 255 ) ;
} else
if ( bossDisplayTimer > 1 ) {
alpha = 255 ;
} else {
alpha = uint8_t ( ( bossDisplayTimer ) * 255 ) ;
}
vf2d textScale = { 3 , 5 } ;
DrawShadowStringPropDecal ( vf2d { float ( ScreenWidth ( ) / 2 ) , float ( ScreenHeight ( ) / 2 ) } - vf2d { GetTextSizeProp ( displayText ) } * textScale / 2 , displayText , { 252 , 186 , 3 , alpha } , { 128 , 0 , 0 , alpha } , textScale , 2 ) ;
}
if ( InBossEncounter ( ) ) {
Pixel displayCol = totalBossEncounterMobs = = 0 ? Pixel { 224 , 133 , 29 } : WHITE ;
std : : string timeDisplay = util : : timerStr ( encounterDuration ) ;
vf2d timerTextSize = GetTextSizeProp ( timeDisplay ) ;
DrawShadowStringPropDecal ( vf2d { ScreenWidth ( ) - 2 - timerTextSize . x , 2 + 10 * 0 } , timeDisplay , displayCol ) ;
vf2d displayTextSize = GetTextSizeProp ( bossName ) ;
DrawShadowStringPropDecal ( vf2d { ScreenWidth ( ) - 2 - displayTextSize . x , 2 + 10 * 1 } , bossName , displayCol ) ;
if ( encounterDuration > = 1 ) {
std : : string dpsText = " DPS: " + std : : to_string ( int ( totalDamageDealt / encounterDuration ) ) ;
vf2d dpsDisplayTextSize = GetTextSizeProp ( dpsText ) ;
DrawShadowStringPropDecal ( vf2d { ScreenWidth ( ) - 2 - dpsDisplayTextSize . x , 2 + 10 * 2 } , dpsText , displayCol ) ;
}
}
}
void Crawler : : BossDamageDealt ( int damage ) {
totalDamageDealt + = damage ;
}
void Crawler : : ReduceBossEncounterMobCount ( ) {
totalBossEncounterMobs - - ;
if ( totalBossEncounterMobs < 0 ) {
std : : cout < < " WARNING! Boss Encounter mob count is less than zero, THIS SHOULD NOT BE HAPPENING! " < < std : : endl ;
throw ;
}
}