Esempio n. 1
0
    def _gen_surface(self, side):
        """Generate a terrain block.

        Randomly choose one of the terrain blocks proper for this
        rails block. Randomly rotate it. Use special terrain blocks
        for enemy territory.

        Args:
            side (str):
                Side of the terrain block, relatively to the railway.

        Returns:
            str, int: Terrain model name, angle.
        """
        if self.enemy_territory:
            return address("surface_en1"), random.choice(ANGLES)

        if self.is_city:
            return address("surface_with_" + side +
                           "_city"), 180 if side == "r" else 0

        if side == self._station_side:
            surface = address(take_random(
                base.world.stations_pool))  # noqa: F821
            return surface, (180 if side == "r" else 0)

        surface = address(random.choice(SURFACES[self.name]))
        if self.name == "direct":
            return surface, random.choice(ANGLES)

        return surface, 0
Esempio n. 2
0
 def __init__(self):
     self._models = {
         "moto1": Actor(address("motocycle1")),
         "moto2": Actor(address("motocycle2")),
         "moto3": Actor(address("motocycle3")),
         "dodge": Actor(address("car1")),
     }
     self._models["moto1"].setPlayRate(1.5, "ride")
     self._models["moto2"].setPlayRate(1.5, "ride")
     self._models["moto3"].setPlayRate(1.5, "ride")
     self._models["dodge"].setPlayRate(2.5, "ride")
Esempio n. 3
0
    def _set_shoot_anim(self):
        """Prepare machine gun shooting animation for this unit.

        Returns:
            direct.interval.MetaInterval.Sequence:
                Shooting animation and sounds sequence.
        """
        shot_snd = base.sound_mgr.loadSfx(  # noqa: F821
            "sounds/combat/machine_gun_shot1.ogg")
        base.sound_mgr.attachSoundToObject(shot_snd, self.model)  # noqa: F821

        fire = loader.loadModel(address("gun_fire2"))  # noqa: F821
        fire.reparentTo(self.model)
        fire.setScale(1, 0.0001, 1)
        if self._y_pos > 0:
            fire.setPos(-0.055, -0.008, 0.076)
            fire.setH(180)
        else:
            fire.setPos(0.065, -0.008, 0.076)

        shoot_par = Parallel(
            Sequence(
                LerpScaleInterval(fire, 0.07, (1, 1, 1)),
                LerpScaleInterval(fire, 0.07, (1, 0.0001, 1)),
                Wait(0.12),
            ),
            SoundInterval(shot_snd, duration=0.25),
        )
        return Sequence(*(shoot_par, ) * 20)
Esempio n. 4
0
    def __init__(self, model, id_, y_positions, enemy_handler, class_data):
        EnemyMotorcyclist.__init__(self, id_, "Kamikaze", class_data, model,
                                   y_positions, enemy_handler)

        self._train_captured = False
        self._explosion_col_np = None
        self.is_jumping = False

        self._side = "left" if self._y_pos > 0 else "right"

        self._jump_path = Mopath.Mopath(
            objectToLoad=loader.loadModel(  # noqa: F821
                address(self._side[0] + "_kamikaze_jump")))
        self._jump_path.fFaceForward = True

        self._jump_snd = base.sound_mgr.loadSfx(
            "sounds/moto_jump.ogg")  # noqa: F821
        base.sound_mgr.attachSoundToObject(self._jump_snd,
                                           self.model)  # noqa: F821

        self._wick_snd = base.sound_mgr.loadSfx(
            "sounds/combat/wick.ogg")  # noqa: F821
        base.sound_mgr.attachSoundToObject(self._wick_snd,
                                           self.model)  # noqa: F821

        self._wick = ParticleEffect()

        self._fire_ring = ParticleEffect()
        self._fire_ring.loadConfig("effects/fire_ring.ptf")
        self._fire_ring.setZ(0.2)
Esempio n. 5
0
    def _set_shoot_anim(self, pos, angle, shots):
        """Prepare gun fire animation and sounds.

        Args:
            pos (tuple): Position to set fire.
            angle (int): Angle to set fire.
            shots (int): Number of shots in animation.

        Returns:
            direct.interval.MetaInterval.Sequence: Shooting sequence.
        """
        fire = loader.loadModel(address("gun_fire1"))  # noqa: F821
        fire.reparentTo(self.model)
        fire.setScale(1, 0.0001, 1)
        fire.setPos(*pos)
        fire.setH(angle)

        shoot_seq = Parallel(
            Sequence(
                LerpScaleInterval(fire, 0.12, (1, 1, 1)),
                LerpScaleInterval(fire, 0.12, (1, 0.0001, 1)),
            ),
            SoundInterval(self.shot_snd, duration=0.3),
        )
        return Sequence(*(shoot_seq, ) * shots)
