Added tile environment color manipulation.
This commit is contained in:
parent
7705a64624
commit
9f5bb212f8
@ -821,15 +821,17 @@ void AiL::PopulateRenderLists(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AiL::RenderTile(vi2d pos,TilesheetData tileSheet,int tileSheetIndex,vi2d tileSheetPos){
|
void AiL::RenderTile(vi2d pos,TilesheetData tileSheet,int tileSheetIndex,vi2d tileSheetPos){
|
||||||
|
Pixel tempCol=worldColorFunc(pos*game->GetCurrentMapData().tilewidth);
|
||||||
|
|
||||||
if(tileSheet.tileset->animationData.count(tileSheetIndex)){
|
if(tileSheet.tileset->animationData.count(tileSheetIndex)){
|
||||||
int animationDuration_ms=int(tileSheet.tileset->animationData[tileSheetIndex].size()*"animation_tile_precision"_I);
|
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 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 tileSheetWidth=tileSheet.tileset->tileset->Sprite()->width/tileSheet.tileset->tilewidth;
|
||||||
int tileSheetX=animatedIndex%tileSheetWidth;
|
int tileSheetX=animatedIndex%tileSheetWidth;
|
||||||
int tileSheetY=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{
|
}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();
|
foregroundTileGroups.clear();
|
||||||
upperForegroundTileGroups.clear();
|
upperForegroundTileGroups.clear();
|
||||||
MONSTER_LIST.clear();
|
MONSTER_LIST.clear();
|
||||||
|
worldColor=WHITE;
|
||||||
|
worldColorFunc=[&](vi2d pos){return game->worldColor;};
|
||||||
currentLevel=map;
|
currentLevel=map;
|
||||||
levelTime=0;
|
levelTime=0;
|
||||||
bossName="";
|
bossName="";
|
||||||
@ -2945,3 +2949,15 @@ std::string operator ""_FS(const char*key,std::size_t len){
|
|||||||
void AiL::DisableFadeIn(const bool disable){
|
void AiL::DisableFadeIn(const bool disable){
|
||||||
disableFadeIn=disable;
|
disableFadeIn=disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AiL::SetWorldColorFunc(std::function<Pixel(vi2d)>func){
|
||||||
|
worldColorFunc=func;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AiL::SetWorldColor(Pixel worldCol){
|
||||||
|
worldColor=worldCol;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Pixel&AiL::GetWorldColor()const{
|
||||||
|
return worldColor;
|
||||||
|
}
|
@ -140,6 +140,8 @@ private:
|
|||||||
bool disableFadeIn=false;
|
bool disableFadeIn=false;
|
||||||
DynamicCounter healthCounter;
|
DynamicCounter healthCounter;
|
||||||
DynamicCounter manaCounter;
|
DynamicCounter manaCounter;
|
||||||
|
Pixel worldColor=WHITE;
|
||||||
|
std::function<Pixel(vi2d)>worldColorFunc=[](vi2d pos){return WHITE;};
|
||||||
|
|
||||||
void ValidateGameStatus();
|
void ValidateGameStatus();
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
@ -242,6 +244,10 @@ public:
|
|||||||
void ResetGame();
|
void ResetGame();
|
||||||
void OnRequestCompleted(const std::string_view receivedData)const override;
|
void OnRequestCompleted(const std::string_view receivedData)const override;
|
||||||
void DisableFadeIn(const bool disable);
|
void DisableFadeIn(const bool disable);
|
||||||
|
//vi2d provides a tile in world coords.
|
||||||
|
void SetWorldColorFunc(std::function<Pixel(vi2d)>func);
|
||||||
|
void SetWorldColor(Pixel worldCol);
|
||||||
|
const Pixel&GetWorldColor()const;
|
||||||
|
|
||||||
struct TileGroupData{
|
struct TileGroupData{
|
||||||
vi2d tilePos;
|
vi2d tilePos;
|
||||||
|
@ -86,4 +86,6 @@ enum class Attribute{
|
|||||||
PATH_DIR,
|
PATH_DIR,
|
||||||
PREV_POS,
|
PREV_POS,
|
||||||
WISP_PATTERN_LIST,
|
WISP_PATTERN_LIST,
|
||||||
|
ENVIRONMENT_TIMER,
|
||||||
|
ENVIRONMENT_PHASE,
|
||||||
};
|
};
|
@ -48,6 +48,7 @@ INCLUDE_BULLET_LIST
|
|||||||
INCLUDE_GFX
|
INCLUDE_GFX
|
||||||
INCLUDE_MONSTER_LIST
|
INCLUDE_MONSTER_LIST
|
||||||
INCLUDE_MONSTER_DATA
|
INCLUDE_MONSTER_DATA
|
||||||
|
INCLUDE_DATA
|
||||||
|
|
||||||
using A=Attribute;
|
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.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");
|
m.I(A::PHASE_REPEAT_COUNT)=ConfigInt("Phase 2.Wisp Pattern Spawn Count");
|
||||||
SoundEffect::PlaySFX("Ursule Phase Transition",SoundEffect::CENTERED);
|
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){
|
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:{
|
case 2:{
|
||||||
m.PerformOtherAnimation(2);
|
m.PerformOtherAnimation(2);
|
||||||
m.F(A::SHOOT_TIMER)=std::max(0.f,m.F(A::SHOOT_TIMER)-fElapsedTime);
|
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<float>(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.I(A::PHASE_REPEAT_COUNT)>0){
|
||||||
if(m.F(A::SHOOT_TIMER)==0.f){
|
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));
|
std::string_view row=ConfigString(std::format("Wisp Pattern {}.Row[{}]",wispPattern,y));
|
||||||
if(row[int(x/wispSize.x)%row.length()]!='.'){
|
if(row[int(x/wispSize.x)%row.length()]!='.'){
|
||||||
float ySpawn=ConfigInt("Phase 2.Wisp Pattern Spawn Y")+y*wispSize.y;
|
float ySpawn=ConfigInt("Phase 2.Wisp Pattern Spawn Y")+y*wispSize.y;
|
||||||
BULLET_LIST.push_back(std::make_unique<Wisp>(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<Wisp>(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;
|
}break;
|
||||||
case 3:{
|
case 3:{
|
||||||
std::cout<<"Phase 3"<<std::endl;
|
|
||||||
}break;
|
}break;
|
||||||
default:{
|
default:{
|
||||||
ERR(std::format("WARNING! Unknown phase {} for {} reached!",m.phase,m.GetName()));
|
ERR(std::format("WARNING! Unknown phase {} for {} reached!",m.phase,m.GetName()));
|
||||||
|
@ -39,7 +39,7 @@ All rights reserved.
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 3
|
#define VERSION_MINOR 3
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 6316
|
#define VERSION_BUILD 6322
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
@ -340,11 +340,23 @@ MonsterStrategy
|
|||||||
# Percentage of damage reduced on the bear while the barrier is active.
|
# Percentage of damage reduced on the bear while the barrier is active.
|
||||||
Barrier Damage Reduction = 100%
|
Barrier Damage Reduction = 100%
|
||||||
|
|
||||||
|
# Amount of time the environment fades out to pitch black.
|
||||||
|
Environment Fade-out Time = 0.4s
|
||||||
|
|
||||||
|
# Amount of time for the environment to fade in with the new color.
|
||||||
|
Environment Fade-in Time = 2.0s
|
||||||
|
|
||||||
|
# New fade-in environment color.
|
||||||
|
Environment Fade-In Color = 87, 82, 255, 255
|
||||||
|
|
||||||
|
# The amount of range sight the player has with the new environment.
|
||||||
|
Environment Fade-In Range = 400
|
||||||
|
|
||||||
# Wisp size in pixels.
|
# Wisp size in pixels.
|
||||||
Wisp Size = 24,24
|
Wisp Size = 24,24
|
||||||
|
|
||||||
# Speed at which the wisp moves downwards.
|
# Speed at which the wisp moves downwards.
|
||||||
Wisp Speed = 100
|
Wisp Speed = 90
|
||||||
|
|
||||||
# RGBA value of the wisp.
|
# RGBA value of the wisp.
|
||||||
Wisp Color = 247, 157, 0, 255
|
Wisp Color = 247, 157, 0, 255
|
||||||
@ -357,7 +369,7 @@ MonsterStrategy
|
|||||||
|
|
||||||
# How much time (in seconds) to wait between each pattern spawn.
|
# How much time (in seconds) to wait between each pattern spawn.
|
||||||
# 100% speed means it takes 6 seconds for all the wisps to move entirely down.
|
# 100% speed means it takes 6 seconds for all the wisps to move entirely down.
|
||||||
Wisp Pattern Spawn Wait Time = 1.44s
|
Wisp Pattern Spawn Wait Time = 1.6s
|
||||||
|
|
||||||
# This value is either Bag or Random. Bag means every pattern gets selected once before re-cycling. Random is truly random with potential repeats.
|
# This value is either Bag or Random. Bag means every pattern gets selected once before re-cycling. Random is truly random with potential repeats.
|
||||||
Wisp Pattern Random Selection = Bag
|
Wisp Pattern Random Selection = Bag
|
||||||
@ -366,7 +378,7 @@ MonsterStrategy
|
|||||||
Wisp Pattern Spawn Count = 9
|
Wisp Pattern Spawn Count = 9
|
||||||
|
|
||||||
# Wait for the wisp count to be at or below this value before proceeding to Phase 3.
|
# Wait for the wisp count to be at or below this value before proceeding to Phase 3.
|
||||||
Wisp Count Phase Change Wait = 0
|
Wisp Count Phase Change Wait = 8.0s
|
||||||
}
|
}
|
||||||
Phase 3
|
Phase 3
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user