|
|
|
@ -179,6 +179,12 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ |
|
|
|
|
HandlePanAndZoom(fElapsedTime); |
|
|
|
|
HandleMinimapClick(); |
|
|
|
|
|
|
|
|
|
for(auto&tile:visibleTiles){ |
|
|
|
|
tile.second-=fElapsedTime; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::erase_if(visibleTiles,[](std::pair<vf2d,float> key){return key.second<=0;}); |
|
|
|
|
|
|
|
|
|
for(auto&u:units){ |
|
|
|
|
Unit*closestUnit=nullptr; |
|
|
|
|
float closestDist=999999; |
|
|
|
@ -186,6 +192,13 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ |
|
|
|
|
IdentifyClosestTarget(closestUnit,closestDist,u,u2); |
|
|
|
|
CollisionChecking(u,u2); |
|
|
|
|
} |
|
|
|
|
if(u->IsFriendly()){ |
|
|
|
|
for(int y=-1;y<2;y++){ |
|
|
|
|
for(int x=-1;x<2;x++){ |
|
|
|
|
visibleTiles[u->GetPos()/24/4+vi2d(x,y)]=5; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
u->AttemptAttack(closestUnit); |
|
|
|
|
u->Update(fElapsedTime); |
|
|
|
|
} |
|
|
|
@ -199,6 +212,15 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
DrawSelectionRectangle(); |
|
|
|
|
for(int y=game.GetTopLeftTile().y/96-1;y<=game.GetBottomRightTile().y/96+1;y++){ |
|
|
|
|
for(int x=game.GetTopLeftTile().x/96-1;x<=game.GetBottomRightTile().x/96+1;x++){ |
|
|
|
|
if(visibleTiles.count(vi2d{x,y})==0){ |
|
|
|
|
if(x>=0&&y>=0&&x<=CONSTANT::WORLD_SIZE.x*CONSTANT::TILE_SIZE.x&&y<=CONSTANT::WORLD_SIZE.y*CONSTANT::TILE_SIZE.y){ |
|
|
|
|
game.FillRectDecal(vf2d{float(x),float(y)}*96,{96,96},{0,0,0,128}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
DrawMinimap(); |
|
|
|
|
|
|
|
|
|