Esempio n. 6
0
    def _prepare_arrow(self, name, arrow_pos):
        """Prepare a manipulating arrow for this part.

        Args:
            name (str): Name of the part.
            arrow_pos (dict): Arrow position.

        Returns:
            panda3d.core.NodePath: Arrow node.
        """
        arrow = loader.loadModel(address("train_part_arrow"))  # noqa: F821
        arrow.setPos(*arrow_pos)
        arrow.setH(self.angle)
        arrow.clearLight()

        # set manipulating arrow collisions
        # used to detect pointing the arrow by mouse
        col_node = CollisionNode(name)
        col_node.setFromCollideMask(NO_MASK)
        col_node.setIntoCollideMask(MOUSE_MASK)
        col_node.addSolid(
            CollisionPolygon(
                Point3(-0.06, -0.06, 0),
                Point3(-0.06, 0.06, 0),
                Point3(0.06, 0.06, 0),
                Point3(0.06, -0.06, 0),
            )
        )
        arrow.attachNewNode(col_node)
        return arrow
Esempio n. 7
0
    def __init__(self, day_part_desc):
        self._path = Mopath.Mopath(objectToLoad=address("sun_path"))

        self._color = copy.deepcopy(next(SUN_COLORS))
        self._next_color = copy.deepcopy(next(SUN_COLORS))
        self._color_step = 0

        if day_part_desc:
            while self._color["name"] != day_part_desc["name"]:
                self._color = self._next_color
                self._next_color = copy.deepcopy(next(SUN_COLORS))

            self._color = day_part_desc["time"]["color"]
            self._color_step = day_part_desc["time"]["step"]

        # day duration = 90 steps * 10 sec/step = 15 min/part
        # 15 min/part * 4 parts = 1 hour/day
        self._day_part_duration = 90
        self._step_duration = 9

        self._arch_int = None

        self._color_vec = self._calc_color_vec(self._color, self._next_color,
                                               self._day_part_duration)

        self._amb_light, self._dir_light, sun_np = self._set_general_lights(
            base.train.node  # noqa: F821
        )
        self._set_day_night_cycle(sun_np, day_part_desc)
Esempio n. 8
0
    def _load_motion_paths(self):
        """Load all motion path models into single index.

        Returns:
            dict: Index of paths.
        """
        paths = {}

        for name in ("direct", "l90_turn", "r90_turn", "ls", "rs"):
            path_mod = loader.loadModel(address(name + "_path"))  # noqa: F821

            # motion path for Train
            paths[name] = Mopath.Mopath(objectToLoad=path_mod)
            paths[name].fFaceForward = True
            # motion path for camera
            paths["cam_" + name] = Mopath.Mopath(objectToLoad=path_mod)

        # every fork has two paths
        paths["r_fork"] = (paths["direct"], paths["r90_turn"])
        paths["cam_r_fork"] = (paths["cam_direct"], paths["cam_r90_turn"])

        paths["l_fork"] = (paths["direct"], paths["l90_turn"])
        paths["cam_l_fork"] = (paths["cam_direct"], paths["cam_l90_turn"])

        paths["exit_from_fork"] = (paths["l90_turn"], paths["r90_turn"])
        paths["cam_exit_from_fork"] = (paths["cam_l90_turn"], paths["cam_r90_turn"])

        return paths
Esempio n. 9
0
    def __init__(self, loc_model):
        self._is_on_move = False
        self.cur_position = "top"

        self._snd = base.sound_mgr.loadSfx(  # noqa: F821
            "sounds/train/armor_plate_move.ogg"
        )
        base.sound_mgr.attachSoundToObject(self._snd, loc_model)  # noqa: F821

        self._model = Actor(address("armor_plate"))
        self._model.reparentTo(loc_model)

        self._right_to_left = Sequence(
            Parallel(
                self._model.actorInterval("right", playRate=-2.5),
                SoundInterval(self._snd),
            ),
            Parallel(
                self._model.actorInterval("left", playRate=2.5),
                SoundInterval(self._snd),
            ),
        )
        self._left_to_right = Sequence(
            Parallel(
                self._model.actorInterval("left", playRate=-2.5),
                SoundInterval(self._snd),
            ),
            Parallel(
                self._model.actorInterval("right", playRate=2.5),
                SoundInterval(self._snd),
            ),
        )
        base.accept("4", self._turn_left)  # noqa: F821
        base.accept("5", self._turn_top)  # noqa: F821
        base.accept("6", self._turn_right)  # noqa: F821
Esempio n. 10
0
    def _gen_railways_model(self):
        """Select railways model and generate its coordinates.

        Returns:
            list: Railways model name, x and y coords, angle.
        """
        if (self.name != "direct" or chance(83) or self.enemy_territory
                or self.is_station):
            return

        model = random.choice((
            "arch1",
            "sign1",
            "sign2",
            "sign3",
            "light_post{}".format(random.randint(1, 2)),
            "lamp_post1",
            "transparant1",
        ))
        if model in ("arch1", "transparant1"):
            coor = 0
        else:
            coor = random.choice((0.15, -0.15))

        if model == "lamp_post1" and coor > 0:
            angle = 180
        else:
            angle = 0

        return (address(model), (coor, random.randint(0, 8)), angle)
