コード例 #1
0
 def _isAtDestination(self, margin=2):
     """
     Returns True if Unit is sufficiently close to dest, False otherwise
     """
     if self.status == Locals.IDLE:
         return True
     return specialMath.distance(self.realCenter,self.dest) <= margin
コード例 #2
0
 def update(self,current):
     self.setCorner(current)
     if specialMath.distance(self.current,self.start) > 5:
         self.visible = True
         self.updateBoundingBox()
     else:
         self.visible = False
コード例 #3
0
 def moveCloseToObject(self,radius, obj):
     """
     Moves unit within specified radius of objectOfAction. Returns True if within radius, False if otherwise
     """
     if obj is not None:
         closest=specialMath.findClosest(self.realCenter, obj.realCenter, self.worldSize)
         self.dest=closest
         if specialMath.distance(self.realCenter, self.dest) > radius:
             self.move()
             return False
         else:
             return True
     return False