diff --git a/olcCodeJam2023Entry/Unit.cpp b/olcCodeJam2023Entry/Unit.cpp index 2807243..75dbeb2 100644 --- a/olcCodeJam2023Entry/Unit.cpp +++ b/olcCodeJam2023Entry/Unit.cpp @@ -64,7 +64,7 @@ BitRestorer::BitRestorer(vf2d pos,std::map>&IM {ATKSPD,1}, {MOVESPD,1}, {HEALTH,2}, - },pos,12,*IMAGES[BIT_RESTORER],friendly,moveable){} + },pos,12,*IMAGES[BIT_RESTORER],friendly,moveable,true,false){} void BitRestorer::Attack(Unit&victim){ @@ -77,7 +77,7 @@ MemorySwapper::MemorySwapper(vf2d pos,std::map {HEALTH,3}, {PROCEDURE,3}, {MOVESPD,2}, - },pos,12,*IMAGES[MEMORY_SWAPPER],friendly,moveable){} + },pos,12,*IMAGES[MEMORY_SWAPPER],friendly,moveable,true){} void MemorySwapper::Attack(Unit&victim){ @@ -103,7 +103,7 @@ MemoryAllocator::MemoryAllocator(vf2d pos,std::mapSprite()->width,IMAGES[RAM_BANK]->Sprite()->height); pge->SetDrawTarget(img.Sprite()); @@ -150,8 +152,8 @@ void RAMBank::Draw(TileTransformedView&game,std::mapmemory,vf2d pos,float radius,Renderable&img,bool friendly,bool moveable) -:pos(pos),radius(radius),ghostPos(pos),img(img),friendly(friendly),moveable(moveable){ +Unit::Unit(std::vectormemory,vf2d pos,float radius,Renderable&img,bool friendly,bool moveable,bool friendlyInteractable,bool enemyInteractable) +:pos(pos),radius(radius),ghostPos(pos),img(img),friendly(friendly),moveable(moveable),friendlyInteractable(friendlyInteractable),enemyInteractable(enemyInteractable){ int marker=0; for(Memory&mem:memory){ for(int i=0;imemory,vf2d pos,float radius,Renderable&img,bool f } void Unit::DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::map>&IMAGES){ + if(!CanInteractWithAllies()&&!CanInteractWithEnemies())return; float dist=geom2d::line(game.ScreenToWorld(pge->GetMousePos()),GetGhostPos()).length(); float range=12*(GetRange()+1); float totalRange=GetUnitSize().x/2+range; if(IsSelected()){ - game.DrawRotatedDecal(GetGhostPos(),IMAGES[RANGE_INDICATOR]->Decal(),0,IMAGES[RANGE_INDICATOR]->Sprite()->Size()/2,{totalRange/12,totalRange/12},{0,196,0,128}); + Pixel col; + if(CanInteractWithAllies()&&!CanInteractWithEnemies()){ + col={40,127,173}; + } else { + col={0,196,0}; + } + game.DrawRotatedDecal(GetGhostPos(),IMAGES[RANGE_INDICATOR]->Decal(),0,IMAGES[RANGE_INDICATOR]->Sprite()->Size()/2,{totalRange/12,totalRange/12},col); }else if(distDecal(),0,IMAGES[RANGE_INDICATOR]->Sprite()->Size()/2,{totalRange/12,totalRange/12},{col.r,col.g,col.b,uint8_t((1.f-(dist/(range*2)))*128)}); + game.DrawRotatedDecal(GetGhostPos(),IMAGES[RANGE_INDICATOR]->Decal(),0,IMAGES[RANGE_INDICATOR]->Sprite()->Size()/2,{totalRange/12,totalRange/12},{col.r,col.g,col.b,uint8_t((1.f-(dist/(range*2)))*255)}); } } @@ -446,4 +463,12 @@ vf2d Unit::GetGhostPos(){ bool Unit::IsMoveable(){ return moveable; +} + +bool Unit::CanInteractWithAllies(){ + return friendlyInteractable; +} + +bool Unit::CanInteractWithEnemies(){ + return enemyInteractable; } \ No newline at end of file diff --git a/olcCodeJam2023Entry/Unit.h b/olcCodeJam2023Entry/Unit.h index 380381f..82a51bc 100644 --- a/olcCodeJam2023Entry/Unit.h +++ b/olcCodeJam2023Entry/Unit.h @@ -25,7 +25,7 @@ struct Memory{ struct Unit{ public: - Unit(std::vectormemory,vf2d pos,float radius,Renderable&img,bool friendly=false,bool moveable=true); + Unit(std::vectormemory,vf2d pos,float radius,Renderable&img,bool friendly=false,bool moveable=true,bool friendlyInteractable=false,bool enemyInteractable=true); int GetHealth(); int GetRange(); int GetAtkSpd(); @@ -56,6 +56,8 @@ public: void _Update(PixelGameEngine*pge); bool IsMoveable(); void DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::map>&IMAGES); + bool CanInteractWithEnemies(); + bool CanInteractWithAllies(); std::vector& operator <<=(const int n){ for(int i=0;i(u1->GetGhostPos(),GetWorldMousePos()).length(); + float dist2=geom2d::line(u2->GetGhostPos(),GetWorldMousePos()).length(); + return dist1>dist2;}); + return true; } diff --git a/olcCodeJam2023Entry/assets/range_indicator.png b/olcCodeJam2023Entry/assets/range_indicator.png index a959b65..5800ab4 100644 Binary files a/olcCodeJam2023Entry/assets/range_indicator.png and b/olcCodeJam2023Entry/assets/range_indicator.png differ