|
|
@ -64,7 +64,7 @@ BitRestorer::BitRestorer(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IM |
|
|
|
{ATKSPD,1}, |
|
|
|
{ATKSPD,1}, |
|
|
|
{MOVESPD,1}, |
|
|
|
{MOVESPD,1}, |
|
|
|
{HEALTH,2}, |
|
|
|
{HEALTH,2}, |
|
|
|
},pos,12,*IMAGES[BIT_RESTORER],friendly,moveable){} |
|
|
|
},pos,12,*IMAGES[BIT_RESTORER],friendly,moveable,true,false){} |
|
|
|
|
|
|
|
|
|
|
|
void BitRestorer::Attack(Unit&victim){ |
|
|
|
void BitRestorer::Attack(Unit&victim){ |
|
|
|
|
|
|
|
|
|
|
@ -77,7 +77,7 @@ MemorySwapper::MemorySwapper(vf2d pos,std::map<Image,std::unique_ptr<Renderable> |
|
|
|
{HEALTH,3}, |
|
|
|
{HEALTH,3}, |
|
|
|
{PROCEDURE,3}, |
|
|
|
{PROCEDURE,3}, |
|
|
|
{MOVESPD,2}, |
|
|
|
{MOVESPD,2}, |
|
|
|
},pos,12,*IMAGES[MEMORY_SWAPPER],friendly,moveable){} |
|
|
|
},pos,12,*IMAGES[MEMORY_SWAPPER],friendly,moveable,true){} |
|
|
|
|
|
|
|
|
|
|
|
void MemorySwapper::Attack(Unit&victim){ |
|
|
|
void MemorySwapper::Attack(Unit&victim){ |
|
|
|
|
|
|
|
|
|
|
@ -103,7 +103,7 @@ MemoryAllocator::MemoryAllocator(vf2d pos,std::map<Image,std::unique_ptr<Rendera |
|
|
|
{MOVESPD,1}, |
|
|
|
{MOVESPD,1}, |
|
|
|
{PROCEDURE,1}, |
|
|
|
{PROCEDURE,1}, |
|
|
|
{HEALTH,1}, |
|
|
|
{HEALTH,1}, |
|
|
|
},pos,12,*IMAGES[UNIT_ALLOCATOR],friendly){} |
|
|
|
},pos,12,*IMAGES[UNIT_ALLOCATOR],friendly,false,false){} |
|
|
|
|
|
|
|
|
|
|
|
void MemoryAllocator::Attack(Unit&victim){ |
|
|
|
void MemoryAllocator::Attack(Unit&victim){ |
|
|
|
|
|
|
|
|
|
|
@ -116,7 +116,9 @@ RAMBank::RAMBank(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Ren |
|
|
|
{MOVESPD,0}, |
|
|
|
{MOVESPD,0}, |
|
|
|
{PROCEDURE,25}, |
|
|
|
{PROCEDURE,25}, |
|
|
|
{HEALTH,16}, |
|
|
|
{HEALTH,16}, |
|
|
|
},pos,41,*IMAGES[RAM_BANK],friendly,false),randomOffset({util::random(128),util::random(128)}),matrixImg(*IMAGES[MATRIX]), |
|
|
|
},pos,41,*IMAGES[RAM_BANK],friendly,false |
|
|
|
|
|
|
|
,false,false |
|
|
|
|
|
|
|
),randomOffset({util::random(128),util::random(128)}),matrixImg(*IMAGES[MATRIX]), |
|
|
|
originalImg(*IMAGES[RAM_BANK]){ |
|
|
|
originalImg(*IMAGES[RAM_BANK]){ |
|
|
|
img.Create(IMAGES[RAM_BANK]->Sprite()->width,IMAGES[RAM_BANK]->Sprite()->height); |
|
|
|
img.Create(IMAGES[RAM_BANK]->Sprite()->width,IMAGES[RAM_BANK]->Sprite()->height); |
|
|
|
pge->SetDrawTarget(img.Sprite()); |
|
|
|
pge->SetDrawTarget(img.Sprite()); |
|
|
@ -150,8 +152,8 @@ void RAMBank::Draw(TileTransformedView&game,std::map<Image,std::unique_ptr<Rende |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Unit::Unit(std::vector<Memory>memory,vf2d pos,float radius,Renderable&img,bool friendly,bool moveable) |
|
|
|
Unit::Unit(std::vector<Memory>memory,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){ |
|
|
|
:pos(pos),radius(radius),ghostPos(pos),img(img),friendly(friendly),moveable(moveable),friendlyInteractable(friendlyInteractable),enemyInteractable(enemyInteractable){ |
|
|
|
int marker=0; |
|
|
|
int marker=0; |
|
|
|
for(Memory&mem:memory){ |
|
|
|
for(Memory&mem:memory){ |
|
|
|
for(int i=0;i<mem.size;i++){ |
|
|
|
for(int i=0;i<mem.size;i++){ |
|
|
@ -185,20 +187,35 @@ Unit::Unit(std::vector<Memory>memory,vf2d pos,float radius,Renderable&img,bool f |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Unit::DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){ |
|
|
|
void Unit::DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){ |
|
|
|
|
|
|
|
if(!CanInteractWithAllies()&&!CanInteractWithEnemies())return; |
|
|
|
float dist=geom2d::line<float>(game.ScreenToWorld(pge->GetMousePos()),GetGhostPos()).length(); |
|
|
|
float dist=geom2d::line<float>(game.ScreenToWorld(pge->GetMousePos()),GetGhostPos()).length(); |
|
|
|
float range=12*(GetRange()+1); |
|
|
|
float range=12*(GetRange()+1); |
|
|
|
float totalRange=GetUnitSize().x/2+range; |
|
|
|
float totalRange=GetUnitSize().x/2+range; |
|
|
|
if(IsSelected()){ |
|
|
|
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 |
|
|
|
}else |
|
|
|
if(dist<range*2){ |
|
|
|
if(dist<range*2){ |
|
|
|
Pixel col; |
|
|
|
Pixel col; |
|
|
|
if(IsFriendly()){ |
|
|
|
if(IsFriendly()){ |
|
|
|
col={0,196,0}; |
|
|
|
if(CanInteractWithAllies()&&!CanInteractWithEnemies()){ |
|
|
|
|
|
|
|
col={40,127,173}; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
col={0,196,0}; |
|
|
|
|
|
|
|
} |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
col={196,130,0}; |
|
|
|
if(CanInteractWithAllies()&&!CanInteractWithEnemies()){ |
|
|
|
|
|
|
|
col={194, 37, 168}; |
|
|
|
|
|
|
|
} 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)}); |
|
|
|
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(){ |
|
|
|
bool Unit::IsMoveable(){ |
|
|
|
return moveable; |
|
|
|
return moveable; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Unit::CanInteractWithAllies(){ |
|
|
|
|
|
|
|
return friendlyInteractable; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Unit::CanInteractWithEnemies(){ |
|
|
|
|
|
|
|
return enemyInteractable; |
|
|
|
} |
|
|
|
} |