Added in extra stat indicators for damaged units.
@ -223,6 +223,7 @@ void Unit::DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::
|
||||
float dist=geom2d::line<float>(game.ScreenToWorld(pge->GetMousePos()),GetGhostPos()).length();
|
||||
float range=12*(GetRange()+1);
|
||||
float totalRange=GetUnitSize().x/2+range;
|
||||
|
||||
if(IsSelected()){
|
||||
Pixel col;
|
||||
if(CanInteractWithAllies()&&!CanInteractWithEnemies()){
|
||||
@ -231,6 +232,7 @@ void Unit::DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::
|
||||
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(dist<range*2){
|
||||
Pixel col;
|
||||
@ -247,7 +249,8 @@ void Unit::DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::
|
||||
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)))*255)});
|
||||
uint8_t transparency=uint8_t((1.f-(dist/(range*2)))*255);
|
||||
game.DrawRotatedDecal(GetGhostPos(),IMAGES[RANGE_INDICATOR]->Decal(),0,IMAGES[RANGE_INDICATOR]->Sprite()->Size()/2,{totalRange/12,totalRange/12},{col.r,col.g,col.b,transparency});
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,6 +313,40 @@ void Unit::DrawHud(TileTransformedView&game,std::map<Image,std::unique_ptr<Rende
|
||||
float(initialBarY)},CONSTANT::BAR_SQUARE_SIZE,ghostMemory[i]?col:col/4);
|
||||
game.DrawRectDecal({float(initialBarX)+i*CONSTANT::BAR_SQUARE_SIZE.x,
|
||||
float(initialBarY)},CONSTANT::BAR_SQUARE_SIZE,BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::DrawUnitDamageStats(PixelGameEngine*pge,TileTransformedView&game,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){
|
||||
float dist=geom2d::line<float>(game.ScreenToWorld(pge->GetMousePos()),GetGhostPos()).length();
|
||||
float range=12*(GetRange()+1);
|
||||
|
||||
|
||||
|
||||
auto DrawStatDown=[&](Marker&maxStat,int currentStat,vf2d pos,vf2d downDisplayPos,Image img,uint8_t transparency=255){
|
||||
if(maxStat.size>0){
|
||||
if(currentStat!=maxStat.size){
|
||||
game.DrawDecal(this->pos+pos,IMAGES[img]->Decal(),{1,1},{255,255,255,transparency});
|
||||
if(currentStat>0){
|
||||
game.DrawDecal(this->pos+downDisplayPos,IMAGES[DOWN_ARROW]->Decal(),{1,1},{255,255,255,transparency});
|
||||
} else {
|
||||
game.DrawDecal(this->pos+downDisplayPos,IMAGES[RED_X]->Decal(),{1,1},{255,255,255,transparency});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if(IsSelected()){
|
||||
DrawStatDown(atkSpd,GetAtkSpd(),{-48-8,-24},{-48+8,-18},RLD);
|
||||
DrawStatDown(moveSpd,GetMoveSpd(),{-48-8,8},{-48+8,2},SPD);
|
||||
DrawStatDown(this->range,GetRange(),{8,-24},{36,-18},RNG);
|
||||
DrawStatDown(procedure,GetProcedure(),{8,8},{36,2},PRC);
|
||||
}else
|
||||
if(dist<range*2){
|
||||
uint8_t transparency=uint8_t((1.f-(dist/(range*2)))*255);
|
||||
DrawStatDown(atkSpd,GetAtkSpd(),{-48-8,-24},{-48+8,-18},RLD,transparency);
|
||||
DrawStatDown(moveSpd,GetMoveSpd(),{-48-8,8},{-48+8,2},SPD,transparency);
|
||||
DrawStatDown(this->range,GetRange(),{8,-24},{26,-18},RNG,transparency);
|
||||
DrawStatDown(procedure,GetProcedure(),{8,8},{26,2},PRC,transparency);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -64,6 +64,7 @@ public:
|
||||
virtual void Attacked(std::weak_ptr<Unit>attacker);
|
||||
void _Attacked(std::weak_ptr<Unit>attacker);
|
||||
std::weak_ptr<Unit>GetCurrentTarget();
|
||||
void DrawUnitDamageStats(PixelGameEngine*pge,TileTransformedView&game,std::map<Image,std::unique_ptr<Renderable>>&IMAGES);
|
||||
|
||||
std::vector<bool>& operator <<=(const int n){
|
||||
for(int i=0;i<GetMemorySize()-1;i++){
|
||||
|
||||
@ -78,6 +78,10 @@ bool VirusAttack::OnUserCreate(){
|
||||
|
||||
units.push_back(std::make_unique<RightShifter>(vf2d{360,300},IMAGES,false));
|
||||
|
||||
for(int i=0;i<units[0]->GetMemorySize();i++){
|
||||
units[0]->memory[i]=units[0]->ghostMemory[i]=i%2==0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -399,6 +403,7 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
|
||||
}
|
||||
|
||||
for(auto&u:units){
|
||||
u->DrawUnitDamageStats(this,game,IMAGES);
|
||||
u->DrawHud(game,IMAGES);
|
||||
}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 692 B After Width: | Height: | Size: 8.3 KiB |