|
|
|
@ -101,11 +101,12 @@ void VirusAttack::InitializeLevelData(){ |
|
|
|
|
levelData[stage].name=stage; |
|
|
|
|
levelData[stage].cameraStart={96,96}; |
|
|
|
|
levelData[stage].worldZoom={1,1}; |
|
|
|
|
levelData[stage].levelColor=DARK_RED; |
|
|
|
|
levelData[stage].levelColor=DARK_GREEN; |
|
|
|
|
levelData[stage].size={24,24}; |
|
|
|
|
levelData[stage].bgm=Sound::GRAVITY; |
|
|
|
|
levelData[stage].scenarioIndex=int(stage); |
|
|
|
|
levelData[stage].player_starting_resources={500,500,500,500,500}; |
|
|
|
|
levelData[stage].availableMemory=240; |
|
|
|
|
levelData[stage].player_starting_resources={5,5,5,5,5}; |
|
|
|
|
levelData[stage].enemy_starting_resources={0,0,0,0,0}; |
|
|
|
|
{ |
|
|
|
|
std::vector<UnitData>&units=levelData[stage].unitPlacement; |
|
|
|
@ -124,19 +125,23 @@ void VirusAttack::InitializeLevelData(){ |
|
|
|
|
levelData[stage].name=stage; |
|
|
|
|
levelData[stage].cameraStart={96,96}; |
|
|
|
|
levelData[stage].worldZoom={1,1}; |
|
|
|
|
levelData[stage].size={16,16}; |
|
|
|
|
levelData[stage].size={30,30}; |
|
|
|
|
levelData[stage].levelColor=DARK_GREEN; |
|
|
|
|
levelData[stage].bgm=Sound::GRAVITY; |
|
|
|
|
levelData[stage].scenarioIndex=int(stage); |
|
|
|
|
levelData[stage].player_starting_resources={10,10,10,10,10}; |
|
|
|
|
levelData[stage].availableMemory=240; |
|
|
|
|
levelData[stage].player_starting_resources={50,30,40,30,55}; |
|
|
|
|
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::_Platform,vf2d{7*24,10*24},true}); |
|
|
|
|
|
|
|
|
|
units.push_back({UnitType::RAMBank,vf2d{1200,1200},false}); |
|
|
|
|
units.push_back({UnitType::RightShifter,vf2d{20*24,21*24},false}); |
|
|
|
|
units.push_back({UnitType::LeftShifter,vf2d{20*24,22*24},false}); |
|
|
|
|
units.push_back({UnitType::MemoryAllocator,vf2d{22*24,24*24},false}); |
|
|
|
|
units.push_back({UnitType::RAMBank,vf2d{22*24,23*24},false}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#pragma endregion |
|
|
|
@ -297,6 +302,7 @@ void VirusAttack::InitializeSounds(){ |
|
|
|
|
LoadSound(Sound::BOSS2,"boss2.mp3"); |
|
|
|
|
LoadSound(Sound::VOICEOVER,"voice.mp3"); |
|
|
|
|
LoadSound(Sound::PING,"ping.mp3"); |
|
|
|
|
LoadSound(Sound::ALARM,"alarm.mp3"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool VirusAttack::UnitCreationClickHandled(){ |
|
|
|
@ -326,9 +332,9 @@ bool VirusAttack::UnitCreationClickHandled(){ |
|
|
|
|
CheckClick(MemoryGuard,memoryGuardButton,IsPlatform) |
|
|
|
|
return false;
|
|
|
|
|
} |
|
|
|
|
#define EnableAndHoverCheck(UnitClass,Button,box,limited) \ |
|
|
|
|
Button->Enable(CanAfford(player_resources,UnitClass::resourceCost)&&(!limited||limited&&!flags.limitedBuildOptions)); \
|
|
|
|
|
if(limited&&!flags.limitedBuildOptions){Button->bVisible=false;} \
|
|
|
|
|
#define EnableAndHoverCheck(UnitClass,Button,box,allowed) \ |
|
|
|
|
Button->Enable(CanAfford(player_resources,UnitClass::resourceCost)&&allowed); \
|
|
|
|
|
if(!allowed){Button->bVisible=false;} \
|
|
|
|
|
if(Button->bHover){ \
|
|
|
|
|
box.Initialize(UnitClass::unitDescription, GetMousePos(), UnitClass::unitName,nullptr,{120,36},nullptr,UnitClass::resourceCost); \
|
|
|
|
|
hovering=true; \
|
|
|
|
@ -343,13 +349,13 @@ void VirusAttack::UpdateUnitCreationListGUI(bool allocatorSelected){ |
|
|
|
|
unitCreationList.DisplayAllControls(allocatorSelected); |
|
|
|
|
|
|
|
|
|
bool hovering=false; |
|
|
|
|
EnableAndHoverCheck(LeftShifter,leftShifterButton,unitCreationBox,false) |
|
|
|
|
EnableAndHoverCheck(RightShifter,rightShifterButton,unitCreationBox,false) |
|
|
|
|
EnableAndHoverCheck(BitRestorer,bitRestorerButton,unitCreationBox,true) |
|
|
|
|
EnableAndHoverCheck(MemorySwapper,memorySwapperButton,unitCreationBox,true) |
|
|
|
|
EnableAndHoverCheck(BitRestorer,bitRestorerButton,unitCreationBox,true) |
|
|
|
|
EnableAndHoverCheck(Corrupter,corrupterButton,unitCreationBox,true) |
|
|
|
|
EnableAndHoverCheck(_Platform,platformButton,unitCreationBox,true) |
|
|
|
|
EnableAndHoverCheck(LeftShifter,leftShifterButton,unitCreationBox,true) |
|
|
|
|
EnableAndHoverCheck(RightShifter,rightShifterButton,unitCreationBox,true) |
|
|
|
|
EnableAndHoverCheck(BitRestorer,bitRestorerButton,unitCreationBox,!flags.limitedBuildOptions) |
|
|
|
|
EnableAndHoverCheck(MemorySwapper,memorySwapperButton,unitCreationBox,!flags.limitedBuildOptions) |
|
|
|
|
EnableAndHoverCheck(BitRestorer,bitRestorerButton,unitCreationBox,!flags.limitedBuildOptions) |
|
|
|
|
EnableAndHoverCheck(Corrupter,corrupterButton,unitCreationBox,!flags.limitedBuildOptions) |
|
|
|
|
EnableAndHoverCheck(_Platform,platformButton,unitCreationBox,!flags.limitedBuildOptions) |
|
|
|
|
|
|
|
|
|
if(!hovering){ |
|
|
|
|
unitCreationBox.SetVisible(false); |
|
|
|
@ -361,10 +367,10 @@ void VirusAttack::UpdateUnitCreationListGUI(bool allocatorSelected){ |
|
|
|
|
void VirusAttack::UpdatePlatformCreationListGUI(bool platformSelected){ |
|
|
|
|
platformCreationList.DisplayAllControls(platformSelected); |
|
|
|
|
bool hovering=false; |
|
|
|
|
EnableAndHoverCheck(RAMBank,ramBankButton,platformCreationBox,false) |
|
|
|
|
EnableAndHoverCheck(Refresher,refresherButton,platformCreationBox,true) |
|
|
|
|
EnableAndHoverCheck(Turret,turretButton,platformCreationBox,true) |
|
|
|
|
EnableAndHoverCheck(MemoryGuard,memoryGuardButton,platformCreationBox,true) |
|
|
|
|
EnableAndHoverCheck(RAMBank,ramBankButton,platformCreationBox,true) |
|
|
|
|
EnableAndHoverCheck(Refresher,refresherButton,platformCreationBox,!flags.limitedBuildOptions) |
|
|
|
|
EnableAndHoverCheck(Turret,turretButton,platformCreationBox,!flags.limitedBuildOptions) |
|
|
|
|
EnableAndHoverCheck(MemoryGuard,memoryGuardButton,platformCreationBox,!flags.limitedBuildOptions) |
|
|
|
|
|
|
|
|
|
if(!hovering){ |
|
|
|
|
platformCreationBox.SetVisible(false); |
|
|
|
@ -375,23 +381,6 @@ void VirusAttack::UpdatePlatformCreationListGUI(bool platformSelected){ |
|
|
|
|
|
|
|
|
|
void VirusAttack::HandleDraggingSelection(){ |
|
|
|
|
auto NotClickingOnMinimap=[&](){return !(GetMouseX()>=ScreenWidth()-64&&GetMouseY()>=ScreenHeight()-64);}; |
|
|
|
|
bool allocatorSelected=false; |
|
|
|
|
bool platformSelected=false; |
|
|
|
|
bool memoryAllocatorBoxHovered=false; |
|
|
|
|
for(auto&u:units){ |
|
|
|
|
u->UpdateGUIState(gametv,player_resources,memoryAllocatorBox,memoryAllocatorBoxHovered,GetTotalUsedMemory(),currentLevel->availableMemory); |
|
|
|
|
if(u->IsSelected()){ |
|
|
|
|
if(u->IsAllocator()){ |
|
|
|
|
allocatorSelected=true; |
|
|
|
|
} else |
|
|
|
|
if(u->IsPlatform()){ |
|
|
|
|
platformSelected=true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(!memoryAllocatorBoxHovered)memoryAllocatorBox.SetVisible(false); |
|
|
|
|
UpdateUnitCreationListGUI(allocatorSelected); |
|
|
|
|
UpdatePlatformCreationListGUI(platformSelected); |
|
|
|
|
if(GetMouse(0).bPressed){ |
|
|
|
|
if(NotClickingOnMinimap()){ |
|
|
|
|
for(auto&u:units){ |
|
|
|
@ -777,12 +766,17 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ |
|
|
|
|
#pragma endregion |
|
|
|
|
#pragma region GAMEPLAY |
|
|
|
|
case GameState::GAMEPLAY:{ |
|
|
|
|
HandleGUIDisplay(); |
|
|
|
|
if(flags.playerInControl){ |
|
|
|
|
HandleDraggingSelection(); |
|
|
|
|
HandleRightClickMove(); |
|
|
|
|
HandlePanAndZoom(fElapsedTime); |
|
|
|
|
HandleMinimapClick(); |
|
|
|
|
} |
|
|
|
|
flashTimer+=fElapsedTime*2; |
|
|
|
|
if(flashTimer>1){ |
|
|
|
|
flashTimer--; |
|
|
|
|
} |
|
|
|
|
SCENARIOS[currentScenario]->_Update(); |
|
|
|
|
if(SCENARIOS[currentScenario]->transitionToNextLevel){ |
|
|
|
|
if(SCENARIOS[currentScenario]->nextLevel!=FINISH){ |
|
|
|
@ -1039,11 +1033,11 @@ void VirusAttack::DrawSystemMemoryBar(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
FillRectDecal(barPos+vf2d{barOffset+actualBarWidth+3-2,1.f},{2,3},RED); |
|
|
|
|
|
|
|
|
|
DrawPartialDecal(barPos,{3,5},IMAGES[ROUND_BAR]->Decal(),{0,0},{3,5}); |
|
|
|
|
DrawPartialDecal(barPos,{3,5},IMAGES[ROUND_BAR]->Decal(),{0,0},{3,5},flags.flashMemoryBar?PixelLerp(BLACK,CONSTANT::INCREASE_VALUE_COLOR,flashTimer):BLACK); |
|
|
|
|
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,0},{barWidth,5},IMAGES[ROUND_BAR]->Decal(),{2,0},{1,5},flags.flashMemoryBar?PixelLerp(BLACK,CONSTANT::INCREASE_VALUE_COLOR,flashTimer):BLACK); |
|
|
|
|
} |
|
|
|
|
DrawPartialDecal(barPos+vf2d{3+barWidth,0},{3,5},IMAGES[ROUND_BAR]->Decal(),{2,0},{3,5}); |
|
|
|
|
DrawPartialDecal(barPos+vf2d{3+barWidth,0},{3,5},IMAGES[ROUND_BAR]->Decal(),{2,0},{3,5},flags.flashMemoryBar?PixelLerp(BLACK,CONSTANT::INCREASE_VALUE_COLOR,flashTimer):BLACK); |
|
|
|
|
vf2d textPos=barPos+vf2d{barWidth+6+4,0}; |
|
|
|
|
if(GetTotalUsedMemory()>lastTotalMemory){ |
|
|
|
|
memoryIncreased=true; |
|
|
|
@ -1272,6 +1266,26 @@ void VirusAttack::DrawCurvedTexture(vf2d offset,vf2d size,Decal*decal,vf2d texOf |
|
|
|
|
SetDecalStructure(DecalStructure::FAN); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void VirusAttack::HandleGUIDisplay(){ |
|
|
|
|
bool allocatorSelected=false; |
|
|
|
|
bool platformSelected=false; |
|
|
|
|
bool memoryAllocatorBoxHovered=false; |
|
|
|
|
for(auto&u:units){ |
|
|
|
|
u->UpdateGUIState(gametv,player_resources,memoryAllocatorBox,memoryAllocatorBoxHovered,GetTotalUsedMemory(),currentLevel->availableMemory); |
|
|
|
|
if(u->IsSelected()){ |
|
|
|
|
if(u->IsAllocator()){ |
|
|
|
|
allocatorSelected=true; |
|
|
|
|
} else |
|
|
|
|
if(u->IsPlatform()){ |
|
|
|
|
platformSelected=true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(!memoryAllocatorBoxHovered)memoryAllocatorBox.SetVisible(false); |
|
|
|
|
UpdateUnitCreationListGUI(allocatorSelected); |
|
|
|
|
UpdatePlatformCreationListGUI(platformSelected); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int main() |
|
|
|
|
{ |
|
|
|
|
VirusAttack app; |
|
|
|
|