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
def update(self,current): self.setCorner(current) if specialMath.distance(self.current,self.start) > 5: self.visible = True self.updateBoundingBox() else: self.visible = False
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