Esempio n. 11
0
    def _switch_garland(self):
        """Christmas related method.

        Enables or removes the locomotive garland
        and an ability to shot a flapper.
        """
        if self._garland is None:
            self._garland = loader.loadModel(address("garland"))  # noqa: F821
            self._garland.reparentTo(self._model)

            self._confetti = []

            for color in ("red", "blue", "green"):
                confetti = ParticleEffect()
                confetti.loadConfig("effects/confetti_{}.ptf".format(color))
                confetti.setPos(0, 0.32, 0.29)
                self._confetti.append(confetti)

            self._confetti_snd = base.sound_mgr.loadSfx(  # noqa: F821
                "sounds/train/flapper.ogg")
            base.sound_mgr.attachSoundToObject(  # noqa: F821
                self._confetti_snd, self._model)
        else:
            self._garland.removeNode()
            self._garland = None

            for effect in self._confetti:
                effect.softStop()
                effect.cleanup()

            self._confetti = None
            base.sound_mgr.detach_sound(self._confetti_snd)  # noqa: F821
            self._confetti_snd = None
Esempio n. 12
0
    def __init__(self, loc_model):
        self._is_loading = False
        self.is_up = False

        self._coors = [None, None, None, None]
        self._sights = []
        self._explosions = []
        self._ground_holes = []
        self._smokes = []
        self._bombs = []
        self._explosion_snds = []

        self._train_mod = loc_model
        self._model = Actor(address("cluster_bomb_launcher"))
        self._model.reparentTo(loc_model)

        for _ in range(4):
            sight = loader.loadModel(address("grenade_sight"))  # noqa: F82
            sight.reparentTo(loc_model)
            sight.hide()
            self._sights.append(sight)

            explosion = ParticleEffect()
            explosion.loadConfig("effects/grenade_explode.ptf")
            self._explosions.append(explosion)

            smoke = ParticleEffect()
            smoke.loadConfig("effects/bomb_smoke1.ptf")
            self._smokes.append(smoke)

            snd = loader.loadSfx("sounds/combat/bomb_explosion1.ogg")  # noqa: F821
            snd.setVolume(random.uniform(0.1, 0.15))
            snd.setPlayRate(random.uniform(0.8, 1))
            self._explosion_snds.append(snd)

            hole = loader.loadModel(address("ground_hole"))  # noqa: F821
            hole.reparentTo(loc_model)
            hole.setTransparency(TransparencyAttrib.MAlpha)
            hole.hide()
            self._ground_holes.append(hole)

        self._load_snd = loader.loadSfx("sounds/combat/howitzer_load.ogg")  # noqa: F821
        self._load_snd.setPlayRate(0.8)

        base.accept("3", self.change_state)  # noqa: F82
Esempio n. 13
0
    def __init__(self):
        x_coor, side = random.choice(
            ((0.553, "left"), (-0.553, "right"), (0, "top")))

        self._model = Actor(address("rocket1"))
        self._model.reparentTo(base.train.model)  # noqa: F821
        self._model.setPos(x_coor, -7, 0.5)

        self._smoke = ParticleEffect()
        self._smoke.loadConfig("effects/smoke_tail.ptf")
        self._smoke.start(self._model, render)  # noqa: F821

        path = Mopath.Mopath(objectToLoad=loader.loadModel(  # noqa: F821
            address("rocket_{}_path".format(side))))
        path.fFaceForward = True

        self._hiss_snd = base.sound_mgr.loadSfx(
            "sounds/rocket_fly.ogg")  # noqa: F821
        base.sound_mgr.attachSoundToObject(self._hiss_snd,
                                           self._model)  # noqa: F821

        self._hiss_snd2 = base.sound_mgr.loadSfx(
            "sounds/rocket_hiss.ogg")  # noqa: F821
        base.sound_mgr.attachSoundToObject(self._hiss_snd2,
                                           self._model)  # noqa: F821

        self._hiss_snd.play()
        seq = Sequence(
            LerpPosInterval(self._model,
                            7, (x_coor, -0.627, 0.561),
                            blendType="easeOut"),
            Wait(0.7),
            Parallel(
                SoundInterval(self._hiss_snd2),
                MopathInterval(path,
                               self._model,
                               duration=0.5,
                               name="rocket_current_path"),
            ),
            Func(self._explode, side),
        )
        seq.start()
