Final changes. Show timer as hh:mm:ss, fix tutorial bug using AI routine, fix bug enemy units attacking themselves.

master
sigonasr2 1 year ago
parent 032801f3e8
commit 3704c1e18c
  1. 2
      olcCodeJam2023Entry/Scenario.cpp
  2. 3
      olcCodeJam2023Entry/Unit.cpp
  3. 14
      olcCodeJam2023Entry/VirusAttack.cpp
  4. 1
      olcCodeJam2023Entry/VirusAttack.h

@ -41,6 +41,8 @@ void Scenario::_Update(Resources&enemy_resources,std::vector<std::shared_ptr<Col
}
};
void Scenario::RunAI(Resources&enemy_resources,std::vector<std::shared_ptr<CollectionPoint>>&collectionPoints,int availableMemory,std::vector<std::shared_ptr<Unit>>&queuedUnits,std::vector<std::unique_ptr<Audio>>&SOUNDS){
if(!flags.guideEnabled||flags.limitedBuildOptions||flags.unitMetersGreyedOut)return; //We don't enable advanced AI during tutorials.
if(!setupEasyMode&&flags.difficulty==0){
enemy_resources={100,100,100,100,100};
}

@ -945,6 +945,9 @@ void Unit::_Attacked(std::weak_ptr<Unit>attacker,std::vector<std::shared_ptr<Uni
if(attacker.lock()->IsFriendly()!=IsFriendly()&&CanInteractWithEnemies()){
SetTargetUnit(attacker);
}
if(!IsFriendly()&&!attacker.lock()->IsFriendly()&&!attacker.lock()->CanInteractWithAllies()){
attacker.lock()->SetTargetLocation(attacker.lock()->GetPos()); //This effectively negates enemies targeting each other for attacking if they're not supposed to. Somehow this occurs sometimes.
}
if(attacker.lock()->IsFriendly()!=IsFriendly()){
for(auto&u:otherUnits){
if(this!=u.get()&&!u->IsFriendly()&&u->GetCurrentTarget().expired()&&u->CanMove()&&!u->IsAllocator()){

@ -1393,7 +1393,8 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
#pragma region COMPLETED
case GameState::COMPLETED:{
DrawPartialDecal({0,0},GetScreenSize(),IMAGES[MATRIX]->Decal(),randomBackgroundOffset+gametv.GetWorldOffset()*(vf2d{32,32}/vf2d(GetScreenSize()))*gametv.GetWorldScale(),{32,32},Pixel{currentLevel->levelColor.r,currentLevel->levelColor.g,currentLevel->levelColor.b,164}/2);
completedBox.Initialize("Thank you for playing Virus Attack!\n\nCompletion Time:"+std::to_string(gameSeconds)+" seconds\n\nHuge shoutout to the OLC community, javidx9 for the PGE, and all supporters!\n\n\nPress [Escape] to return to the main menu.",{0,0},"Congratulations!",nullptr,{float(ScreenWidth()-2),1.f});
completedBox.Initialize("Thank you for playing Virus Attack!\n\nCompletion Time:"+DisplayTime(gameSeconds)+" seconds\nDifficulty Completed:\n+"+(flags.difficulty==0?"Easy":flags.difficulty==1?"Normal":"Hard")+"+\n\nHuge shoutout to the OLC community, javidx9 for the PGE existing, and all supporters!\n\n\nPress [Escape] to return to the main menu.",{0,0},"Congratulations!",nullptr,{float(ScreenWidth()-2),1.f});
completedBox.UpdateAndDraw({0,0},this,player_resources,IMAGES,GetTotalUsedMemory(),currentLevel->availableMemory);
if(GetKey(ESCAPE).bPressed){
state=GameState::MAIN_MENU;
@ -1408,6 +1409,17 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
return true;
}
std::string VirusAttack::DisplayTime(int gameSeconds){
int totalMinutes=gameSeconds/60;
int totalHours=totalMinutes/60;
std::string secondsDisplay=std::to_string(gameSeconds%60);
std::string minutesDisplay=std::to_string(totalMinutes%60);
std::string hoursDisplay=std::to_string(totalHours);
return hoursDisplay+":"+((minutesDisplay.length()==1)?"0":"")+minutesDisplay+":"+((secondsDisplay.length()==1)?"0":"")+secondsDisplay;
}
void VirusAttack::DrawSystemMemoryBar(float fElapsedTime){
memoryChangeTimer=std::max(0.f,memoryChangeTimer-fElapsedTime);
memoryDisplayDelay-=fElapsedTime;

@ -155,6 +155,7 @@ public:
void RestartLevel();
void HandleRestartButton(float fElapsedTime);
void DrawCurvedTexture(vf2d offset,vf2d size,Decal*decal,vf2d texOffset,Pixel col=WHITE,float curveThickness=0.8);
std::string DisplayTime(int gameSeconds);
public:
VirusAttack();

Loading…
Cancel
Save