|
|
|
@ -106,17 +106,17 @@ void Monster::PerformShootAnimation(){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
void Monster::SetX(float x){ |
|
|
|
|
if(x-12*size>0&&x+12*size<game->WORLD_SIZE.x*24){ |
|
|
|
|
if(x-12*size>0&&x+12*size<game->GetWorldSize().x*24){ |
|
|
|
|
pos.x=x; |
|
|
|
|
} else { |
|
|
|
|
pos.x=std::min(game->WORLD_SIZE.x*24-12*size,std::max(12*size,pos.x)); |
|
|
|
|
pos.x=std::min(game->GetWorldSize().x*24-12*size,std::max(12*size,pos.x)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
void Monster::SetY(float y){ |
|
|
|
|
if(y-12*size>0&&y+12*size<game->WORLD_SIZE.y*24){ |
|
|
|
|
if(y-12*size>0&&y+12*size<game->GetWorldSize().y*24){ |
|
|
|
|
pos.y=y; |
|
|
|
|
} else { |
|
|
|
|
pos.y=std::min(game->WORLD_SIZE.y*24-12*size,std::max(12*size,pos.y)); |
|
|
|
|
pos.y=std::min(game->GetWorldSize().y*24-12*size,std::max(12*size,pos.y)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
bool Monster::Update(float fElapsedTime){ |
|
|
|
@ -187,11 +187,11 @@ bool Monster::Update(float fElapsedTime){ |
|
|
|
|
targetAcquireTimer=1; |
|
|
|
|
if(line.length()<24*6){ |
|
|
|
|
target=line.upoint(-1.2); |
|
|
|
|
if(pos.x-12*size>1&&pos.x+12*size<game->WORLD_SIZE.x*24-1&& |
|
|
|
|
pos.y-12*size>1&&pos.y+12*size<game->WORLD_SIZE.y*24-1){ |
|
|
|
|
if(pos.x-12*size>1&&pos.x+12*size<game->GetWorldSize().x*24-1&& |
|
|
|
|
pos.y-12*size>1&&pos.y+12*size<game->GetWorldSize().y*24-1){ |
|
|
|
|
state=MOVE_AWAY; |
|
|
|
|
} else
|
|
|
|
|
if(pos.x-12*size<=1||pos.x+12*size>=game->WORLD_SIZE.x*24-1){ |
|
|
|
|
if(pos.x-12*size<=1||pos.x+12*size>=game->GetWorldSize().x*24-1){ |
|
|
|
|
geom2d::line moveTowardsLine=geom2d::line(pos,target); |
|
|
|
|
if(abs(moveTowardsLine.vector().norm().y)>=0.5){ |
|
|
|
|
state=MOVE_AWAY; |
|
|
|
@ -199,7 +199,7 @@ bool Monster::Update(float fElapsedTime){ |
|
|
|
|
state=NORMAL; |
|
|
|
|
} |
|
|
|
|
} else
|
|
|
|
|
if(pos.y-12*size<=1||pos.y+12*size>=game->WORLD_SIZE.y*24-1){ |
|
|
|
|
if(pos.y-12*size<=1||pos.y+12*size>=game->GetWorldSize().y*24-1){ |
|
|
|
|
geom2d::line moveTowardsLine=geom2d::line(pos,target); |
|
|
|
|
if(abs(moveTowardsLine.vector().norm().x)>=0.5){ |
|
|
|
|
state=MOVE_AWAY; |
|
|
|
|