Esempio n. 14
0
    def __init__(self, loc_model):
        self.is_up = False
        # flag, which indicates if the launcher
        # is in (un-)loading process
        self._is_loading = False
        self._range_col_np = None

        self._loc_model = loc_model

        self._model = Actor(address("grenade_launcher"))
        self._model.reparentTo(loc_model)

        self._sight = loader.loadModel(address("grenade_sight"))  # noqa: F821
        self._sight.reparentTo(loc_model)
        self._sight.hide()

        self._grenade_explosion = ParticleEffect()
        self._grenade_explosion.loadConfig("effects/grenade_explode.ptf")

        self._grenade_smoke = ParticleEffect()
        self._grenade_smoke.loadConfig("effects/bomb_smoke1.ptf")

        self._hole_sprite = loader.loadModel(address("ground_hole"))  # noqa: F821
        self._hole_sprite.reparentTo(loc_model)
        self._hole_sprite.setTransparency(TransparencyAttrib.MAlpha)
        self._hole_sprite.hide()

        base.accept("1", self.change_state)  # noqa: F821

        self._shot_snd = loader.loadSfx(  # noqa: F821
            "sounds/combat/grenade_launcher_shot.ogg"
        )
        self._explosion_snd = loader.loadSfx(  # noqa: F821
            "sounds/combat/bomb_explosion1.ogg"
        )
        self._explosion_snd.setVolume(0.15)

        self._load_snd = loader.loadSfx(  # noqa: F821
            "sounds/combat/grenade_launcher_load.ogg"
        )
Esempio n. 15
0
    def _prepare_auras(self):
        """Prepare cohesion skills aura effects."""
        aura = loader.loadModel(address("cover_fire_aura"))  # noqa: F821
        aura.hide()
        aura.reparentTo(self.model)
        aura.setY(0.007)

        self.effects["cover_fire"] = {
            "model": aura,
            "seq": Sequence(
                LerpScaleInterval(aura, 1.5, (2, 2, 2), (1, 1, 1)),
                LerpScaleInterval(aura, 1.5, (1, 1, 1), (2, 2, 2)),
            ),
        }

        aura = loader.loadModel(address("common_rage_aura"))  # noqa: F821
        aura.hide()
        aura.reparentTo(self.model)
        aura.setY(0.007)

        self.effects["common_rage_aura"] = {
            "model": aura,
            "seq": Sequence(
                LerpScaleInterval(aura, 1.5, (2, 2, 2), (1, 1, 1)),
                LerpScaleInterval(aura, 1.5, (1, 1, 1), (2, 2, 2)),
            ),
        }

        aura = loader.loadModel(address("hold_together_aura"))  # noqa: F821
        aura.hide()
        aura.reparentTo(self.model)
        aura.setY(0.007)

        self.effects["hold_together"] = {
            "model": aura,
            "seq": Sequence(
                LerpScaleInterval(aura, 1.5, (2, 2, 2), (1, 1, 1)),
                LerpScaleInterval(aura, 1.5, (1, 1, 1), (2, 2, 2)),
            ),
        }
Esempio n. 16
0
    def __init__(self, model, id_, y_positions, enemy_handler, class_data):
        EnemyMotorcyclist.__init__(self, id_, "Braker", class_data, model,
                                   y_positions, enemy_handler)
        self.is_jumping = False
        self._train_captured = False

        brake1 = base.loader.loadModel(address("brake1"))  # noqa: F821
        brake1.reparentTo(self.model)
        brake1.setPos(-0.008, -0.019, 0.02)
        brake1.setP(45)

        brake2 = base.loader.loadModel(address("brake1"))  # noqa: F821
        brake2.reparentTo(self.model)
        brake2.setPos(0.008, -0.019, 0.02)
        brake2.setP(45)

        self._brakes = [brake1, brake2]
        self._jump_int = None

        self._l_mopath = Mopath.Mopath(
            objectToLoad=loader.loadModel(address("l_low_jump"))  # noqa: F821
        )
        self._l_mopath.fFaceForward = True

        self._r_mopath = Mopath.Mopath(
            objectToLoad=loader.loadModel(address("r_low_jump"))  # noqa: F821
        )
        self._r_mopath.fFaceForward = True

        self._jump_snd = base.sound_mgr.loadSfx(
            "sounds/moto_jump.ogg")  # noqa: F821
        base.sound_mgr.attachSoundToObject(self._jump_snd,
                                           self.model)  # noqa: F821

        self._fall_snd = base.sound_mgr.loadSfx(
            "sounds/moto_fall.ogg")  # noqa: F821
        base.sound_mgr.attachSoundToObject(self._fall_snd,
                                           self.model)  # noqa: F821
