|
|
|
@ -11,7 +11,7 @@ BasicUnit::BasicUnit(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES |
|
|
|
|
{ATKSPD,2}, |
|
|
|
|
{MOVESPD,3}, |
|
|
|
|
{PROCEDURE,1}, |
|
|
|
|
},pos,*IMAGES[VIRUS_IMG1],friendly,moveable){} |
|
|
|
|
},pos,12,*IMAGES[VIRUS_IMG1],friendly,moveable){} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BasicUnit::Attack(Unit&victim){ |
|
|
|
@ -25,7 +25,7 @@ BasicUnit2::BasicUnit2(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAG |
|
|
|
|
{MOVESPD,3}, |
|
|
|
|
{PROCEDURE,1}, |
|
|
|
|
{HEALTH,4}, |
|
|
|
|
},pos,*IMAGES[VIRUS_IMG1],friendly,moveable){} |
|
|
|
|
},pos,12,*IMAGES[VIRUS_IMG1],friendly,moveable){} |
|
|
|
|
|
|
|
|
|
void BasicUnit2::Attack(Unit&victim){ |
|
|
|
|
victim>>=1; |
|
|
|
@ -38,7 +38,7 @@ LeftShifter::LeftShifter(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IM |
|
|
|
|
{MOVESPD,3}, |
|
|
|
|
{PROCEDURE,1}, |
|
|
|
|
{HEALTH,4}, |
|
|
|
|
},pos,*IMAGES[LEFT_SHIFTER],friendly,moveable){} |
|
|
|
|
},pos,12,*IMAGES[LEFT_SHIFTER],friendly,moveable){} |
|
|
|
|
|
|
|
|
|
void LeftShifter::Attack(Unit&victim){ |
|
|
|
|
victim<<=1; |
|
|
|
@ -51,7 +51,7 @@ RightShifter::RightShifter(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>& |
|
|
|
|
{ATKSPD,2}, |
|
|
|
|
{MOVESPD,3}, |
|
|
|
|
{PROCEDURE,1}, |
|
|
|
|
},pos,*IMAGES[RIGHT_SHIFTER],friendly,moveable){} |
|
|
|
|
},pos,12,*IMAGES[RIGHT_SHIFTER],friendly,moveable){} |
|
|
|
|
|
|
|
|
|
void RightShifter::Attack(Unit&victim){ |
|
|
|
|
victim>>=1; |
|
|
|
@ -64,7 +64,7 @@ BitRestorer::BitRestorer(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IM |
|
|
|
|
{ATKSPD,1}, |
|
|
|
|
{MOVESPD,1}, |
|
|
|
|
{HEALTH,2}, |
|
|
|
|
},pos,*IMAGES[BIT_RESTORER],friendly,moveable){} |
|
|
|
|
},pos,12,*IMAGES[BIT_RESTORER],friendly,moveable){} |
|
|
|
|
|
|
|
|
|
void BitRestorer::Attack(Unit&victim){ |
|
|
|
|
|
|
|
|
@ -77,7 +77,7 @@ MemorySwapper::MemorySwapper(vf2d pos,std::map<Image,std::unique_ptr<Renderable> |
|
|
|
|
{HEALTH,3}, |
|
|
|
|
{PROCEDURE,3}, |
|
|
|
|
{MOVESPD,2}, |
|
|
|
|
},pos,*IMAGES[MEMORY_SWAPPER],friendly,moveable){} |
|
|
|
|
},pos,12,*IMAGES[MEMORY_SWAPPER],friendly,moveable){} |
|
|
|
|
|
|
|
|
|
void MemorySwapper::Attack(Unit&victim){ |
|
|
|
|
|
|
|
|
@ -90,7 +90,7 @@ Corrupter::Corrupter(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES |
|
|
|
|
{PROCEDURE,8}, |
|
|
|
|
{MOVESPD,4}, |
|
|
|
|
{HEALTH,4}, |
|
|
|
|
},pos,*IMAGES[CORRUPTER],friendly,moveable){} |
|
|
|
|
},pos,12,*IMAGES[CORRUPTER],friendly,moveable){} |
|
|
|
|
|
|
|
|
|
void Corrupter::Attack(Unit&victim){ |
|
|
|
|
|
|
|
|
@ -103,7 +103,7 @@ MemoryAllocator::MemoryAllocator(vf2d pos,std::map<Image,std::unique_ptr<Rendera |
|
|
|
|
{MOVESPD,1}, |
|
|
|
|
{PROCEDURE,1}, |
|
|
|
|
{HEALTH,1}, |
|
|
|
|
},pos,*IMAGES[UNIT_ALLOCATOR],friendly){} |
|
|
|
|
},pos,12,*IMAGES[UNIT_ALLOCATOR],friendly){} |
|
|
|
|
|
|
|
|
|
void MemoryAllocator::Attack(Unit&victim){ |
|
|
|
|
|
|
|
|
@ -116,7 +116,7 @@ RAMBank::RAMBank(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Ren |
|
|
|
|
{MOVESPD,0}, |
|
|
|
|
{PROCEDURE,25}, |
|
|
|
|
{HEALTH,16}, |
|
|
|
|
},pos,*IMAGES[RAM_BANK],friendly,false),randomOffset({util::random(128),util::random(128)}),matrixImg(*IMAGES[MATRIX]), |
|
|
|
|
},pos,41,*IMAGES[RAM_BANK],friendly,false),randomOffset({util::random(128),util::random(128)}),matrixImg(*IMAGES[MATRIX]), |
|
|
|
|
originalImg(*IMAGES[RAM_BANK]){ |
|
|
|
|
img.Create(IMAGES[RAM_BANK]->Sprite()->width,IMAGES[RAM_BANK]->Sprite()->height); |
|
|
|
|
pge->SetDrawTarget(img.Sprite()); |
|
|
|
@ -150,8 +150,8 @@ void RAMBank::Draw(TileTransformedView&game,std::map<Image,std::unique_ptr<Rende |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Unit::Unit(std::vector<Memory>memory,vf2d pos,Renderable&img,bool friendly,bool moveable) |
|
|
|
|
:pos(pos),ghostPos(pos),img(img),friendly(friendly),moveable(moveable){ |
|
|
|
|
Unit::Unit(std::vector<Memory>memory,vf2d pos,float radius,Renderable&img,bool friendly,bool moveable) |
|
|
|
|
:pos(pos),radius(radius),ghostPos(pos),img(img),friendly(friendly),moveable(moveable){ |
|
|
|
|
int marker=0; |
|
|
|
|
for(Memory&mem:memory){ |
|
|
|
|
for(int i=0;i<mem.size;i++){ |
|
|
|
@ -185,13 +185,20 @@ Unit::Unit(std::vector<Memory>memory,vf2d pos,Renderable&img,bool friendly,bool |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Unit::DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){ |
|
|
|
|
float dist=geom2d::line<float>(game.ScreenToWorld(pge->GetMousePos()),GetPos()).length(); |
|
|
|
|
float dist=geom2d::line<float>(game.ScreenToWorld(pge->GetMousePos()),GetGhostPos()).length(); |
|
|
|
|
float range=12*(GetRange()+1); |
|
|
|
|
float totalRange=GetUnitSize().x/2+range; |
|
|
|
|
if(IsSelected()){ |
|
|
|
|
game.DrawRotatedDecal(GetPos(),IMAGES[RANGE_INDICATOR]->Decal(),0,IMAGES[RANGE_INDICATOR]->Sprite()->Size()/2,{range/12,range/12},{0,196,0,128}); |
|
|
|
|
game.DrawRotatedDecal(GetGhostPos(),IMAGES[RANGE_INDICATOR]->Decal(),0,IMAGES[RANGE_INDICATOR]->Sprite()->Size()/2,{totalRange/12,totalRange/12},{0,196,0,128}); |
|
|
|
|
}else |
|
|
|
|
if(dist<range*2){ |
|
|
|
|
game.DrawRotatedDecal(GetPos(),IMAGES[RANGE_INDICATOR]->Decal(),0,IMAGES[RANGE_INDICATOR]->Sprite()->Size()/2,{range/12,range/12},{0,196,0,uint8_t((1.f-(dist/(range*2)))*128)}); |
|
|
|
|
Pixel col; |
|
|
|
|
if(IsFriendly()){ |
|
|
|
|
col={0,196,0}; |
|
|
|
|
}else{ |
|
|
|
|
col={196,130,0}; |
|
|
|
|
} |
|
|
|
|
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)))*128)}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -359,7 +366,7 @@ bool Unit::IsDead(){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
vf2d Unit::GetUnitSize(){ |
|
|
|
|
return img.Sprite()->Size(); |
|
|
|
|
return vf2d{radius,radius}*2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Unit::SetTargetUnit(std::weak_ptr<Unit>target){ |
|
|
|
|