コード例 #1
0
 def update_directional_speed(self, b_obj, speedf, balance=False):
     direction = self.directional_speed(b_obj.direction, speedf)
     if balance and direction.size > 0:
         perpedicular_dir = utils.Vector2D(-direction.z, direction.x)
         dot = (b_obj.velocities.x * perpedicular_dir.x + b_obj.velocities.z * perpedicular_dir.z) / \
             (perpedicular_dir.x * perpedicular_dir.x + perpedicular_dir.z * perpedicular_dir.z)
         if dot < 0:
             dot *= -1
             perpedicular_dir = utils.Vector2D(direction.z, -direction.x)
         direction = utils.Vector2D(direction.x - perpedicular_dir.x * dot,
                                    direction.z - perpedicular_dir.z * dot)
         self.turn_to_direction(b_obj, direction.x, 0, direction.z)
     if balance and b_obj.hold_position_flag:
         self.turn_to_direction(b_obj, -b_obj.velocities.x, 0,
                                -b_obj.velocities.z)
         b_obj.velocities.x = 0
         b_obj.velocities.z = 0
     b_obj.velocities.x += direction.x
     b_obj.velocities.z += direction.z
コード例 #2
0
 def tick(self):
     if self.location_received is False:
         return
     if not self.ready:
         self.ready = self.in_complete_chunks(
             self.bot_object) and self.spawn_point_received
         if not self.ready:
             return
     self.move(self.bot_object)
     self.bot_object.direction = utils.Vector2D(0, 0)
     self.send_location(self.bot_object)
     self.send_action(self.bot_object)
     self.stop_sneaking(self.bot_object)
     if not self.i_am_dead:
         utils.do_now(self.behavior_tree.tick)
コード例 #3
0
 def __init__(self):
     self.velocities = utils.Vector(0.0, 0.0, 0.0)
     self.direction = utils.Vector2D(0, 0)
     self._x = 0
     self._y = 0
     self._z = 0
     self.stance_diff = config.PLAYER_EYELEVEL
     self.pitch = None
     self.yaw = None
     self.on_ground = False
     self.is_collided_horizontally = False
     self.horizontally_blocked = False
     self.action = 2  # normal
     self._action = self.action
     self.is_jumping = False
     self.hold_position_flag = True
コード例 #4
0
ファイル: behavior_tree.py プロジェクト: owcici/TwistedBot
 def move(self, b_obj):
     direction = utils.Vector2D(self.target_state.center_x - b_obj.x, self.target_state.center_z - b_obj.z)
     direction.normalize()
     if not self.was_at_target:
         self.blackboard.bot_turn_to_direction(b_obj, direction.x, 0, direction.z)
     b_obj.direction = direction
コード例 #5
0
 def directional_speed(self, direction, speedf):
     dx = direction.x * speedf
     dz = direction.z * speedf
     return utils.Vector2D(dx, dz)
コード例 #6
0
ファイル: gridspace.py プロジェクト: owcici/TwistedBot
 def base_in(self, bb):
     return self.vertical_center_in(utils.Vector2D(
         bb.min_x, bb.min_z)) and self.vertical_center_in(
             utils.Vector2D(bb.max_x, bb.max_z))