Esempio n. 17
0
    def __init__(self, loc_model):
        self.is_up = False
        # flag, which indicates if the launcher
        # is in (un-)loading process
        self._is_loading = False
        self._col_np = None

        self._model = loader.loadModel(address("machine_gun"))  # noqa: F821
        self._model.reparentTo(loc_model)
        self._model.setPos(-0.02, -0.27, 0.31)

        self._sight = loader.loadModel(address("machine_gun_sight"))  # noqa: F821
        self._sight.reparentTo(loc_model)
        self._sight.hide()

        self._shot_dirt = ParticleEffect()
        self._shot_dirt.loadConfig("effects/machine_gun_shot.ptf")

        self._shot_snd = base.sound_mgr.loadSfx(  # noqa: F82
            "sounds/combat/loc_machine_gun.ogg"
        )
        base.sound_mgr.attachSoundToObject(self._shot_snd, self._model)  # noqa: F82
        self._load_snd = loader.loadSfx(  # noqa: F82
            "sounds/combat/machine_gun_load.ogg"
        )

        fire = loader.loadModel(address("gun_fire2"))  # noqa: F821
        fire.reparentTo(self._model)
        fire.setScale(1, 0.0001, 1)
        fire.setPos(0, 0.095, 0.029)
        fire.setH(90)

        self._shoot_seq = Sequence(
            LerpScaleInterval(fire, 0.16, (1.3, 1, 1.3)),
            LerpScaleInterval(fire, 0.085, (1, 0.0001, 1)),
        )
        base.accept("2", self.change_state)  # noqa: F82
Esempio n. 18
0
    def _load_env_model(self, surf_mod, env_mod):
        """Helper to load a model asynchronous.

        Args:
            surf_mod (panda3d.core.NodePath): Surface model.
            env_mod (str): Name of the model to load and its position.
        """
        mod = loader.loadModel(address(env_mod[0]))  # noqa: F821
        if "grass" in env_mod[0]:
            mod.setTransparency(TransparencyAttrib.M_binary)
            mod.setShaderOff()

        mod.reparentTo(surf_mod)
        mod.setPos(env_mod[1])
        mod.setH(random.randint(1, 359))
    def __init__(self, parts, chars):
        self._chars = chars
        self._parts = parts

        self._is_keys_shown = False
        self._is_relations_shown = False
        self._keys_info = None  # on screen text object
        self._pointed_obj = ""
        self._chosen_char = None

        self._move_char_snd = loader.loadSfx("sounds/move_char.ogg")  # noqa: F821
        self._char_pointer = loader.loadModel(  # noqa: F821
            address("character_pointer")
        )
        self._char_pointer.setLightOff()
Esempio n. 20
0
    def __init__(self, model, id_, y_positions, enemy_handler, class_data):
        EnemyMotorcyclist.__init__(self, id_, "Bomb Thrower", class_data,
                                   model, y_positions, enemy_handler)
        self._throw_anim = "throw_" + ("right" if self._y_pos < 0 else "left")

        # prepare a hand bomb model
        self._bomb = loader.loadModel(address("hand_bomb1"))  # noqa: F821
        self._bomb.hide()
        self._bomb.reparentTo(self.model)

        if self._y_pos < 0:
            self._bomb_pos = (0.034, 0.021, 0.068)
        else:
            self._bomb_pos = (-0.037, 0.028, 0.073)

        self._bomb.setPos(*self._bomb_pos)
Esempio n. 21
0
    def preview_upgrade(self, model):
        """Preview the given upgrade model on the locomotive.

        Used when buying upgrades in a city.

        Args:
            model (panda3d.core.NodePath): The upgrade model.
        """
        self.clear_upgrade_preview()

        self._pre_upgrade = loader.loadModel(address(model))  # noqa: F821
        self._pre_upgrade.reparentTo(self.model)

        if "machine_gun" in model:
            self._pre_upgrade.setPos(-0.02, -0.27, 0.31)

        taskMgr.doMethodLater(  # noqa: F821
            0.05, self._highlight_upgrade, "highlight_upgrade")
Esempio n. 22
0
    def _prepare_physics(self, id_, block, x_coor, y_coor):
        """Prepare physics for the given barrier model.

        Args:
            id_ (str): Barrier id. Used as a prefix in rigid body id.
            block (world.block.Block): Block to set barrier on.
            x_coor (float): X coordinate to set block on.
            y_coor (float): Y coordinate to set block on.
        """
        rb_node = BulletRigidBodyNode(id_ + str(x_coor))
        rb_node.setMass(150)
        rb_node.addShape(BulletBoxShape(Vec3(0.05, 0.005, 0.05)))

        phys_np = block.rails_mod.attachNewNode(rb_node)
        phys_np.setPos(x_coor, y_coor, 0.07)
        phys_np.setH(random.randint(-20, 20))
        loader.loadModel(address("barrier1")).reparentTo(phys_np)  # noqa: F821

        base.world.phys_mgr.attachRigidBody(rb_node)  # noqa: F821
        self._rb_nodes.append(rb_node)
