Attaching to collection points now awards resources.

CorrectiveAction
sigonasr2 1 year ago
parent b7ab91a3e8
commit d418690556
  1. 2
      olcCodeJam2023Entry/Constant.cpp
  2. 2
      olcCodeJam2023Entry/Constant.h
  3. 10
      olcCodeJam2023Entry/Resources.h
  4. 27
      olcCodeJam2023Entry/Unit.cpp
  5. 4
      olcCodeJam2023Entry/Unit.h
  6. 2
      olcCodeJam2023Entry/VirusAttack.cpp
  7. 9
      olcCodeJam2023Entry/VirusAttack.h
  8. 1
      olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj
  9. 3
      olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj.filters

@ -25,3 +25,5 @@ Pixel CONSTANT::HEALER_TARGET_COL={0, 134, 230, 196};
Pixel CONSTANT::HEALER_ATTACK_COL={91, 222, 104, 220}; Pixel CONSTANT::HEALER_ATTACK_COL={91, 222, 104, 220};
float CONSTANT::DEBUFFICON_LIFETIME=0.8; float CONSTANT::DEBUFFICON_LIFETIME=0.8;
float CONSTANT::COLLECTION_WAIT_TIME=8;

@ -29,4 +29,6 @@ public:
static Pixel HEALER_ATTACK_COL; static Pixel HEALER_ATTACK_COL;
static float DEBUFFICON_LIFETIME; static float DEBUFFICON_LIFETIME;
static float COLLECTION_WAIT_TIME;
}; };

@ -0,0 +1,10 @@
#pragma once
struct Resources{
int health=0;
int atkSpd=0;
int moveSpd=0;
int range=0;
int procedure=0;
};

@ -431,7 +431,7 @@ void Unit::_RunAI(PixelGameEngine*pge){
RunAI(pge); RunAI(pge);
} }
void Unit::_Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SOUNDS){ void Unit::_Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SOUNDS,Resources&player_resources,Resources&enemy_resources){
if(!target.expired()){ if(!target.expired()){
auto ptrTarget=target.lock(); auto ptrTarget=target.lock();
if(!InRange(ptrTarget)){ if(!InRange(ptrTarget)){
@ -452,6 +452,31 @@ void Unit::_Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SO
} }
} }
if(!attachedPoint.expired()){
collectionTime-=pge->GetElapsedTime();
if(collectionTime<=0){
collectionTime=CONSTANT::COLLECTION_WAIT_TIME;
Resources&targetResource=IsFriendly()?player_resources:enemy_resources;
switch(attachedPoint.lock()->type){
case HEALTH:{
targetResource.health++;
}break;
case RANGE:{
targetResource.range++;
}break;
case ATKSPD:{
targetResource.atkSpd++;
}break;
case MOVESPD:{
targetResource.moveSpd++;
}break;
case PROCEDURE:{
targetResource.procedure++;
}break;
}
}
}
if(!IsFriendly()){ if(!IsFriendly()){
_RunAI(pge); _RunAI(pge);
} }

@ -10,6 +10,7 @@
#include "DebuffIcon.h" #include "DebuffIcon.h"
#include "CollectionPoint.h" #include "CollectionPoint.h"
#include "MemoryType.h" #include "MemoryType.h"
#include "Resources.h"
struct Marker{ struct Marker{
size_t index; size_t index;
@ -52,7 +53,7 @@ public:
bool GhostInFogOfWar(); bool GhostInFogOfWar();
void HideGhost(); void HideGhost();
vf2d GetGhostPos(); vf2d GetGhostPos();
void _Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SOUNDS); void _Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SOUNDS,Resources&player_resources,Resources&enemy_resources);
bool IsMoveable(); bool IsMoveable();
void DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::map<Image,std::unique_ptr<Renderable>>&IMAGES); void DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::map<Image,std::unique_ptr<Renderable>>&IMAGES);
bool CanInteractWithEnemies(); bool CanInteractWithEnemies();
@ -127,6 +128,7 @@ private:
std::weak_ptr<CollectionPoint>attachTarget; std::weak_ptr<CollectionPoint>attachTarget;
bool willAttachWhenReachingDestination=false; bool willAttachWhenReachingDestination=false;
std::weak_ptr<Unit>self_ptr; std::weak_ptr<Unit>self_ptr;
float collectionTime=0;
}; };
struct BasicUnit:Unit{ struct BasicUnit:Unit{

@ -382,7 +382,7 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
} }
} }
u->AttemptAttack(u,closestUnit,units,debuffIcons,IMAGES); u->AttemptAttack(u,closestUnit,units,debuffIcons,IMAGES);
u->_Update(this,SOUNDS); u->_Update(this,SOUNDS,player_resources,enemy_resources);
} }
std::erase_if(units,[&](std::shared_ptr<Unit>u){ std::erase_if(units,[&](std::shared_ptr<Unit>u){

@ -10,6 +10,7 @@
#include "Sound.h" #include "Sound.h"
#include "DebuffIcon.h" #include "DebuffIcon.h"
#include "CollectionPoint.h" #include "CollectionPoint.h"
#include "Resources.h"
struct Letter{ struct Letter{
vf2d pos; vf2d pos;
@ -17,14 +18,6 @@ struct Letter{
char c; char c;
}; };
struct Resources{
int health=0;
int atkSpd=0;
int moveSpd=0;
int range=0;
int procedure=0;
};
class VirusAttack : public olc::PixelGameEngine class VirusAttack : public olc::PixelGameEngine
{ {
private: private:

@ -157,6 +157,7 @@
<ClInclude Include="olcUTIL_Geometry2D.h" /> <ClInclude Include="olcUTIL_Geometry2D.h" />
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />
<ClInclude Include="resource1.h" /> <ClInclude Include="resource1.h" />
<ClInclude Include="Resources.h" />
<ClInclude Include="Sound.h" /> <ClInclude Include="Sound.h" />
<ClInclude Include="TileManager.h" /> <ClInclude Include="TileManager.h" />
<ClInclude Include="Unit.h" /> <ClInclude Include="Unit.h" />

@ -87,6 +87,9 @@
<ClInclude Include="MemoryType.h"> <ClInclude Include="MemoryType.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Resources.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="VirusAttack.cpp"> <ClCompile Include="VirusAttack.cpp">

Loading…
Cancel
Save