示例#1
0
    def play_vfx(self, target, parameters):
        vfxnames = parameters.get('vfx', [])
        duration = parameters.get('duration', 1.0)
        if isinstance(vfxnames, str):
            vfxnames = [vfxnames]

        def create_vfx(vfxname):
            particles = ParticleEffect()
            if pman.is_frozen():
                vfxpath = f'assets/vfx/{vfxname}.ptf'
            else:
                vfxpath = f'.built_assets/vfx/{vfxname}.ptf'
            particles.loadConfig(vfxpath)
            particles.set_shader_auto(True)
            return particles

        vfx = [create_vfx(i) for i in vfxnames]

        def start_particle(effect):
            effect.start(parent=target.as_nodepath)

        return intervals.Parallel(*[
            intervals.Sequence(
                intervals.Func(start_particle, i),
                intervals.Wait(duration),
                intervals.Func(i.cleanup),
            ) for i in vfx
        ])
示例#2
0
 def _startMoveIval(self, entranceId, startT):
     self._stopMoveIval()
     unitVecs = (PM.Vec3(1, 0, 0), PM.Vec3(0, 1, 0), PM.Vec3(-1, 0, 0),
                 PM.Vec3(0, -1, 0))
     machineDistance = 4
     entranceDistance = 60
     startPos = unitVecs[entranceId] * entranceDistance
     endPos = unitVecs[entranceId] * machineDistance
     walkDur = (endPos - startPos
                ).length() / GameConsts.CogSettings.CogWalkSpeed.get()
     sceneRoot = self.getGame().getSceneRoot()
     moveIval = IG.Sequence(
         IG.Func(self.reparentTo, sceneRoot),
         IG.Func(self.setPos, startPos), IG.Func(self.lookAt, sceneRoot),
         IG.Func(self.loop, 'walk'),
         IG.LerpPosInterval(self, walkDur, endPos, startPos=startPos))
     interactIval = IG.Sequence(
         IG.Func(self.loop, 'neutral'),
         IG.Wait(GameConsts.CogSettings.CogMachineInteractDuration.get()))
     flyIval = IG.Sequence(
         IG.Func(self.pose, 'landing', 0),
         IG.LerpPosInterval(self,
                            GameConsts.CogSettings.CogFlyAwayDuration.get(),
                            self._getFlyAwayDest,
                            blendType='easeIn'))
     self._moveIval = IG.Sequence(moveIval, interactIval, flyIval)
     self._moveIval.start(globalClock.getFrameTime() - startT)
 def _fadeOutRepairSpotModel(self, locIndex):
     if locIndex in self._repairSpotIvals:
         self._repairSpotIvals[locIndex].pause()
     
     self._repairSpotHoles[locIndex].setTransparency(1, 100)
     ival = IG.Sequence(IG.Wait(DistributedPlayerSimpleShip.RepairSpotFadeAfter), IG.LerpColorScaleInterval(self._repairSpotHoles[locIndex], DistributedPlayerSimpleShip.RepairSpotFadeDur, Vec4(1.0, 1.0, 1.0, 0.0), blendType = 'easeInOut'))
     ival.start()
     self._repairSpotIvals[locIndex] = ival