diff --git a/olcCodeJam2023Entry/Unit.cpp b/olcCodeJam2023Entry/Unit.cpp index a0152c0..4d583db 100644 --- a/olcCodeJam2023Entry/Unit.cpp +++ b/olcCodeJam2023Entry/Unit.cpp @@ -5,6 +5,8 @@ #include "DebuffIcon.h" #include "olcPGEX_QuickGUI.h" +std::string BasicUnit::unitName=""; +std::string BasicUnit::unitDescription=""; std::vector BasicUnit::resourceCost={{HEALTH,4},{RANGE,2},{ATKSPD,2},{MOVESPD,3},{PROCEDURE,1}}; BasicUnit::BasicUnit(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) :Unit(pge,BasicUnit::resourceCost,pos,12,*IMAGES[VIRUS_IMG1],WHITE,WHITE,friendly,moveable){} @@ -14,6 +16,8 @@ void BasicUnit::Attack(Unit&victim,std::vector>&otherUnits victim<<=1; } +std::string BasicUnit2::unitName=""; +std::string BasicUnit2::unitDescription=""; std::vector BasicUnit2::resourceCost={{RANGE,2},{ATKSPD,2},{MOVESPD,3},{PROCEDURE,1},{HEALTH,4}}; BasicUnit2::BasicUnit2(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) :Unit(pge,BasicUnit2::resourceCost,pos,12,*IMAGES[VIRUS_IMG1],WHITE,WHITE,friendly,moveable){} @@ -22,6 +26,8 @@ void BasicUnit2::Attack(Unit&victim,std::vector>&otherUnit victim>>=1; } +std::string LeftShifter::unitName="Left Shifter"; +std::string LeftShifter::unitDescription="Memory Shifts target memory 1 bit to the left"; std::vector LeftShifter::resourceCost={{RANGE,2},{ATKSPD,2},{MOVESPD,3},{PROCEDURE,1},{HEALTH,4}}; LeftShifter::LeftShifter(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) :Unit(pge,LeftShifter::resourceCost,pos,12,*IMAGES[LEFT_SHIFTER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} @@ -30,6 +36,8 @@ void LeftShifter::Attack(Unit&victim,std::vector>&otherUni victim<<=1; } +std::string RightShifter::unitName="Right Shifter"; +std::string RightShifter::unitDescription="Memory Shifts target memory 1 bit to the right"; std::vector RightShifter::resourceCost={{HEALTH,4},{RANGE,2},{ATKSPD,2},{MOVESPD,3},{PROCEDURE,1}}; RightShifter::RightShifter(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) :Unit(pge,RightShifter::resourceCost,pos,12,*IMAGES[RIGHT_SHIFTER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} @@ -38,6 +46,8 @@ void RightShifter::Attack(Unit&victim,std::vector>&otherUn victim>>=1; } +std::string BitRestorer::unitName="Bit Restorer"; +std::string BitRestorer::unitDescription="Randomly restores 1 missing bit to a target"; std::vector BitRestorer::resourceCost={{PROCEDURE,6},{RANGE,1},{ATKSPD,1},{MOVESPD,1},{HEALTH,2}}; BitRestorer::BitRestorer(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) :Unit(pge,BitRestorer::resourceCost,pos,12,*IMAGES[BIT_RESTORER],CONSTANT::HEALER_TARGET_COL,CONSTANT::HEALER_ATTACK_COL,friendly,moveable,true,false){} @@ -78,6 +88,8 @@ void BitRestorer::AttemptToHealOtherAllies(std::vector>&ot } } +std::string MemorySwapper::unitName="Memory Swapper"; +std::string MemorySwapper::unitDescription="Flips the orientation of all bits of a target around."; std::vector MemorySwapper::resourceCost={{RANGE,3},{ATKSPD,1},{HEALTH,3},{PROCEDURE,3},{MOVESPD,2}}; MemorySwapper::MemorySwapper(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) :Unit(pge,MemorySwapper::resourceCost,pos,12,*IMAGES[MEMORY_SWAPPER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable,true){ @@ -88,6 +100,8 @@ void MemorySwapper::Attack(Unit&victim,std::vector>&otherU } +std::string Corrupter::unitName="Corrupter"; +std::string Corrupter::unitDescription="Chooses a random bit and negates it on a target."; std::vector Corrupter::resourceCost={{ATKSPD,3},{RANGE,1},{PROCEDURE,8},{MOVESPD,4},{HEALTH,4}}; Corrupter::Corrupter(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) :Unit(pge,Corrupter::resourceCost,pos,12,*IMAGES[CORRUPTER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} @@ -98,6 +112,8 @@ void Corrupter::Attack(Unit&victim,std::vector>&otherUnits victim.memory[randomBit]=victim.ghostMemory[randomBit]=false; } +std::string MemoryAllocator::unitName="Memory Allocator"; +std::string MemoryAllocator::unitDescription="A unit that builds other units."; std::vector MemoryAllocator::resourceCost={{RANGE,1},{ATKSPD,1},{MOVESPD,1},{PROCEDURE,1},{HEALTH,1}}; MemoryAllocator::MemoryAllocator(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) :Unit(pge,MemoryAllocator::resourceCost,pos,12,*IMAGES[UNIT_ALLOCATOR],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,true,false){ @@ -110,6 +126,8 @@ void MemoryAllocator::Attack(Unit&victim,std::vector>&othe void MemoryAllocator::Update(PixelGameEngine*pge,std::map>&SOUNDS,std::vector>&queuedUnits){ if(IsBuilding()){ + SetTargetLocation(CONSTANT::UNSELECTED); + target.reset(); buildTime-=pge->GetElapsedTime(); if(buildTime<=0){ for(int i=0;i RAMBank::resourceCost={{RANGE,0},{ATKSPD,0},{MOVESPD,0},{PROCEDURE,25},{HEALTH,16}}; RAMBank::RAMBank(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly) :Unit(pge,RAMBank::resourceCost,pos,41,*IMAGES[RAM_BANK],WHITE,WHITE,friendly,false @@ -150,14 +170,6 @@ RAMBank::RAMBank(PixelGameEngine*pge,vf2d pos,std::mapClear(BLANK); pge->DrawSprite({0,0},IMAGES[RAM_BANK]->Sprite()); pge->SetDrawTarget(nullptr); - /* - olc::Pixel colNormal = olc::DARK_BLUE; - olc::Pixel colHover = olc::BLUE; - olc::Pixel colClick = olc::CYAN; - olc::Pixel colDisable = olc::DARK_GREY; - olc::Pixel colBorder = olc::WHITE; - olc::Pixel colText = olc::WHITE; - */ allocatorManager.colNormal = olc::VERY_DARK_GREEN; allocatorManager.colHover = olc::GREEN; allocatorManager.colClick = olc::YELLOW; diff --git a/olcCodeJam2023Entry/Unit.h b/olcCodeJam2023Entry/Unit.h index 68fcc62..9d0f6c2 100644 --- a/olcCodeJam2023Entry/Unit.h +++ b/olcCodeJam2023Entry/Unit.h @@ -145,24 +145,32 @@ struct BasicUnit:Unit{ BasicUnit(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); void Attack(Unit&victim,std::vector>&otherUnits)override; static std::vector resourceCost; + static std::string unitName; + static std::string unitDescription; }; struct BasicUnit2:Unit{ BasicUnit2(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); void Attack(Unit&victim,std::vector>&otherUnits)override; static std::vector resourceCost; + static std::string unitName; + static std::string unitDescription; }; struct LeftShifter:Unit{ LeftShifter(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); void Attack(Unit&victim,std::vector>&otherUnits)override; static std::vector resourceCost; + static std::string unitName; + static std::string unitDescription; }; struct RightShifter:Unit{ RightShifter(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); void Attack(Unit&victim,std::vector>&otherUnits)override; static std::vector resourceCost; + static std::string unitName; + static std::string unitDescription; }; struct BitRestorer:Unit{ @@ -170,18 +178,24 @@ struct BitRestorer:Unit{ void Attack(Unit&victim,std::vector>&otherUnits)override; void AttemptToHealOtherAllies(std::vector>&otherUnits); static std::vector resourceCost; + static std::string unitName; + static std::string unitDescription; }; struct MemorySwapper:Unit{ MemorySwapper(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); void Attack(Unit&victim,std::vector>&otherUnits)override; static std::vector resourceCost; + static std::string unitName; + static std::string unitDescription; }; struct Corrupter:Unit{ Corrupter(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); void Attack(Unit&victim,std::vector>&otherUnits)override; static std::vector resourceCost; + static std::string unitName; + static std::string unitDescription; }; struct MemoryAllocator:Unit{ @@ -190,6 +204,8 @@ struct MemoryAllocator:Unit{ void Update(PixelGameEngine*pge,std::map>&SOUNDS,std::vector>&queuedUnits)override; void Draw(TileTransformedView&game,std::map>&IMAGES)override; static std::vector resourceCost; + static std::string unitName; + static std::string unitDescription; }; struct RAMBank:Unit{ @@ -210,4 +226,6 @@ struct RAMBank:Unit{ void UpdateGUIState(TileTransformedView&game,Resources&player_resources)override; void DrawHud(TileTransformedView&game,std::map>&IMAGES)override; static std::vector resourceCost; + static std::string unitName; + static std::string unitDescription; }; \ No newline at end of file