|
|
|
@ -61,6 +61,8 @@ void VirusAttack::InitializeImages(){ |
|
|
|
|
LoadImage(PLATFORM,"assets/platform.png"); |
|
|
|
|
LoadImage(GUARD_ICON,"assets/shieldIcon.png"); |
|
|
|
|
LoadImage(GUIDE,"assets/guide.png"); |
|
|
|
|
LoadImage(ROUND_BAR,"assets/round_bar.png"); |
|
|
|
|
LoadImage(SEGMENT_BAR,"assets/segmentBar.png",false,false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void VirusAttack::InitializeLevelData(){ |
|
|
|
@ -73,7 +75,7 @@ void VirusAttack::InitializeLevelData(){ |
|
|
|
|
levelData[stage].levelColor=DARK_RED; |
|
|
|
|
levelData[stage].size={64,64}; |
|
|
|
|
levelData[stage].bgm=Sound::BOSS2; |
|
|
|
|
levelData[stage].player_starting_resources={50,50,50,50,50}; |
|
|
|
|
levelData[stage].player_starting_resources={500,500,500,500,500}; |
|
|
|
|
levelData[stage].enemy_starting_resources={0,0,0,0,0}; |
|
|
|
|
{ |
|
|
|
|
std::vector<UnitData>&units=levelData[stage].unitPlacement; |
|
|
|
@ -127,6 +129,7 @@ void VirusAttack::InitializeLevelData(){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool VirusAttack::OnUserCreate(){ |
|
|
|
|
srand(time(NULL)); |
|
|
|
|
SetPixelMode(Pixel::MASK); |
|
|
|
|
|
|
|
|
|
game.Initialise(GetScreenSize()); |
|
|
|
@ -667,6 +670,7 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ |
|
|
|
|
|
|
|
|
|
std::erase_if(TileManager::visibleTiles,[](std::pair<vf2d,float> key){return key.second<=0;}); |
|
|
|
|
|
|
|
|
|
playerUsedMemory=enemyUsedMemory={0}; |
|
|
|
|
for(auto&u:units){ |
|
|
|
|
u->SaveMemory(); |
|
|
|
|
std::weak_ptr<Unit>closestUnit; |
|
|
|
@ -686,6 +690,19 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
u->AttemptAttack(u,closestUnit,units,debuffIcons,IMAGES); |
|
|
|
|
u->_Update(this,SOUNDS,player_resources,enemy_resources,queuedUnits,resourceGainTimer,resourceGainIcons,IMAGES); |
|
|
|
|
if(u->IsFriendly()){ |
|
|
|
|
playerUsedMemory[0]+=u->health.size; |
|
|
|
|
playerUsedMemory[1]+=u->range.size; |
|
|
|
|
playerUsedMemory[2]+=u->atkSpd.size; |
|
|
|
|
playerUsedMemory[3]+=u->moveSpd.size; |
|
|
|
|
playerUsedMemory[4]+=u->procedure.size; |
|
|
|
|
} else { |
|
|
|
|
enemyUsedMemory[0]+=u->health.size; |
|
|
|
|
enemyUsedMemory[1]+=u->range.size; |
|
|
|
|
enemyUsedMemory[2]+=u->atkSpd.size; |
|
|
|
|
enemyUsedMemory[3]+=u->moveSpd.size; |
|
|
|
|
enemyUsedMemory[4]+=u->procedure.size; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::erase_if(units,[&](std::shared_ptr<Unit>u){ |
|
|
|
@ -704,7 +721,7 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ |
|
|
|
|
|
|
|
|
|
queuedUnits.clear(); |
|
|
|
|
|
|
|
|
|
DrawPartialDecal({0,0},GetScreenSize(),IMAGES[MATRIX]->Decal(),randomBackgroundOffset,{32,32},Pixel{currentLevel->levelColor.r,currentLevel->levelColor.g,currentLevel->levelColor.b,164}/2); |
|
|
|
|
DrawPartialDecal({0,0},GetScreenSize(),IMAGES[MATRIX]->Decal(),randomBackgroundOffset+game.GetWorldOffset()*(vf2d{32,32}/vf2d(GetScreenSize()))*game.GetWorldScale(),{32,32},Pixel{currentLevel->levelColor.r,currentLevel->levelColor.g,currentLevel->levelColor.b,164}/2); |
|
|
|
|
game.DrawPartialDecal({0,0},WORLD_SIZE*CONSTANT::TILE_SIZE,IMAGES[TILE]->Decal(),{0,0},WORLD_SIZE*CONSTANT::TILE_SIZE,currentLevel->levelColor); |
|
|
|
|
|
|
|
|
|
for(auto&u:units){ |
|
|
|
@ -756,6 +773,7 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ |
|
|
|
|
unitCreationList.DrawDecal(this); |
|
|
|
|
platformCreationList.DrawDecal(this); |
|
|
|
|
|
|
|
|
|
DrawSystemMemoryBar(fElapsedTime); |
|
|
|
|
DrawResourceBar(fElapsedTime); |
|
|
|
|
DrawDecal({float(ScreenWidth()-74-IMAGES[GUIDE]->Sprite()->width*0.75),float(ScreenHeight()+6-IMAGES[GUIDE]->Sprite()->height*0.75)},IMAGES[GUIDE]->Decal(),{0.75,0.75}); |
|
|
|
|
DrawMinimap(); |
|
|
|
@ -789,21 +807,146 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void VirusAttack::DrawSystemMemoryBar(float fElapsedTime){ |
|
|
|
|
memoryChangeTimer=std::max(0.f,memoryChangeTimer-fElapsedTime); |
|
|
|
|
memoryDisplayDelay-=fElapsedTime; |
|
|
|
|
if(memoryDisplayDelay<=0){ |
|
|
|
|
if(memoryDisplayAmt>lastTotalMemory){ |
|
|
|
|
memoryDisplayAmt-=1; |
|
|
|
|
} else
|
|
|
|
|
if(memoryDisplayAmt<lastTotalMemory){ |
|
|
|
|
memoryDisplayAmt+=1; |
|
|
|
|
} |
|
|
|
|
memoryDisplayDelay=0.01; |
|
|
|
|
} |
|
|
|
|
lastDisplayMemoryUpdateTimer-=fElapsedTime; |
|
|
|
|
if(lastDisplayMemoryUpdateTimer<=0){ |
|
|
|
|
for(int i=0;i<playerUsedMemory.size();i++){ |
|
|
|
|
if(playerUsedMemory[i]<playerUsedDisplayMemory[i]){ |
|
|
|
|
playerUsedDisplayMemory[i]--; |
|
|
|
|
} else |
|
|
|
|
if(playerUsedMemory[i]>playerUsedDisplayMemory[i]){ |
|
|
|
|
playerUsedDisplayMemory[i]++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for(int i=0;i<enemyUsedMemory.size();i++){ |
|
|
|
|
if(enemyUsedMemory[i]<enemyUsedDisplayMemory[i]){ |
|
|
|
|
enemyUsedDisplayMemory[i]--; |
|
|
|
|
} else |
|
|
|
|
if(enemyUsedMemory[i]>enemyUsedDisplayMemory[i]){ |
|
|
|
|
enemyUsedDisplayMemory[i]++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
lastDisplayMemoryUpdateTimer=0.01; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
vf2d barPos={2,float(ScreenHeight()-7)}; |
|
|
|
|
float barOffset=0; |
|
|
|
|
float barWidth=240; |
|
|
|
|
float actualBarWidth=barWidth+2; |
|
|
|
|
for(int i=0;i<playerUsedDisplayMemory.size();i++){ |
|
|
|
|
float barSegmentWidth=(float(playerUsedDisplayMemory[i])/currentLevel->availableMemory)*actualBarWidth; |
|
|
|
|
Pixel col; |
|
|
|
|
switch(i){ |
|
|
|
|
case 0:{ |
|
|
|
|
col=CONSTANT::HEALTH_COLOR; |
|
|
|
|
}break; |
|
|
|
|
case 1:{ |
|
|
|
|
col=CONSTANT::RANGE_COLOR; |
|
|
|
|
}break; |
|
|
|
|
case 2:{ |
|
|
|
|
col=CONSTANT::ATKSPD_COLOR; |
|
|
|
|
}break; |
|
|
|
|
case 3:{ |
|
|
|
|
col=CONSTANT::MOVESPD_COLOR; |
|
|
|
|
}break; |
|
|
|
|
case 4:{ |
|
|
|
|
col=CONSTANT::PROCEDURE_COLOR; |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
DrawPartialDecal(barPos+vf2d{barOffset+1,1.f},{barSegmentWidth,3},IMAGES[SEGMENT_BAR]->Decal(),{0,0},{float(playerUsedDisplayMemory[i]),3.f},col); |
|
|
|
|
barOffset+=barSegmentWidth; |
|
|
|
|
} |
|
|
|
|
FillRectDecal(barPos+vf2d{barOffset+1,1.f},{2,3},GREEN); |
|
|
|
|
barOffset=0; |
|
|
|
|
for(int i=0;i<enemyUsedDisplayMemory.size();i++){ |
|
|
|
|
float barSegmentWidth=(float(enemyUsedDisplayMemory[i])/currentLevel->availableMemory)*actualBarWidth; |
|
|
|
|
Pixel col; |
|
|
|
|
switch(i){ |
|
|
|
|
case 0:{ |
|
|
|
|
col=CONSTANT::HEALTH_COLOR; |
|
|
|
|
}break; |
|
|
|
|
case 1:{ |
|
|
|
|
col=CONSTANT::RANGE_COLOR; |
|
|
|
|
}break; |
|
|
|
|
case 2:{ |
|
|
|
|
col=CONSTANT::ATKSPD_COLOR; |
|
|
|
|
}break; |
|
|
|
|
case 3:{ |
|
|
|
|
col=CONSTANT::MOVESPD_COLOR; |
|
|
|
|
}break; |
|
|
|
|
case 4:{ |
|
|
|
|
col=CONSTANT::PROCEDURE_COLOR; |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
DrawPartialDecal(barPos+vf2d{barOffset+actualBarWidth+3-barSegmentWidth,1.f},{barSegmentWidth,3},IMAGES[SEGMENT_BAR]->Decal(),{0,0},{float(enemyUsedDisplayMemory[i]),3.f},col); |
|
|
|
|
barOffset-=barSegmentWidth; |
|
|
|
|
} |
|
|
|
|
FillRectDecal(barPos+vf2d{barOffset+actualBarWidth+3-2,1.f},{2,3},RED); |
|
|
|
|
|
|
|
|
|
DrawPartialDecal(barPos,{3,5},IMAGES[ROUND_BAR]->Decal(),{0,0},{3,5}); |
|
|
|
|
for(int i=barPos.x+3;i<barWidth;i++){ |
|
|
|
|
DrawPartialDecal(barPos+vf2d{3,0},{barWidth,5},IMAGES[ROUND_BAR]->Decal(),{2,0},{1,5}); |
|
|
|
|
} |
|
|
|
|
DrawPartialDecal(barPos+vf2d{3+barWidth,0},{3,5},IMAGES[ROUND_BAR]->Decal(),{2,0},{3,5}); |
|
|
|
|
vf2d textPos=barPos+vf2d{barWidth+6+4,0}; |
|
|
|
|
if(GetTotalUsedMemory()>lastTotalMemory){ |
|
|
|
|
memoryIncreased=true; |
|
|
|
|
memoryChangeTimer=2; |
|
|
|
|
} else
|
|
|
|
|
if(GetTotalUsedMemory()<lastTotalMemory){ |
|
|
|
|
memoryIncreased=false; |
|
|
|
|
memoryChangeTimer=2; |
|
|
|
|
} |
|
|
|
|
lastTotalMemory=GetTotalUsedMemory(); |
|
|
|
|
DrawShadowStringPropDecal(textPos,std::to_string(memoryDisplayAmt)+"/"+std::to_string(currentLevel->availableMemory)+"b",WHITE,PixelLerp(BLACK,memoryIncreased?CONSTANT::INCREASE_VALUE_COLOR:CONSTANT::DECREASE_VALUE_COLOR,memoryChangeTimer/2.0f),{0.6,0.6},0.6); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void VirusAttack::DrawResourceBar(float fElapsedTime){ |
|
|
|
|
for(int i=0;i<resourceGainTimer.size();i++){ |
|
|
|
|
resourceGainTimer[i]=std::max(0.f,resourceGainTimer[i]-fElapsedTime); |
|
|
|
|
} |
|
|
|
|
GradientFillRectDecal({0,0},{float(ScreenWidth()),12.f},BLACK,{VERY_DARK_BLUE.r,VERY_DARK_BLUE.g,VERY_DARK_BLUE.b,128},{VERY_DARK_BLUE.r,VERY_DARK_BLUE.g,VERY_DARK_BLUE.b,128},BLACK); |
|
|
|
|
DrawRectDecal({0,0},{float(ScreenWidth()),12.f},{3, 194, 252}); |
|
|
|
|
auto DrawResourceDisplay=[&](int index,int resourceValue,Pixel col){ |
|
|
|
|
auto DrawResourceDisplay=[&](int index,int resourceValue,int&previousResourceValue,int&displayResourceValue,Pixel col){ |
|
|
|
|
resourceDisplayValueUpdateTimer[index]-=fElapsedTime; |
|
|
|
|
if(previousResourceValue<resourceValue){ |
|
|
|
|
resourceIncreased[index]=true; |
|
|
|
|
resourceGainTimer[index]=2; |
|
|
|
|
previousResourceValue=resourceValue; |
|
|
|
|
} else |
|
|
|
|
if(previousResourceValue>resourceValue){ |
|
|
|
|
resourceIncreased[index]=false; |
|
|
|
|
resourceGainTimer[index]=2; |
|
|
|
|
previousResourceValue=resourceValue; |
|
|
|
|
} |
|
|
|
|
if(resourceDisplayValueUpdateTimer[index]<=0){ |
|
|
|
|
if(displayResourceValue<resourceValue){ |
|
|
|
|
displayResourceValue++; |
|
|
|
|
} else |
|
|
|
|
if(displayResourceValue>resourceValue){ |
|
|
|
|
displayResourceValue--; |
|
|
|
|
} |
|
|
|
|
resourceDisplayValueUpdateTimer[index]=0.01; |
|
|
|
|
} |
|
|
|
|
DrawDecal({6.f+index*42,1.f},IMAGES[RESOURCE]->Decal(),{1,1},col); |
|
|
|
|
DrawShadowStringDecal({6.f+index*42+20,2.f},std::to_string(resourceValue),col,PixelLerp(BLACK,{7, 223, 247},resourceGainTimer[index]/2.0f)); |
|
|
|
|
DrawShadowStringDecal({6.f+index*42+20,2.f},std::to_string(displayResourceValue),col,PixelLerp(BLACK,resourceIncreased[index]?CONSTANT::INCREASE_VALUE_COLOR:CONSTANT::DECREASE_VALUE_COLOR,resourceGainTimer[index]/2.0f)); |
|
|
|
|
}; |
|
|
|
|
DrawResourceDisplay(0,player_resources.health,CONSTANT::HEALTH_COLOR); |
|
|
|
|
DrawResourceDisplay(1,player_resources.atkSpd,CONSTANT::ATKSPD_COLOR); |
|
|
|
|
DrawResourceDisplay(2,player_resources.moveSpd,CONSTANT::MOVESPD_COLOR); |
|
|
|
|
DrawResourceDisplay(3,player_resources.range,CONSTANT::RANGE_COLOR); |
|
|
|
|
DrawResourceDisplay(4,player_resources.procedure,CONSTANT::PROCEDURE_COLOR); |
|
|
|
|
DrawResourceDisplay(0,player_resources.health,player_prev_resources.health,player_display_resources.health,CONSTANT::HEALTH_COLOR); |
|
|
|
|
DrawResourceDisplay(1,player_resources.atkSpd,player_prev_resources.atkSpd,player_display_resources.atkSpd,CONSTANT::ATKSPD_COLOR); |
|
|
|
|
DrawResourceDisplay(2,player_resources.moveSpd,player_prev_resources.moveSpd,player_display_resources.moveSpd,CONSTANT::MOVESPD_COLOR); |
|
|
|
|
DrawResourceDisplay(3,player_resources.range,player_prev_resources.range,player_display_resources.range,CONSTANT::RANGE_COLOR); |
|
|
|
|
DrawResourceDisplay(4,player_resources.procedure,player_prev_resources.procedure,player_display_resources.procedure,CONSTANT::PROCEDURE_COLOR); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void VirusAttack::RenderFogOfWar(){ |
|
|
|
@ -863,6 +1006,24 @@ void VirusAttack::ExpendResources(Resources&resources,std::vector<Memory>&unitCo |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int VirusAttack::GetTotalUsedMemory(){ |
|
|
|
|
return GetPlayerUsedMemory()+GetEnemyUsedMemory(); |
|
|
|
|
} |
|
|
|
|
int VirusAttack::GetPlayerUsedMemory(){ |
|
|
|
|
int sum=0; |
|
|
|
|
for(int i=0;i<5;i++){ |
|
|
|
|
sum+=playerUsedMemory[i]; |
|
|
|
|
} |
|
|
|
|
return sum; |
|
|
|
|
} |
|
|
|
|
int VirusAttack::GetEnemyUsedMemory(){ |
|
|
|
|
int sum=0; |
|
|
|
|
for(int i=0;i<5;i++){ |
|
|
|
|
sum+=enemyUsedMemory[i]; |
|
|
|
|
} |
|
|
|
|
return sum; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int main() |
|
|
|
|
{ |
|
|
|
|
VirusAttack app; |
|
|
|
|