Esempio n. 1
0
    def process_change(self, change):
        arguments = change.split(" ")
        if arguments[0] == "create":
            if arguments[1] == "RotatableWorldObject":
                coord_x, coord_y = int(arguments[2]), int(arguments[3])
                width, height = int(arguments[4]), int(arguments[5])
                tileset_name = arguments[6]
                image_name, start_angle = arguments[7], arguments[8]
                world_id = int(arguments[9])
                temp_object = RotatableWorldObject(self, tileset_name)
                temp_object.set_pos(coord_x, coord_y)
                temp_object.set_size(width, height)
                temp_object.set_image(image_name)
                temp_object.set_angle(start_angle)
                temp_object.set_world_id(world_id)

                self.objects_id_dict[world_id] = temp_object
                self.all_drawable_client.append(temp_object)
        elif arguments[0] == "move":
            world_id = int(arguments[1])
            new_x, new_y = int(arguments[2]), int(arguments[3])
            new_frame, new_angle = int(arguments[4]), arguments[5]
            try:
                self.objects_id_dict[world_id].set_pos(new_x, new_y)
                self.objects_id_dict[world_id].set_angle(new_angle)
                self.objects_id_dict[world_id].image.current_frame = new_frame
            except KeyError:
                # Видимо, этот объект уже уничтожили?
                pass
        elif arguments[0] == "destroy":
            if arguments[1] == "RotatableWorldObject":
                world_id = int(arguments[2])
                try:
                    remove_if_exists_in(self.objects_id_dict[world_id], self.all_drawable_client)
                    self.objects_id_dict[world_id].destroy()
                except KeyError:
                    # Видимо, этот объект уже уничтожили?
                    pass
            elif arguments[1] == "WorldTile":
                world_id = int(arguments[2])
                self.objects_id_dict[world_id].destroy()
        elif arguments[0] == "gethit":
            world_id = int(arguments[1])
            bullet_direction = arguments[2]
            self.objects_id_dict[world_id].get_hit(bullet_direction)
        elif arguments[0] == "change_color":
            world_id = int(arguments[1])
            color = (int(arguments[2]), int(arguments[3]), int(arguments[4]))  # RGB цвет
            self.objects_id_dict[world_id].add_color(color)
        elif arguments[0] == "visible":
            world_id = int(arguments[1])
            is_visible = bool(strtobool(arguments[2]))
            # is_visible = bool(arguments[2])

            self.objects_id_dict[world_id].set_visible(is_visible)
Esempio n. 2
0
 def destroy(self):
     """
     Данный метод удаляет пулю из нужных массивов
     """
     super().destroy()
     remove_if_exists_in(self, self.parent_world.collisionable_objects)
     remove_if_exists_in(self, self.parent_world.actable_object)
     remove_if_exists_in(self, self.parent_world.all_bullets)
Esempio n. 3
0
 def destroy(self):
     remove_if_exists_in(self, self.parent_world.all_tiles)
     if self.is_solid:
         remove_if_exists_in(self, self.parent_world.collisionable_objects)
     if self.tile_id == 5:  # База игрока
         remove_if_exists_in(self, self.parent_world.world_map.player_bases)
     if self.parent_world.need_to_log_changes:  # Для сервера
         self.parent_world.changes.append(
             DESTROY_STRING.format(object_type="WorldTile",
                                   world_id=self.world_id))
Esempio n. 4
0
 def destroy(self, cinematic: bool = False):
     """
     Данный метод удаляет танк из нужных массивов
     :param cinematic: Нужно ли создать взрыв после уничтожения танка.
     :return:
     """
     super().destroy()
     remove_if_exists_in(self, self.parent_world.all_tanks)
     remove_if_exists_in(self, self.parent_world.collisionable_objects)
     remove_if_exists_in(self, self.parent_world.actable_object)
     self.is_destroyed = True
     # if self.parent_world.need_to_log_changes:  # Для сервера
     #     self.parent_world.changes.append(DESTROY_STRING.format(world_id=self.world_id,
     #                                                            object_type="RotatableWorldObject"))
     if cinematic:
         explode = TankExplosion(self.parent_world)
         explode.setup_in_world(self.object_rect.x + self.object_rect.w / 2,
                                self.object_rect.y + self.object_rect.h / 2)
Esempio n. 5
0
 def destroy(self):
     super().destroy()
     remove_if_exists_in(self, self.parent_world.all_tanks)
     remove_if_exists_in(self, self.parent_world.actable_object)
Esempio n. 6
0
 def destroy(self, cinematic: bool = False):
     super().destroy(cinematic)
     remove_if_exists_in(self, self.parent_world.all_enemies)
     self.parent_world.current_amount_of_enemies -= 1
Esempio n. 7
0
 def destroy(self, cinematic: bool = False):
     super().destroy(cinematic)
     remove_if_exists_in(self, self.parent_world.players)