Esempio n. 23
0
    def show_relation(self, cohesion):
        """Show a relations ball above this character.

        The color of the ball shows the strength of cohesion
        between the chosen character and this one.

        Args:
            cohesion (float):
                Value of the cohesion between the
                chosen character and this one.
        """
        if self._cohesion_ball is None:
            self._cohesion_ball = loader.loadModel(  # noqa: F821
                address("relation_ball")
            )
            self._cohesion_ball.clearLight()
            base.world.sun.ignore_shadows(self._cohesion_ball)  # noqa: F821

            self._cohesion_ball.reparentTo(self.model)
            self._cohesion_ball.setZ(0.14)

        self._cohesion_ball.setColorScale(*RELATION_COLORS[cohesion // 20])
Esempio n. 24
0
    def __init__(self):
        self._train_pos = base.train.root_node.getPos()  # noqa: F821
        self._mod = loader.loadModel(address("city_hangar"))  # noqa: F821

        base.camera_ctrl.set_hangar_pos(self._mod)  # noqa: F821

        self._mod.reparentTo(base.train.model)  # noqa: F821

        lens = PerspectiveLens()
        lens.setNearFar(0, 10)
        lens.setFov(100, 100)

        lighter = Spotlight("hangar_light")
        lighter.setColor((1, 1, 1, 1))
        lighter.setLens(lens)
        self._lighter_np = self._mod.attachNewNode(lighter)
        self._lighter_np.setPos(-0.3, 0.65, 4)
        self._lighter_np.lookAt(base.train.model)  # noqa: F821

        render.setLight(self._lighter_np)  # noqa: F821

        flies = ParticleEffect()
        flies.loadConfig("effects/flies.ptf")
        flies.setPos(-0.465, 0.11, 0.17)
        flies.start(self._mod, render)  # noqa: F821

        lens = PerspectiveLens()
        lens.setNearFar(0, 50)
        lens.setFov(80, 80)

        lamp = Spotlight("hangar_light")
        lamp.setColor((0.7, 0.7, 0.7, 1))
        lamp.setLens(lens)
        lamp.setExponent(0.002)
        self._lamp_np = self._mod.attachNewNode(lamp)
        self._lamp_np.setPos(-0.47, 0.11, 0.195)
        self._lamp_np.setHpr(-180, -60, 0)
        render.setLight(self._lamp_np)  # noqa: F821
Esempio n. 25
0
    def _shot(self):
        """Make a cluster howitzer shot."""
        self.change_state()
        base.ignore("3")  # noqa: F82

        rocket = loader.loadModel(address("cluster_rocket"))  # noqa: F82
        rocket.reparentTo(self._model)
        rocket.setPos(0, -0.325, 0.3)
        rocket.setP(20)

        smoke = ParticleEffect()
        smoke.loadConfig("effects/smoke_tail.ptf")
        smoke.start(rocket, render)  # noqa: F821

        hiss_snd = base.sound_mgr.loadSfx("sounds/rocket_fly.ogg")  # noqa: F821
        base.sound_mgr.attachSoundToObject(hiss_snd, rocket)  # noqa: F821
        hiss_snd.play()

        open_snd = base.sound_mgr.loadSfx("sounds/cluster_open.ogg")  # noqa: F821
        base.sound_mgr.attachSoundToObject(open_snd, rocket)  # noqa: F821

        Sequence(
            Parallel(
                LerpPosInterval(rocket, 2, (0, 1.8, 3)),
                LerpHprInterval(rocket, 2, (0, 80, 0)),
            ),
            SoundInterval(open_snd),
            Func(self._clear_rocket, rocket, smoke, hiss_snd),
            Func(self._bombs_down),
        ).start()

        taskMgr.doMethodLater(  # noqa: F82
            45,
            base.accept,  # noqa: F82
            "unblock_cluster_launcher",
            extraArgs=["3", self.change_state],
        )
        base.train.make_shot("Cluster Howitzer")  # noqa: F82
Esempio n. 26
0
    def _bombs_down(self):
        """Move bombs down to the ground and do explosion."""
        move_par = Parallel()
        for num in range(4):
            bomb = loader.loadModel(address("hand_bomb1"))  # noqa: F82
            bomb.reparentTo(self._train_mod)
            bomb.setPos(*self._coors[num], 2)
            bomb.setScale(2)

            smoke = ParticleEffect()
            smoke.loadConfig("effects/smoke_tail.ptf")
            smoke.start(bomb, render)  # noqa: F821

            self._bombs.append((bomb, smoke))
            move_par.append(
                LerpPosInterval(
                    bomb, random.uniform(0.45, 0.7), (*self._coors[num], 0)
                ),
            )

        Sequence(
            move_par, Func(self._clear_grenades), Func(self._explode_grenades),
        ).start()
Esempio n. 27
0
def resume_extracts(text):
    """
    Takes the text format of the resume and returns all the values

    text: text format of the resume
    """
    conts = {}

    # Preprocessing the document
    text = utils.preprocess(text)

    # Extracting name
    conts['name'] = utils.name(text)

    # Extracting Address
    conts['address'] = utils.address(text)

    # Extracting mobile number
    conts['mobile'] = utils.mobile_number(text)

    # Extracting Email
    conts['email'] = utils.email(text)

    # Extracting github
    conts['github'] = utils.github(text)

    # Extracting linkedin
    conts['linkedin'] = utils.linkedin(text)

    # Provides the expertise list match
    conts['expertise'] = utils.expertise_match(text)

    # Provides the resume to job description simiarity
    conts['similarity_score'] = utils.jobdes_rsm_similarity(text)

    return conts
Esempio n. 28
0
    def prepare(self):
        """Load the character model and positionate it.

        Tweak collision solid and sounds.
        """
        animations = {
            name: address(self.class_ + "-" + name)
            for name in (
                "die",
                "gun_up",
                "incline1",
                "release_gun",
                "stand_and_aim",
                "stand",
                "surrender",
                "tread1",
                "turn_head1",
                "stunned",
                "cough",
                "celebrate",
            )
        }
        self.model = Actor(address(self.sex + "_" + self.class_), animations)
        self.model.enableBlend()
        self.model.setControlEffect("stand", 1)

        self.model.setPlayRate(0.8, "stand_and_aim")
        self.model.setPlayRate(0.6, "stand")
        self.model.loop("stand")
        self._current_anim = "stand"

        self._health_bar = HealthBar(self)

        base.team.init_relations(self)  # noqa: F821

        taskMgr.doMethodLater(  # noqa: F821
            random.randint(40, 60), self._idle_animation, self.id + "_idle_anim"
        )
        self._col_node = self._init_col_node(
            NO_MASK, MOUSE_MASK, CollisionCapsule(0, 0, 0, 0, 0, 0.035, 0.035)
        )
        self.shot_snd = self._set_shoot_snd(self.class_data["shot_snd"])
        self._cough_snd = base.sound_mgr.loadSfx(  # noqa: F821
            "sounds/{sex}_cough.ogg".format(sex=self.sex)
        )
        base.sound_mgr.attachSoundToObject(self._cough_snd, self.model)  # noqa: F821
        self._die_snd = base.sound_mgr.loadSfx(  # noqa: F821
            "sounds/combat/{sex}_death.ogg".format(sex=self.sex)
        )
        base.sound_mgr.attachSoundToObject(self._die_snd, self.model)  # noqa: F821

        for i in range(1, 4):
            yeah_snd1 = base.sound_mgr.loadSfx(  # noqa: F821
                "sounds/{sex}_yes{num}.ogg".format(sex=self.sex, num=str(i))
            )
            base.sound_mgr.attachSoundToObject(yeah_snd1, self.model)  # noqa: F821

            self._yeah_snds.append(yeah_snd1)

        if self.class_ == "soldier":
            z = 0.064 if self.sex == "male" else 0.062
        elif self.class_ == "raider":
            z = 0.047
        elif self.class_ == "anarchist":
            z = 0.06 if self.sex == "male" else 0.057

        self._shoot_anim = self._set_shoot_anim(
            (0.004, 0.045, z), 97, self.class_data["shots_num"]
        )
        taskMgr.doMethodLater(  # noqa: F821
            self.class_data["energy_spend"],
            self._reduce_energy,
            self.id + "_reduce_energy",
        )
        self._prepare_cohesion_particles()
        self._prepare_auras()
Esempio n. 29
0
    def __init__(self, description=None):
        self.root_node = render.attachNewNode("train_root")  # noqa: F821
        # node to hold camera and Sun
        self.node = self.root_node.attachNewNode("train")

        self.model = Actor(address("locomotive"))
        self.model.reparentTo(self.root_node)

        (
            self._clunk_snd,
            self._clunk2_snd,
            self._filter_open_snd,
            self._barrier_hit_snd,
            self._lighter_snd,
            self._creak_snds,
            self._rocket_explosions_snd,
            self._attack_started_snd,
            self._brake_snd,
        ) = self._set_sounds()

        self.ctrl = TrainController(self.model)
        self.ctrl.set_controls(self)

        self.parts = {
            "part_left":
            TrainPart(
                self.model,
                "part_left",
                positions=[(-0.063, -0.02, 0.147), (-0.063, 0.15, 0.147)],
                angle=90,
                arrow_pos=(-0.2, 0.09, 0.147),
            ),
            "part_right":
            TrainPart(
                self.model,
                "part_right",
                positions=[(0.063, -0.02, 0.147), (0.063, 0.15, 0.147)],
                angle=-90,
                arrow_pos=(0.2, 0.09, 0.147),
            ),
            "part_front":
            TrainPart(
                self.model,
                "part_front",
                positions=[(0, 0.41, 0.147)],
                angle=0,
                arrow_pos=(0, 0.55, 0.147),
            ),
            "part_rest":
            RestPart(self.model, "part_rest"),
        }

        self._lights = self._set_lights()
        self.lights_on = False

        self._gui = TrainGUI()

        self._durability = None

        if description:  # loading params from the game save
            self._max_durability = description["max_durability"]
            self.durability = description["durability"]
            self._miles = description["miles"] - 1
            self.node.setHpr(description["node_angle"])
        else:  # params for a new game
            self._max_durability = 1000
            self.durability = 1000
            self._miles = -1

        self.l_brake = False
        self.r_brake = False
        self._is_on_rusty = False
        self._creak_snd_cooldown = False
        self._phys_node = None
        self._phys_shape = None
        self._bomb_explosions = []
        self._floodlights_mat = None
        self._upgrade_highlight = 1
        self._highlight_step = 0.03

        self._upgrades = []
        self._pre_upgrade = None

        self._armor_plate = None
        self._grenade_launcher = None
        self._cluster_howitzer = None
        self._machine_gun = None

        self._bean = loader.loadModel(address("light_bean"))  # noqa: F821
        self._bean.reparentTo(self.model)
        self._bean.setPos(0, 1.25, 0.12)
        self._bean.hide()
        self._bean.setDepthWrite(False)

        (
            self._smoke,
            self._l_brake_sparks,
            self._r_brake_sparks,
            self._rocket_explosions,
            self._stop_steam,
            self._shot_sparks,
            self._love_particle,
        ) = self._prepare_particles()

        self.smoke_filtered = False
        self._smoke_filter = Actor(address("smoke_filter"))
        self._smoke_filter.hide()
        self._smoke_filter.reparentTo(self.model)
        self._smoke_filter.pose("open", 1)

        self.do_turn = 0
        self.cells = 7
Esempio n. 30
0
    def install_upgrade(self, upgrade):
        """Install the given upgrade on to the locomotive.

        Args:
            upgrade (dict): The upgrade description.
        """
        self._upgrades.append(upgrade["name"])

        if upgrade["name"] in ("Armor Plate", "Пластина Брони"):
            self._armor_plate = ArmorPlate(self.model)
            return

        if upgrade["name"] in ("Grenade Launcher", "Гранатомёт"):
            self._grenade_launcher = GrenadeLauncher(self.model)
            self._gui.activate_weapon(
                "Grenade Launcher",
                base.train.load_grenade_launcher  # noqa: F821
            )
            return

        if upgrade["name"] in ("Cluster Howitzer", "Ракетомёт"):
            self._cluster_howitzer = ClusterHowitzer(self.model)
            self._gui.activate_weapon(
                "Cluster Howitzer",
                base.train.load_cluster_howitzer  # noqa: F821
            )
            return

        if upgrade["name"] in ("Machine Gun", "Пулемёт"):
            self._machine_gun = MachineGun(self.model)
            self._gui.activate_weapon(
                "Machine Gun",
                base.train.load_machine_gun  # noqa: F821
            )
            return

        up_model = loader.loadModel(address(upgrade["model"]))  # noqa: F821
        up_model.reparentTo(self.model)

        if upgrade["name"] in ("Ram", "Таран"):
            taskMgr.remove("update_physics")  # noqa: F821
            taskMgr.remove("check_train_contacts")  # noqa: F821

            base.world.phys_mgr.removeCharacter(self._phys_shape)  # noqa: F821
            self._phys_node.removeNode()

            self._phys_shape = self._phys_shape = BulletCharacterControllerNode(
                BulletBoxShape(Vec3(0.095, 0.58, 0.1)), 10, "train_shape")

            self._phys_node = self.model.attachNewNode(self._phys_shape)
            self._phys_node.setPos(0, 0.03, 0.1)

            base.world.phys_mgr.attachCharacter(self._phys_shape)  # noqa: F821

            taskMgr.add(  # noqa: F821
                base.world.update_physics,  # noqa: F821
                "update_physics",
                extraArgs=[0.03],
                appendTask=True,
            )
            taskMgr.doMethodLater(  # noqa: F821
                0.1,
                self._check_contacts,
                "check_train_contacts",
                extraArgs=[base.world.phys_mgr,
                           self._phys_node.node()],  # noqa: F821
                appendTask=True,
            )
            return

        if upgrade["name"] in ("Floodlights", "Прожекторы"):
            self._floodlights_mat = up_model.findMaterial("lamp_glass")

            self._lights[0].node().setColor((1, 1, 1, 1))

            for light in self._lights[1:]:
                light.node().setAttenuation(1.7)

            return

        if upgrade["name"] in ("Fire Extinguishers", "Огнетушители"):
            taskMgr.doMethodLater(30, self._repair,
                                  "train_repair")  # noqa: F821
            return

        if upgrade["name"] in ("Sleeper", "Место"):
            self.cells += 1
            self.parts["part_rest"].cells += 1
            base.res_gui.update_chars()  # noqa: F821
            return

        if upgrade["name"] in ("Protectors", "Протекторы"):
            self._max_durability = 1500
            self.durability += 500
            SHOT_COORS[0][0] += 0.02
            self._gui.increase_max_duration()