diff --git a/olcCodeJam2023Entry/Constant.cpp b/olcCodeJam2023Entry/Constant.cpp index aaa0c49..e960992 100644 --- a/olcCodeJam2023Entry/Constant.cpp +++ b/olcCodeJam2023Entry/Constant.cpp @@ -24,4 +24,6 @@ Pixel CONSTANT::ATTACKER_ATTACK_COL={171, 0, 0, 220}; Pixel CONSTANT::HEALER_TARGET_COL={0, 134, 230, 196}; Pixel CONSTANT::HEALER_ATTACK_COL={91, 222, 104, 220}; -float CONSTANT::DEBUFFICON_LIFETIME=0.8; \ No newline at end of file +float CONSTANT::DEBUFFICON_LIFETIME=0.8; + +float CONSTANT::COLLECTION_WAIT_TIME=8; \ No newline at end of file diff --git a/olcCodeJam2023Entry/Constant.h b/olcCodeJam2023Entry/Constant.h index edfdf0e..1dbd810 100644 --- a/olcCodeJam2023Entry/Constant.h +++ b/olcCodeJam2023Entry/Constant.h @@ -29,4 +29,6 @@ public: static Pixel HEALER_ATTACK_COL; static float DEBUFFICON_LIFETIME; + + static float COLLECTION_WAIT_TIME; }; \ No newline at end of file diff --git a/olcCodeJam2023Entry/Resources.h b/olcCodeJam2023Entry/Resources.h new file mode 100644 index 0000000..ea315c2 --- /dev/null +++ b/olcCodeJam2023Entry/Resources.h @@ -0,0 +1,10 @@ +#pragma once + + +struct Resources{ + int health=0; + int atkSpd=0; + int moveSpd=0; + int range=0; + int procedure=0; +}; \ No newline at end of file diff --git a/olcCodeJam2023Entry/Unit.cpp b/olcCodeJam2023Entry/Unit.cpp index 714bf64..a0d49e5 100644 --- a/olcCodeJam2023Entry/Unit.cpp +++ b/olcCodeJam2023Entry/Unit.cpp @@ -431,7 +431,7 @@ void Unit::_RunAI(PixelGameEngine*pge){ RunAI(pge); } -void Unit::_Update(PixelGameEngine*pge,std::map>&SOUNDS){ +void Unit::_Update(PixelGameEngine*pge,std::map>&SOUNDS,Resources&player_resources,Resources&enemy_resources){ if(!target.expired()){ auto ptrTarget=target.lock(); if(!InRange(ptrTarget)){ @@ -452,6 +452,31 @@ void Unit::_Update(PixelGameEngine*pge,std::map>&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()){ _RunAI(pge); } diff --git a/olcCodeJam2023Entry/Unit.h b/olcCodeJam2023Entry/Unit.h index c1cd72e..896f105 100644 --- a/olcCodeJam2023Entry/Unit.h +++ b/olcCodeJam2023Entry/Unit.h @@ -10,6 +10,7 @@ #include "DebuffIcon.h" #include "CollectionPoint.h" #include "MemoryType.h" +#include "Resources.h" struct Marker{ size_t index; @@ -52,7 +53,7 @@ public: bool GhostInFogOfWar(); void HideGhost(); vf2d GetGhostPos(); - void _Update(PixelGameEngine*pge,std::map>&SOUNDS); + void _Update(PixelGameEngine*pge,std::map>&SOUNDS,Resources&player_resources,Resources&enemy_resources); bool IsMoveable(); void DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::map>&IMAGES); bool CanInteractWithEnemies(); @@ -127,6 +128,7 @@ private: std::weak_ptrattachTarget; bool willAttachWhenReachingDestination=false; std::weak_ptrself_ptr; + float collectionTime=0; }; struct BasicUnit:Unit{ diff --git a/olcCodeJam2023Entry/VirusAttack.cpp b/olcCodeJam2023Entry/VirusAttack.cpp index be5bf4c..905f892 100644 --- a/olcCodeJam2023Entry/VirusAttack.cpp +++ b/olcCodeJam2023Entry/VirusAttack.cpp @@ -382,7 +382,7 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ } } 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_ptru){ diff --git a/olcCodeJam2023Entry/VirusAttack.h b/olcCodeJam2023Entry/VirusAttack.h index 3017654..44ba55f 100644 --- a/olcCodeJam2023Entry/VirusAttack.h +++ b/olcCodeJam2023Entry/VirusAttack.h @@ -10,6 +10,7 @@ #include "Sound.h" #include "DebuffIcon.h" #include "CollectionPoint.h" +#include "Resources.h" struct Letter{ vf2d pos; @@ -17,14 +18,6 @@ struct Letter{ char c; }; -struct Resources{ - int health=0; - int atkSpd=0; - int moveSpd=0; - int range=0; - int procedure=0; -}; - class VirusAttack : public olc::PixelGameEngine { private: diff --git a/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj b/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj index d4f0a74..92b2a21 100644 --- a/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj +++ b/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj @@ -157,6 +157,7 @@ + diff --git a/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj.filters b/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj.filters index afd5b60..7095515 100644 --- a/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj.filters +++ b/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj.filters @@ -87,6 +87,9 @@ Header Files + + Header Files +