Esempio n. 1
0
 def _step_action(self, robot: Robot, action: Action):
     # gas, rotate, transverse, rotate cloud terrance, shoot
     robot.move_ahead_back(action.v_t)
     robot.turn_left_right(action.angular)
     robot.move_left_right(action.v_n)
     if int(self.t * FPS) % (60 * FPS) == 0:
         robot.refresh_supply_oppotunity()
     if action.supply > 0.99:
         action.supply = 0.0
         if robot.if_supply_available():
             robot.use_supply_oppotunity()
             if self.__area_supply.if_in_area(robot):
                 robot.supply()
     if action.shoot > 0.99 and int(self.t * FPS) % (FPS / 5) == 1:
         if (robot.if_left_projectile()):
             angle, pos = robot.get_gun_angle_pos()
             robot.shoot()
             self.__projectile.shoot(angle, pos)
Esempio n. 2
0
    def detect(self, robot: Robot, t_now):
        # 0, 1, 2min refresh
        bool_t = (t_now > 3.00 - 0.05
                  and t_now < 3.00 + 0.05) and (t_now > 120.00 - 0.05
                                                and t_now < 120.00 + 0.05)
        if (int(t_now) % 60 == 0):
            # if t_now == 5.00 or t_now == 60.00:
            # if bool_t:
            self.__activated = False
            self.__t_stay = 0
            self.__type = choice(TYPE)
            # print(f'time {t_now}')
            # print(f"buff type - 2 {self.__type}")

        if self.__activated:
            return

        if robot.group != self.__group and self.__type < 1:
            return

        if self._if_in_area(robot.get_pos(), self.__box):
            self.__t_stay += t_now - self.__t_last
            if self.__t_stay >= TIME_BUFF_TRIGGER:
                self.__activated = True
                if self.__type == 0:
                    robot.lose_health(-1000)
                    return
                if self.__type == 1:
                    robot.supply()
                    return
                robot.buff_left_time = PUNISH_TIME
                robot.buff_type = self.__type
                self.__t_stay = 0
        else:
            self.__t_stay = 0

        self.__t_last = t_now