|
|
@ -65,52 +65,64 @@ void VirusAttack::InitializeImages(){ |
|
|
|
|
|
|
|
|
|
|
|
void VirusAttack::InitializeLevelData(){ |
|
|
|
void VirusAttack::InitializeLevelData(){ |
|
|
|
#pragma region Stage 1 |
|
|
|
#pragma region Stage 1 |
|
|
|
//Stage 1 data.
|
|
|
|
|
|
|
|
levelData[STAGE1].size={64,64}; |
|
|
|
|
|
|
|
levelData[STAGE1].bgm=Sound::BOSS2; |
|
|
|
|
|
|
|
levelData[STAGE1].player_starting_resources={50,50,50,50,50}; |
|
|
|
|
|
|
|
levelData[STAGE1].enemy_starting_resources={0,0,0,0,0}; |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
std::vector<UnitData>&units=levelData[STAGE1].unitPlacement; |
|
|
|
//Stage 1 data.
|
|
|
|
std::vector<CPData>&collectionPoints=levelData[STAGE1].cpPlacement; |
|
|
|
LevelName stage=STAGE1; |
|
|
|
|
|
|
|
levelData[stage].cameraStart={96,96}; |
|
|
|
units.push_back({UnitType::LeftShifter,vf2d{128,128},true}); |
|
|
|
levelData[stage].worldZoom={1,1}; |
|
|
|
units.push_back({UnitType::RightShifter,vf2d{129,129},true}); |
|
|
|
levelData[stage].levelColor=DARK_RED; |
|
|
|
units.push_back({UnitType::BitRestorer,vf2d{130,130},true}); |
|
|
|
levelData[stage].size={64,64}; |
|
|
|
units.push_back({UnitType::BitRestorer,vf2d{130,140},true}); |
|
|
|
levelData[stage].bgm=Sound::BOSS2; |
|
|
|
units.push_back({UnitType::MemorySwapper,vf2d{131,131},true}); |
|
|
|
levelData[stage].player_starting_resources={50,50,50,50,50}; |
|
|
|
units.push_back({UnitType::Corrupter,vf2d{132,132},true}); |
|
|
|
levelData[stage].enemy_starting_resources={0,0,0,0,0}; |
|
|
|
units.push_back({UnitType::MemoryAllocator,vf2d{133,133},true}); |
|
|
|
{ |
|
|
|
units.push_back({UnitType::RAMBank,vf2d{134,134},true}); |
|
|
|
std::vector<UnitData>&units=levelData[stage].unitPlacement; |
|
|
|
units.push_back({UnitType::MemoryGuard,vf2d{200,134},true}); |
|
|
|
std::vector<CPData>&collectionPoints=levelData[stage].cpPlacement; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
units.push_back({UnitType::LeftShifter,vf2d{128,128},true}); |
|
|
|
for(int i=0;i<5;i++){ |
|
|
|
units.push_back({UnitType::RightShifter,vf2d{129,129},true}); |
|
|
|
collectionPoints.push_back({vf2d{32.f+48*i,32.f},0,MemoryType(i)}); |
|
|
|
units.push_back({UnitType::BitRestorer,vf2d{130,130},true}); |
|
|
|
collectionPoints.push_back({vf2d{32.f,32.f+48*i},-PI/2,MemoryType(i)}); |
|
|
|
units.push_back({UnitType::BitRestorer,vf2d{130,140},true}); |
|
|
|
} |
|
|
|
units.push_back({UnitType::MemorySwapper,vf2d{131,131},true}); |
|
|
|
|
|
|
|
units.push_back({UnitType::Corrupter,vf2d{132,132},true}); |
|
|
|
|
|
|
|
units.push_back({UnitType::MemoryAllocator,vf2d{133,133},true}); |
|
|
|
|
|
|
|
units.push_back({UnitType::RAMBank,vf2d{134,134},true}); |
|
|
|
|
|
|
|
units.push_back({UnitType::MemoryGuard,vf2d{200,134},true}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<5;i++){ |
|
|
|
|
|
|
|
collectionPoints.push_back({vf2d{32.f+48*i,32.f},0,MemoryType(i)}); |
|
|
|
|
|
|
|
collectionPoints.push_back({vf2d{32.f,32.f+48*i},-PI/2,MemoryType(i)}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
units.push_back({UnitType::RAMBank,vf2d{1200,1200},false}); |
|
|
|
units.push_back({UnitType::RAMBank,vf2d{1200,1200},false}); |
|
|
|
|
|
|
|
|
|
|
|
units.push_back({UnitType::RightShifter,vf2d{1260,1200},false}); |
|
|
|
units.push_back({UnitType::RightShifter,vf2d{1260,1200},false}); |
|
|
|
units.push_back({UnitType::RightShifter,vf2d{360,300},false}); |
|
|
|
units.push_back({UnitType::RightShifter,vf2d{360,300},false}); |
|
|
|
units.push_back({UnitType::RightShifter,vf2d{361,300},false}); |
|
|
|
units.push_back({UnitType::RightShifter,vf2d{361,300},false}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#pragma endregion |
|
|
|
#pragma endregion |
|
|
|
#pragma region Stage 2 |
|
|
|
#pragma region Stage 2 |
|
|
|
//Stage 2 data.
|
|
|
|
|
|
|
|
levelData[STAGE2].size={16,16}; |
|
|
|
|
|
|
|
levelData[STAGE2].bgm=Sound::COSMOS; |
|
|
|
|
|
|
|
levelData[STAGE2].player_starting_resources={10,10,10,10,10}; |
|
|
|
|
|
|
|
levelData[STAGE2].enemy_starting_resources={0,0,0,0,0}; |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
std::vector<UnitData>&units=levelData[STAGE2].unitPlacement; |
|
|
|
//Stage 2 data.
|
|
|
|
std::vector<CPData>&collectionPoints=levelData[STAGE2].cpPlacement; |
|
|
|
LevelName stage=STAGE2; |
|
|
|
|
|
|
|
levelData[stage].cameraStart={96,96}; |
|
|
|
units.push_back({UnitType::RAMBank,vf2d{134,134},true}); |
|
|
|
levelData[stage].worldZoom={1,1}; |
|
|
|
|
|
|
|
levelData[stage].size={16,16}; |
|
|
|
units.push_back({UnitType::RAMBank,vf2d{1200,1200},false}); |
|
|
|
levelData[stage].levelColor=DARK_GREEN; |
|
|
|
} |
|
|
|
levelData[stage].bgm=Sound::COSMOS; |
|
|
|
|
|
|
|
levelData[stage].player_starting_resources={10,10,10,10,10}; |
|
|
|
|
|
|
|
levelData[stage].enemy_starting_resources={0,0,0,0,0}; |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
std::vector<UnitData>&units=levelData[stage].unitPlacement; |
|
|
|
|
|
|
|
std::vector<CPData>&collectionPoints=levelData[stage].cpPlacement; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
units.push_back({UnitType::RAMBank,vf2d{134,134},true}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
units.push_back({UnitType::RAMBank,vf2d{1200,1200},false}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
#pragma endregion |
|
|
|
#pragma endregion |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -203,6 +215,8 @@ void VirusAttack::LoadLevel(LevelName level){ |
|
|
|
for(auto&cp:selectedLevel.cpPlacement){ |
|
|
|
for(auto&cp:selectedLevel.cpPlacement){ |
|
|
|
collectionPoints.push_back(std::make_unique<CollectionPoint>(this,cp.pos,cp.rot,*IMAGES[MEMORY_COLLECTION_POINT],cp.type));
|
|
|
|
collectionPoints.push_back(std::make_unique<CollectionPoint>(this,cp.pos,cp.rot,*IMAGES[MEMORY_COLLECTION_POINT],cp.type));
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
randomBackgroundOffset={util::random(128),util::random(128)}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void VirusAttack::InitializeGUIs(){ |
|
|
|
void VirusAttack::InitializeGUIs(){ |
|
|
@ -471,11 +485,35 @@ void VirusAttack::DrawMinimap(){ |
|
|
|
SetDrawTarget(IMAGES[MINIMAP_OUTLINE]->Sprite()); |
|
|
|
SetDrawTarget(IMAGES[MINIMAP_OUTLINE]->Sprite()); |
|
|
|
Clear(BLANK); |
|
|
|
Clear(BLANK); |
|
|
|
DrawRect((game.GetWorldOffset()/worldPixelSize*64),viewingTilesPct*64/game.GetWorldScale()); |
|
|
|
DrawRect((game.GetWorldOffset()/worldPixelSize*64),viewingTilesPct*64/game.GetWorldScale()); |
|
|
|
|
|
|
|
for(auto&cp:collectionPoints){ |
|
|
|
|
|
|
|
Pixel col; |
|
|
|
|
|
|
|
switch(cp->type){ |
|
|
|
|
|
|
|
case HEALTH:{ |
|
|
|
|
|
|
|
col=CONSTANT::HEALTH_COLOR; |
|
|
|
|
|
|
|
}break; |
|
|
|
|
|
|
|
case ATKSPD:{ |
|
|
|
|
|
|
|
col=CONSTANT::ATKSPD_COLOR; |
|
|
|
|
|
|
|
}break; |
|
|
|
|
|
|
|
case MOVESPD:{ |
|
|
|
|
|
|
|
col=CONSTANT::MOVESPD_COLOR; |
|
|
|
|
|
|
|
}break; |
|
|
|
|
|
|
|
case RANGE:{ |
|
|
|
|
|
|
|
col=CONSTANT::RANGE_COLOR; |
|
|
|
|
|
|
|
}break; |
|
|
|
|
|
|
|
case PROCEDURE:{ |
|
|
|
|
|
|
|
col=CONSTANT::PROCEDURE_COLOR; |
|
|
|
|
|
|
|
}break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
FillCircle(cp->pos/worldPixelSize*64-vf2d{1,0},1,col); |
|
|
|
|
|
|
|
DrawCircle(cp->pos/worldPixelSize*64-vf2d{1,0},1,BLACK); |
|
|
|
|
|
|
|
} |
|
|
|
for(auto&u:units){ |
|
|
|
for(auto&u:units){ |
|
|
|
vf2d squareSize=u->GetUnitSize()/vf2d(WORLD_SIZE); |
|
|
|
vf2d squareSize=u->GetUnitSize()/vf2d(WORLD_SIZE); |
|
|
|
squareSize.x=std::round(std::max(1.f,squareSize.x)); |
|
|
|
squareSize.x=std::round(std::max(1.f,squareSize.x)); |
|
|
|
squareSize.y=std::round(std::max(1.f,squareSize.y)); |
|
|
|
squareSize.y=std::round(std::max(1.f,squareSize.y)); |
|
|
|
FillRect(u->GetGhostPos()/worldPixelSize*64-squareSize,squareSize*2,u->IsFriendly()?GREEN:RED); |
|
|
|
float colorMult=1; |
|
|
|
|
|
|
|
if(u->IsAttached()){colorMult=0.5;} |
|
|
|
|
|
|
|
FillRect(u->GetGhostPos()/worldPixelSize*64-squareSize,squareSize*2,(u->IsFriendly()?GREEN:RED)*colorMult); |
|
|
|
} |
|
|
|
} |
|
|
|
IMAGES[MINIMAP_OUTLINE]->Decal()->Update(); |
|
|
|
IMAGES[MINIMAP_OUTLINE]->Decal()->Update(); |
|
|
|
SetDrawTarget(nullptr); |
|
|
|
SetDrawTarget(nullptr); |
|
|
@ -647,7 +685,7 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
u->AttemptAttack(u,closestUnit,units,debuffIcons,IMAGES); |
|
|
|
u->AttemptAttack(u,closestUnit,units,debuffIcons,IMAGES); |
|
|
|
u->_Update(this,SOUNDS,player_resources,enemy_resources,queuedUnits,resourceGainTimer); |
|
|
|
u->_Update(this,SOUNDS,player_resources,enemy_resources,queuedUnits,resourceGainTimer,resourceGainIcons,IMAGES); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::erase_if(units,[&](std::shared_ptr<Unit>u){ |
|
|
|
std::erase_if(units,[&](std::shared_ptr<Unit>u){ |
|
|
@ -666,7 +704,8 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ |
|
|
|
|
|
|
|
|
|
|
|
queuedUnits.clear(); |
|
|
|
queuedUnits.clear(); |
|
|
|
|
|
|
|
|
|
|
|
game.DrawPartialDecal({0,0},WORLD_SIZE*CONSTANT::TILE_SIZE,IMAGES[TILE]->Decal(),{0,0},WORLD_SIZE*CONSTANT::TILE_SIZE,DARK_GREEN); |
|
|
|
DrawPartialDecal({0,0},GetScreenSize(),IMAGES[MATRIX]->Decal(),randomBackgroundOffset,{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){ |
|
|
|
for(auto&u:units){ |
|
|
|
u->DrawRangeIndicator(this,game,IMAGES); |
|
|
|
u->DrawRangeIndicator(this,game,IMAGES); |
|
|
@ -699,7 +738,13 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ |
|
|
|
icon.Draw(game); |
|
|
|
icon.Draw(game); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(ResourceGainIcon&icon:resourceGainIcons){ |
|
|
|
|
|
|
|
icon.Update(fElapsedTime); |
|
|
|
|
|
|
|
icon.Draw(game); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::erase_if(debuffIcons,[](DebuffIcon&icon){return icon.lifetime<=0;}); |
|
|
|
std::erase_if(debuffIcons,[](DebuffIcon&icon){return icon.lifetime<=0;}); |
|
|
|
|
|
|
|
std::erase_if(resourceGainIcons,[](ResourceGainIcon&icon){return icon.lifetime<=0;}); |
|
|
|
|
|
|
|
|
|
|
|
for(auto&u:units){ |
|
|
|
for(auto&u:units){ |
|
|
|
u->_DrawHud(game,IMAGES); |
|
|
|
u->_DrawHud(game,IMAGES); |
|
|
@ -765,7 +810,7 @@ void VirusAttack::RenderFogOfWar(){ |
|
|
|
for(int y=game.GetTopLeftTile().y/96-1;y<=game.GetBottomRightTile().y/96+1;y++){ |
|
|
|
for(int y=game.GetTopLeftTile().y/96-1;y<=game.GetBottomRightTile().y/96+1;y++){ |
|
|
|
for(int x=game.GetTopLeftTile().x/96-1;x<=game.GetBottomRightTile().x/96+1;x++){ |
|
|
|
for(int x=game.GetTopLeftTile().x/96-1;x<=game.GetBottomRightTile().x/96+1;x++){ |
|
|
|
if(TileManager::visibleTiles.count(vi2d{x,y})==0){ |
|
|
|
if(TileManager::visibleTiles.count(vi2d{x,y})==0){ |
|
|
|
if(x>=0&&y>=0&&x<=WORLD_SIZE.x*CONSTANT::TILE_SIZE.x&&y<=WORLD_SIZE.y*CONSTANT::TILE_SIZE.y){ |
|
|
|
if(x>=0&&y>=0&&x<WORLD_SIZE.x/4&&y<WORLD_SIZE.y/4){ |
|
|
|
game.FillRectDecal(vf2d{float(x),float(y)}*96,{96,96},{0,0,0,128}); |
|
|
|
game.FillRectDecal(vf2d{float(x),float(y)}*96,{96,96},{0,0,0,128}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|