Stage 1 and 2 completed.
This commit is contained in:
parent
34b32d809b
commit
bb33e8a8cd
@ -5,4 +5,5 @@ struct GameFlags{
|
|||||||
bool playerInControl=false;
|
bool playerInControl=false;
|
||||||
bool limitedBuildOptions=false;
|
bool limitedBuildOptions=false;
|
||||||
bool guideEnabled=true;
|
bool guideEnabled=true;
|
||||||
|
bool flashMemoryBar=false;
|
||||||
};
|
};
|
@ -22,6 +22,10 @@ void Scenario::Start(){};
|
|||||||
void Scenario::_Update(){
|
void Scenario::_Update(){
|
||||||
initialWaitTime=std::max(0.f,initialWaitTime-game.GetPGE()->GetElapsedTime());
|
initialWaitTime=std::max(0.f,initialWaitTime-game.GetPGE()->GetElapsedTime());
|
||||||
missionFinishWaitTime=std::max(0.f,missionFinishWaitTime-game.GetPGE()->GetElapsedTime());
|
missionFinishWaitTime=std::max(0.f,missionFinishWaitTime-game.GetPGE()->GetElapsedTime());
|
||||||
|
smallTimePass=std::min(1.f,smallTimePass+game.GetPGE()->GetElapsedTime());
|
||||||
|
if(flags.playerInControl){
|
||||||
|
smallTimePass=0;
|
||||||
|
}
|
||||||
if(missionCompleted){
|
if(missionCompleted){
|
||||||
missionCompletedTimer+=game.GetPGE()->GetElapsedTime();
|
missionCompletedTimer+=game.GetPGE()->GetElapsedTime();
|
||||||
} else {
|
} else {
|
||||||
@ -54,7 +58,8 @@ void Scenario::Draw(){
|
|||||||
Resources temp={0,0,0,0,0};
|
Resources temp={0,0,0,0,0};
|
||||||
box.UpdateAndDraw({24,64},game.GetPGE(),temp,IMAGES,0,0);
|
box.UpdateAndDraw({24,64},game.GetPGE(),temp,IMAGES,0,0);
|
||||||
}
|
}
|
||||||
void Scenario::SetCameraTarget(vf2d pos){
|
void Scenario::SetCameraTarget(vf2d pos,bool instant){
|
||||||
|
if(instant){camera.SetMode(utils::Camera2D::Mode::Simple);} else {camera.SetMode(utils::Camera2D::Mode::LazyFollow);}
|
||||||
targetPos=pos;
|
targetPos=pos;
|
||||||
camera.SetTarget(targetPos);
|
camera.SetTarget(targetPos);
|
||||||
camera.Update(game.GetPGE()->GetElapsedTime());
|
camera.Update(game.GetPGE()->GetElapsedTime());
|
||||||
@ -63,6 +68,14 @@ void Scenario::SetCameraTarget(vf2d pos){
|
|||||||
void Scenario::SetObjective(std::string objective){
|
void Scenario::SetObjective(std::string objective){
|
||||||
this->objective=objective;
|
this->objective=objective;
|
||||||
}
|
}
|
||||||
|
void Scenario::RevealTiles(vf2d pos){
|
||||||
|
for(int y=-1;y<=1;y++){
|
||||||
|
for(int x=-1;x<=1;x++){
|
||||||
|
vi2d basePos={int(pos.x+x*96),int(pos.y+y*96)};
|
||||||
|
TileManager::visibleTiles[{basePos.x/96,basePos.y/96}]=30;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Stage1::Stage1(std::vector<std::shared_ptr<Unit>>&units,std::vector<std::unique_ptr<Renderable>>&IMAGES,std::vector<std::unique_ptr<Audio>>&SOUNDS,std::string&objective,TileTransformedView&game,GameFlags&flags)
|
Stage1::Stage1(std::vector<std::shared_ptr<Unit>>&units,std::vector<std::unique_ptr<Renderable>>&IMAGES,std::vector<std::unique_ptr<Audio>>&SOUNDS,std::string&objective,TileTransformedView&game,GameFlags&flags)
|
||||||
:Scenario(units,IMAGES,SOUNDS,objective,game,flags){}
|
:Scenario(units,IMAGES,SOUNDS,objective,game,flags){}
|
||||||
void Stage1::Start(){
|
void Stage1::Start(){
|
||||||
@ -71,7 +84,9 @@ void Stage1::Start(){
|
|||||||
nextLevel=LevelName::STAGE2;
|
nextLevel=LevelName::STAGE2;
|
||||||
};
|
};
|
||||||
void Scenario::DisplayBox(std::string text,bool scaryHoodedFigure){
|
void Scenario::DisplayBox(std::string text,bool scaryHoodedFigure){
|
||||||
|
if(smallTimePass==1){
|
||||||
box.Initialize(text,{24,64},"",scaryHoodedFigure?IMAGES[SPOOK_HOODED_FIGURE].get():IMAGES[HOODED_FIGURE].get(),{378,28},SOUNDS[Sound::VOICEOVER].get());
|
box.Initialize(text,{24,64},"",scaryHoodedFigure?IMAGES[SPOOK_HOODED_FIGURE].get():IMAGES[HOODED_FIGURE].get(),{378,28},SOUNDS[Sound::VOICEOVER].get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void Stage1::Update(){
|
void Stage1::Update(){
|
||||||
switch(state){
|
switch(state){
|
||||||
@ -86,12 +101,7 @@ void Stage1::Update(){
|
|||||||
if(box.bPressed){
|
if(box.bPressed){
|
||||||
state=2;
|
state=2;
|
||||||
SOUNDS[Sound::PING]->PlayCentered();
|
SOUNDS[Sound::PING]->PlayCentered();
|
||||||
for(int y=-1;y<=1;y++){
|
RevealTiles({320,320});
|
||||||
for(int x=-1;x<=1;x++){
|
|
||||||
vi2d basePos={320+x*96,320+y*96};
|
|
||||||
TileManager::visibleTiles[{basePos.x/96,basePos.y/96}]=30;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
case 2:{
|
case 2:{
|
||||||
@ -113,7 +123,7 @@ void Stage1::Update(){
|
|||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
case 5:{
|
case 5:{
|
||||||
DisplayBox("The yellow bar represent units' allocated Health memory. Take out the enemies' and make sure you always have at least 1 bit of it.");
|
DisplayBox("The yellow bars represent units' allocated Health memory. Take out the enemies' and make sure you always have at least 1 bit of it.");
|
||||||
if(box.bPressed){
|
if(box.bPressed){
|
||||||
state=6;
|
state=6;
|
||||||
}
|
}
|
||||||
@ -148,17 +158,122 @@ bool Stage1::MissionCompleted(){
|
|||||||
Stage2::Stage2(std::vector<std::shared_ptr<Unit>>&units,std::vector<std::unique_ptr<Renderable>>&IMAGES,std::vector<std::unique_ptr<Audio>>&SOUNDS,std::string&objective,TileTransformedView&game,GameFlags&flags)
|
Stage2::Stage2(std::vector<std::shared_ptr<Unit>>&units,std::vector<std::unique_ptr<Renderable>>&IMAGES,std::vector<std::unique_ptr<Audio>>&SOUNDS,std::string&objective,TileTransformedView&game,GameFlags&flags)
|
||||||
:Scenario(units,IMAGES,SOUNDS,objective,game,flags){}
|
:Scenario(units,IMAGES,SOUNDS,objective,game,flags){}
|
||||||
void Stage2::Start(){
|
void Stage2::Start(){
|
||||||
|
flags.playerInControl=false;
|
||||||
|
flags.limitedBuildOptions=true;
|
||||||
nextLevel=LevelName::STAGE3;
|
nextLevel=LevelName::STAGE3;
|
||||||
};
|
};
|
||||||
void Stage2::Update(){
|
void Stage2::Update(){
|
||||||
switch(state){
|
switch(state){
|
||||||
case 0:{
|
case 0:{
|
||||||
|
SetCameraTarget({7*24,10*24},true);
|
||||||
|
DisplayBox("You took care of that sector flawlessly Hacker, this next one needs a bit more hand-holding.");
|
||||||
|
if(box.bPressed){
|
||||||
|
state=1;
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case 1:{
|
||||||
|
DisplayBox("We have analyzed the data from the RAM bank and can now create one. Go ahead and select the Platform here and construct one.");
|
||||||
|
if(box.bPressed){
|
||||||
|
state=2;
|
||||||
|
box.SetVisible(false);
|
||||||
|
flags.playerInControl=true;
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case 2:{
|
||||||
|
for(auto&u:units){
|
||||||
|
if(u->IsRAMBank()&&u->IsFriendly()){
|
||||||
|
state=3;
|
||||||
|
flags.playerInControl=false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case 3:{
|
||||||
|
DisplayBox("Excellent, each RAM bank has the capability to allocate memory into the system. See that indicator down below?");
|
||||||
|
flags.flashMemoryBar=true;
|
||||||
|
if(box.bPressed){
|
||||||
|
state=4;
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case 4:{
|
||||||
|
DisplayBox("This sector lets us allocate 30 bytes of RAM. That's 240 bits for the savvy folks out there.");
|
||||||
|
if(box.bPressed){
|
||||||
|
state=5;
|
||||||
|
flags.flashMemoryBar=false;
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case 5:{
|
||||||
|
DisplayBox("Some of it has already been used up by our RAM bank and other system resources... ");
|
||||||
|
if(box.bPressed){
|
||||||
|
state=6;
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case 6:{
|
||||||
|
DisplayBox("To allocate 5 bits, select the RAM bank and click the Memory Allocator button.\n\nGive it a try now.");
|
||||||
|
if(box.bPressed){
|
||||||
|
state=7;
|
||||||
|
box.SetVisible(false);
|
||||||
|
flags.playerInControl=true;
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case 7:{
|
||||||
|
for(auto&u:units){
|
||||||
|
if(u->IsAllocator()&&u->IsFriendly()){
|
||||||
|
state=8;
|
||||||
|
flags.playerInControl=false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case 8:{
|
||||||
|
DisplayBox("Now select the memory allocator and let's make a Shifter unit.");
|
||||||
|
if(box.bPressed){
|
||||||
|
state=9;
|
||||||
|
box.SetVisible(false);
|
||||||
|
flags.playerInControl=true;
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case 9:{
|
||||||
|
for(auto&u:units){
|
||||||
|
if(!u->IsAllocator()&&!u->IsRAMBank()&&u->IsFriendly()){
|
||||||
|
state=10;
|
||||||
|
flags.playerInControl=false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case 10:{
|
||||||
|
DisplayBox("The memory shifters will be your primary way to delete memory from units.");
|
||||||
|
if(box.bPressed){
|
||||||
|
state=11;
|
||||||
|
SOUNDS[Sound::ALARM]->PlayCentered();
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case 11:{
|
||||||
|
SetCameraTarget({22*24,23*24});
|
||||||
|
RevealTiles({22*24,23*24});
|
||||||
|
if(camera.ReachedTarget()){
|
||||||
|
state=12;
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case 12:{
|
||||||
|
SetObjective("Defeat all enemy units.");
|
||||||
|
DisplayBox("I have detected viruses in the system again. Please eradicate them and free system resources.");
|
||||||
|
if(box.bPressed){
|
||||||
|
state=13;
|
||||||
|
flags.playerInControl=true;
|
||||||
|
box.SetVisible(false);
|
||||||
|
}
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
bool Stage2::MissionCompleted(){
|
bool Stage2::MissionCompleted(){
|
||||||
|
for(auto&u:units){
|
||||||
|
if(!u->IsFriendly()){
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
Stage3::Stage3(std::vector<std::shared_ptr<Unit>>&units,std::vector<std::unique_ptr<Renderable>>&IMAGES,std::vector<std::unique_ptr<Audio>>&SOUNDS,std::string&objective,TileTransformedView&game,GameFlags&flags)
|
Stage3::Stage3(std::vector<std::shared_ptr<Unit>>&units,std::vector<std::unique_ptr<Renderable>>&IMAGES,std::vector<std::unique_ptr<Audio>>&SOUNDS,std::string&objective,TileTransformedView&game,GameFlags&flags)
|
||||||
:Scenario(units,IMAGES,SOUNDS,objective,game,flags){}
|
:Scenario(units,IMAGES,SOUNDS,objective,game,flags){}
|
||||||
|
@ -19,8 +19,9 @@ public:
|
|||||||
LevelName nextLevel=LevelName::STAGE1;
|
LevelName nextLevel=LevelName::STAGE1;
|
||||||
protected:
|
protected:
|
||||||
void DisplayBox(std::string text,bool scaryHoodedFigure=false);
|
void DisplayBox(std::string text,bool scaryHoodedFigure=false);
|
||||||
void SetCameraTarget(vf2d pos);
|
void SetCameraTarget(vf2d pos,bool instant=false);
|
||||||
void SetObjective(std::string objective);
|
void SetObjective(std::string objective);
|
||||||
|
void RevealTiles(vf2d pos);
|
||||||
virtual bool MissionCompleted();
|
virtual bool MissionCompleted();
|
||||||
virtual void Update();
|
virtual void Update();
|
||||||
int state=0;
|
int state=0;
|
||||||
@ -31,6 +32,7 @@ protected:
|
|||||||
bool missionCompleted=false;
|
bool missionCompleted=false;
|
||||||
float missionFinishWaitTime=3;
|
float missionFinishWaitTime=3;
|
||||||
float missionCompletedTimer=0;
|
float missionCompletedTimer=0;
|
||||||
|
float smallTimePass=0;
|
||||||
std::vector<std::shared_ptr<Unit>>&units;
|
std::vector<std::shared_ptr<Unit>>&units;
|
||||||
std::vector<std::unique_ptr<Renderable>>&IMAGES;
|
std::vector<std::unique_ptr<Renderable>>&IMAGES;
|
||||||
std::vector<std::unique_ptr<Audio>>&SOUNDS;
|
std::vector<std::unique_ptr<Audio>>&SOUNDS;
|
||||||
|
@ -9,5 +9,6 @@ namespace Sound{
|
|||||||
BOSS2,
|
BOSS2,
|
||||||
VOICEOVER,
|
VOICEOVER,
|
||||||
PING,
|
PING,
|
||||||
|
ALARM,
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -101,11 +101,12 @@ void VirusAttack::InitializeLevelData(){
|
|||||||
levelData[stage].name=stage;
|
levelData[stage].name=stage;
|
||||||
levelData[stage].cameraStart={96,96};
|
levelData[stage].cameraStart={96,96};
|
||||||
levelData[stage].worldZoom={1,1};
|
levelData[stage].worldZoom={1,1};
|
||||||
levelData[stage].levelColor=DARK_RED;
|
levelData[stage].levelColor=DARK_GREEN;
|
||||||
levelData[stage].size={24,24};
|
levelData[stage].size={24,24};
|
||||||
levelData[stage].bgm=Sound::GRAVITY;
|
levelData[stage].bgm=Sound::GRAVITY;
|
||||||
levelData[stage].scenarioIndex=int(stage);
|
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};
|
levelData[stage].enemy_starting_resources={0,0,0,0,0};
|
||||||
{
|
{
|
||||||
std::vector<UnitData>&units=levelData[stage].unitPlacement;
|
std::vector<UnitData>&units=levelData[stage].unitPlacement;
|
||||||
@ -124,19 +125,23 @@ void VirusAttack::InitializeLevelData(){
|
|||||||
levelData[stage].name=stage;
|
levelData[stage].name=stage;
|
||||||
levelData[stage].cameraStart={96,96};
|
levelData[stage].cameraStart={96,96};
|
||||||
levelData[stage].worldZoom={1,1};
|
levelData[stage].worldZoom={1,1};
|
||||||
levelData[stage].size={16,16};
|
levelData[stage].size={30,30};
|
||||||
levelData[stage].levelColor=DARK_GREEN;
|
levelData[stage].levelColor=DARK_GREEN;
|
||||||
levelData[stage].bgm=Sound::GRAVITY;
|
levelData[stage].bgm=Sound::GRAVITY;
|
||||||
levelData[stage].scenarioIndex=int(stage);
|
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};
|
levelData[stage].enemy_starting_resources={0,0,0,0,0};
|
||||||
{
|
{
|
||||||
std::vector<UnitData>&units=levelData[stage].unitPlacement;
|
std::vector<UnitData>&units=levelData[stage].unitPlacement;
|
||||||
std::vector<CPData>&collectionPoints=levelData[stage].cpPlacement;
|
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
|
#pragma endregion
|
||||||
@ -297,6 +302,7 @@ void VirusAttack::InitializeSounds(){
|
|||||||
LoadSound(Sound::BOSS2,"boss2.mp3");
|
LoadSound(Sound::BOSS2,"boss2.mp3");
|
||||||
LoadSound(Sound::VOICEOVER,"voice.mp3");
|
LoadSound(Sound::VOICEOVER,"voice.mp3");
|
||||||
LoadSound(Sound::PING,"ping.mp3");
|
LoadSound(Sound::PING,"ping.mp3");
|
||||||
|
LoadSound(Sound::ALARM,"alarm.mp3");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VirusAttack::UnitCreationClickHandled(){
|
bool VirusAttack::UnitCreationClickHandled(){
|
||||||
@ -326,9 +332,9 @@ bool VirusAttack::UnitCreationClickHandled(){
|
|||||||
CheckClick(MemoryGuard,memoryGuardButton,IsPlatform)
|
CheckClick(MemoryGuard,memoryGuardButton,IsPlatform)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#define EnableAndHoverCheck(UnitClass,Button,box,limited) \
|
#define EnableAndHoverCheck(UnitClass,Button,box,allowed) \
|
||||||
Button->Enable(CanAfford(player_resources,UnitClass::resourceCost)&&(!limited||limited&&!flags.limitedBuildOptions)); \
|
Button->Enable(CanAfford(player_resources,UnitClass::resourceCost)&&allowed); \
|
||||||
if(limited&&!flags.limitedBuildOptions){Button->bVisible=false;} \
|
if(!allowed){Button->bVisible=false;} \
|
||||||
if(Button->bHover){ \
|
if(Button->bHover){ \
|
||||||
box.Initialize(UnitClass::unitDescription, GetMousePos(), UnitClass::unitName,nullptr,{120,36},nullptr,UnitClass::resourceCost); \
|
box.Initialize(UnitClass::unitDescription, GetMousePos(), UnitClass::unitName,nullptr,{120,36},nullptr,UnitClass::resourceCost); \
|
||||||
hovering=true; \
|
hovering=true; \
|
||||||
@ -343,13 +349,13 @@ void VirusAttack::UpdateUnitCreationListGUI(bool allocatorSelected){
|
|||||||
unitCreationList.DisplayAllControls(allocatorSelected);
|
unitCreationList.DisplayAllControls(allocatorSelected);
|
||||||
|
|
||||||
bool hovering=false;
|
bool hovering=false;
|
||||||
EnableAndHoverCheck(LeftShifter,leftShifterButton,unitCreationBox,false)
|
EnableAndHoverCheck(LeftShifter,leftShifterButton,unitCreationBox,true)
|
||||||
EnableAndHoverCheck(RightShifter,rightShifterButton,unitCreationBox,false)
|
EnableAndHoverCheck(RightShifter,rightShifterButton,unitCreationBox,true)
|
||||||
EnableAndHoverCheck(BitRestorer,bitRestorerButton,unitCreationBox,true)
|
EnableAndHoverCheck(BitRestorer,bitRestorerButton,unitCreationBox,!flags.limitedBuildOptions)
|
||||||
EnableAndHoverCheck(MemorySwapper,memorySwapperButton,unitCreationBox,true)
|
EnableAndHoverCheck(MemorySwapper,memorySwapperButton,unitCreationBox,!flags.limitedBuildOptions)
|
||||||
EnableAndHoverCheck(BitRestorer,bitRestorerButton,unitCreationBox,true)
|
EnableAndHoverCheck(BitRestorer,bitRestorerButton,unitCreationBox,!flags.limitedBuildOptions)
|
||||||
EnableAndHoverCheck(Corrupter,corrupterButton,unitCreationBox,true)
|
EnableAndHoverCheck(Corrupter,corrupterButton,unitCreationBox,!flags.limitedBuildOptions)
|
||||||
EnableAndHoverCheck(_Platform,platformButton,unitCreationBox,true)
|
EnableAndHoverCheck(_Platform,platformButton,unitCreationBox,!flags.limitedBuildOptions)
|
||||||
|
|
||||||
if(!hovering){
|
if(!hovering){
|
||||||
unitCreationBox.SetVisible(false);
|
unitCreationBox.SetVisible(false);
|
||||||
@ -361,10 +367,10 @@ void VirusAttack::UpdateUnitCreationListGUI(bool allocatorSelected){
|
|||||||
void VirusAttack::UpdatePlatformCreationListGUI(bool platformSelected){
|
void VirusAttack::UpdatePlatformCreationListGUI(bool platformSelected){
|
||||||
platformCreationList.DisplayAllControls(platformSelected);
|
platformCreationList.DisplayAllControls(platformSelected);
|
||||||
bool hovering=false;
|
bool hovering=false;
|
||||||
EnableAndHoverCheck(RAMBank,ramBankButton,platformCreationBox,false)
|
EnableAndHoverCheck(RAMBank,ramBankButton,platformCreationBox,true)
|
||||||
EnableAndHoverCheck(Refresher,refresherButton,platformCreationBox,true)
|
EnableAndHoverCheck(Refresher,refresherButton,platformCreationBox,!flags.limitedBuildOptions)
|
||||||
EnableAndHoverCheck(Turret,turretButton,platformCreationBox,true)
|
EnableAndHoverCheck(Turret,turretButton,platformCreationBox,!flags.limitedBuildOptions)
|
||||||
EnableAndHoverCheck(MemoryGuard,memoryGuardButton,platformCreationBox,true)
|
EnableAndHoverCheck(MemoryGuard,memoryGuardButton,platformCreationBox,!flags.limitedBuildOptions)
|
||||||
|
|
||||||
if(!hovering){
|
if(!hovering){
|
||||||
platformCreationBox.SetVisible(false);
|
platformCreationBox.SetVisible(false);
|
||||||
@ -375,23 +381,6 @@ void VirusAttack::UpdatePlatformCreationListGUI(bool platformSelected){
|
|||||||
|
|
||||||
void VirusAttack::HandleDraggingSelection(){
|
void VirusAttack::HandleDraggingSelection(){
|
||||||
auto NotClickingOnMinimap=[&](){return !(GetMouseX()>=ScreenWidth()-64&&GetMouseY()>=ScreenHeight()-64);};
|
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(GetMouse(0).bPressed){
|
||||||
if(NotClickingOnMinimap()){
|
if(NotClickingOnMinimap()){
|
||||||
for(auto&u:units){
|
for(auto&u:units){
|
||||||
@ -777,12 +766,17 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
|
|||||||
#pragma endregion
|
#pragma endregion
|
||||||
#pragma region GAMEPLAY
|
#pragma region GAMEPLAY
|
||||||
case GameState::GAMEPLAY:{
|
case GameState::GAMEPLAY:{
|
||||||
|
HandleGUIDisplay();
|
||||||
if(flags.playerInControl){
|
if(flags.playerInControl){
|
||||||
HandleDraggingSelection();
|
HandleDraggingSelection();
|
||||||
HandleRightClickMove();
|
HandleRightClickMove();
|
||||||
HandlePanAndZoom(fElapsedTime);
|
HandlePanAndZoom(fElapsedTime);
|
||||||
HandleMinimapClick();
|
HandleMinimapClick();
|
||||||
}
|
}
|
||||||
|
flashTimer+=fElapsedTime*2;
|
||||||
|
if(flashTimer>1){
|
||||||
|
flashTimer--;
|
||||||
|
}
|
||||||
SCENARIOS[currentScenario]->_Update();
|
SCENARIOS[currentScenario]->_Update();
|
||||||
if(SCENARIOS[currentScenario]->transitionToNextLevel){
|
if(SCENARIOS[currentScenario]->transitionToNextLevel){
|
||||||
if(SCENARIOS[currentScenario]->nextLevel!=FINISH){
|
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);
|
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++){
|
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};
|
vf2d textPos=barPos+vf2d{barWidth+6+4,0};
|
||||||
if(GetTotalUsedMemory()>lastTotalMemory){
|
if(GetTotalUsedMemory()>lastTotalMemory){
|
||||||
memoryIncreased=true;
|
memoryIncreased=true;
|
||||||
@ -1272,6 +1266,26 @@ void VirusAttack::DrawCurvedTexture(vf2d offset,vf2d size,Decal*decal,vf2d texOf
|
|||||||
SetDecalStructure(DecalStructure::FAN);
|
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()
|
int main()
|
||||||
{
|
{
|
||||||
VirusAttack app;
|
VirusAttack app;
|
||||||
|
@ -108,12 +108,14 @@ public:
|
|||||||
float textOrientationX=0;
|
float textOrientationX=0;
|
||||||
int currentScenario=0;
|
int currentScenario=0;
|
||||||
GameFlags flags;
|
GameFlags flags;
|
||||||
|
float flashTimer=0;
|
||||||
|
|
||||||
std::string objective="";
|
std::string objective="";
|
||||||
|
|
||||||
vf2d randomBackgroundOffset;
|
vf2d randomBackgroundOffset;
|
||||||
|
|
||||||
vf2d startingDragPos=CONSTANT::UNSELECTED;
|
vf2d startingDragPos=CONSTANT::UNSELECTED;
|
||||||
|
void HandleGUIDisplay();
|
||||||
void HandleDraggingSelection();
|
void HandleDraggingSelection();
|
||||||
void DrawSelectionRectangle();
|
void DrawSelectionRectangle();
|
||||||
void HandleRightClickMove();
|
void HandleRightClickMove();
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 576 B After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 23 MiB After Width: | Height: | Size: 24 MiB |
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user