diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 705d2964..4378df8d 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -821,15 +821,17 @@ void AiL::PopulateRenderLists(){ } void AiL::RenderTile(vi2d pos,TilesheetData tileSheet,int tileSheetIndex,vi2d tileSheetPos){ + Pixel tempCol=worldColorFunc(pos*game->GetCurrentMapData().tilewidth); + if(tileSheet.tileset->animationData.count(tileSheetIndex)){ int animationDuration_ms=int(tileSheet.tileset->animationData[tileSheetIndex].size()*"animation_tile_precision"_I); int animatedIndex=tileSheet.tileset->animationData[tileSheetIndex][size_t(fmod(levelTime*1000.f,animationDuration_ms)/"animation_tile_precision"_I)]; int tileSheetWidth=tileSheet.tileset->tileset->Sprite()->width/tileSheet.tileset->tilewidth; int tileSheetX=animatedIndex%tileSheetWidth; int tileSheetY=animatedIndex/tileSheetWidth; - view.DrawPartialDecal(pos*game->GetCurrentMapData().tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tileSheet.tileset->tileset->Decal(),vi2d{tileSheetX,tileSheetY}*tileSheet.tileset->tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)}); + view.DrawPartialDecal(pos*game->GetCurrentMapData().tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tileSheet.tileset->tileset->Decal(),vi2d{tileSheetX,tileSheetY}*tileSheet.tileset->tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tempCol); }else{ - view.DrawPartialDecal(pos*game->GetCurrentMapData().tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tileSheet.tileset->tileset->Decal(),tileSheetPos*tileSheet.tileset->tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)}); + view.DrawPartialDecal(pos*game->GetCurrentMapData().tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tileSheet.tileset->tileset->Decal(),tileSheetPos*tileSheet.tileset->tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tempCol); } } @@ -1742,6 +1744,8 @@ void AiL::LoadLevel(MapName map){ foregroundTileGroups.clear(); upperForegroundTileGroups.clear(); MONSTER_LIST.clear(); + worldColor=WHITE; + worldColorFunc=[&](vi2d pos){return game->worldColor;}; currentLevel=map; levelTime=0; bossName=""; @@ -2945,3 +2949,15 @@ std::string operator ""_FS(const char*key,std::size_t len){ void AiL::DisableFadeIn(const bool disable){ disableFadeIn=disable; } + +void AiL::SetWorldColorFunc(std::functionfunc){ + worldColorFunc=func; +} + +void AiL::SetWorldColor(Pixel worldCol){ + worldColor=worldCol; +} + +const Pixel&AiL::GetWorldColor()const{ + return worldColor; +} \ No newline at end of file diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index 696631ad..225353c2 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -140,6 +140,8 @@ private: bool disableFadeIn=false; DynamicCounter healthCounter; DynamicCounter manaCounter; + Pixel worldColor=WHITE; + std::functionworldColorFunc=[](vi2d pos){return WHITE;}; void ValidateGameStatus(); #ifndef __EMSCRIPTEN__ @@ -242,6 +244,10 @@ public: void ResetGame(); void OnRequestCompleted(const std::string_view receivedData)const override; void DisableFadeIn(const bool disable); + //vi2d provides a tile in world coords. + void SetWorldColorFunc(std::functionfunc); + void SetWorldColor(Pixel worldCol); + const Pixel&GetWorldColor()const; struct TileGroupData{ vi2d tilePos; diff --git a/Adventures in Lestoria/MonsterAttribute.h b/Adventures in Lestoria/MonsterAttribute.h index 00244329..decbaa8d 100644 --- a/Adventures in Lestoria/MonsterAttribute.h +++ b/Adventures in Lestoria/MonsterAttribute.h @@ -86,4 +86,6 @@ enum class Attribute{ PATH_DIR, PREV_POS, WISP_PATTERN_LIST, + ENVIRONMENT_TIMER, + ENVIRONMENT_PHASE, }; \ No newline at end of file diff --git a/Adventures in Lestoria/Ursule.cpp b/Adventures in Lestoria/Ursule.cpp index 940cf5bf..a3b8acca 100644 --- a/Adventures in Lestoria/Ursule.cpp +++ b/Adventures in Lestoria/Ursule.cpp @@ -48,6 +48,7 @@ INCLUDE_BULLET_LIST INCLUDE_GFX INCLUDE_MONSTER_LIST INCLUDE_MONSTER_DATA +INCLUDE_DATA using A=Attribute; @@ -66,6 +67,8 @@ void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy m.AddBuff(BARRIER_DAMAGE_REDUCTION,INFINITE,ConfigFloat("Phase 2.Barrier Damage Reduction")/100.f); m.I(A::PHASE_REPEAT_COUNT)=ConfigInt("Phase 2.Wisp Pattern Spawn Count"); SoundEffect::PlaySFX("Ursule Phase Transition",SoundEffect::CENTERED); + m.F(A::ENVIRONMENT_TIMER)=ConfigFloat("Phase 2.Environment Fade-out Time"); + m.I(A::ENVIRONMENT_PHASE)=0; }; if(m.GetRemainingHPPct()<=ConfigFloat("Phase 2.Change")/100.f){ @@ -110,6 +113,31 @@ void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy case 2:{ m.PerformOtherAnimation(2); m.F(A::SHOOT_TIMER)=std::max(0.f,m.F(A::SHOOT_TIMER)-fElapsedTime); + + m.F(A::ENVIRONMENT_TIMER)=std::max(0.f,m.F(A::ENVIRONMENT_TIMER)-fElapsedTime); + switch(m.I(A::ENVIRONMENT_PHASE)){ + case 0:{ //Fade out. + game->SetWorldColor(WHITE*util::lerp(0.f,1.0f,m.F(A::ENVIRONMENT_TIMER)/ConfigFloat("Phase 2.Environment Fade-out Time"))); + if(m.F(A::ENVIRONMENT_TIMER)==0.f){ + game->SetWorldColor({0,0,0,255}); + m.F(A::ENVIRONMENT_TIMER)=ConfigFloat("Phase 2.Environment Fade-in Time"); + m.I(A::ENVIRONMENT_PHASE)++; + game->SetWorldColorFunc([&](vi2d pos){ + float fadeInRange=DATA["MonsterStrategy"]["Ursule"]["Phase 2"]["Environment Fade-In Range"].GetReal()/100.f*24.f; + float distToPlayer=geom2d::line(game->GetPlayer()->GetPos(),pos).length(); + return game->GetWorldColor()*std::min(1.0f,fadeInRange/distToPlayer); + }); + } + }break; + case 1:{ //Fade in. + Pixel fadeInCol=ConfigPixel("Phase 2.Environment Fade-In Color"); + + game->SetWorldColor(fadeInCol*util::lerp(1.f,0.f,m.F(A::ENVIRONMENT_TIMER)/ConfigFloat("Phase 2.Environment Fade-in Time"))); + if(m.F(A::ENVIRONMENT_TIMER)==0.f){ + game->SetWorldColor(fadeInCol); + } + }break; + } if(m.I(A::PHASE_REPEAT_COUNT)>0){ if(m.F(A::SHOOT_TIMER)==0.f){ @@ -139,7 +167,7 @@ void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy std::string_view row=ConfigString(std::format("Wisp Pattern {}.Row[{}]",wispPattern,y)); if(row[int(x/wispSize.x)%row.length()]!='.'){ float ySpawn=ConfigInt("Phase 2.Wisp Pattern Spawn Y")+y*wispSize.y; - BULLET_LIST.push_back(std::make_unique(vf2d{x,ySpawn},vf2d{0,ConfigFloat("Phase 2.Wisp Speed")},wispSize.x/2,m.GetAttack(),m.OnUpperLevel(),false,ConfigPixel("Phase 2.Wisp Color"))); + BULLET_LIST.push_back(std::make_unique(vf2d{x,ySpawn},vf2d{0,ConfigFloat("Phase 2.Wisp Speed")},wispSize.x/3.f,m.GetAttack(),m.OnUpperLevel(),false,ConfigPixel("Phase 2.Wisp Color"))); } } } @@ -158,7 +186,7 @@ void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy } }break; case 3:{ - std::cout<<"Phase 3"<