class FiredProjectile(LobProjectile):

    FlameMdl = "phase_14/models/props/flame.bam"
    ImpactSoundPath = "phase_14/audio/sfx/SA_hot_air_flame_hit.ogg"
    FlameEmitSfx = "phase_14/audio/sfx/SA_hot_air_flame_emit.ogg"

    def __init__(self, cr):
        LobProjectile.__init__(self, cr)
        self.emitSound = None
        self.scaleIval = None

    def announceGenerate(self):
        LobProjectile.announceGenerate(self)
        self.setLightOff(1)
        self.hide(CIGlobals.ShadowCameraBitmask)

        fireroot = self.attachNewNode('fireroot')
        fireroot.setScale(1.25)
        fireroot.setBillboardAxis()
        glow = loader.loadModel(GlowMdl)
        glow.reparentTo(fireroot)
        glow.setTransparency(1)
        glow.setColorScale(1, 0.5, 0, 0.5)
        glow.setY(-0.01)
        glow.setTwoSided(1)
        glow.setScale(0.85)
        fire = SuitAttacks.getSuitParticle("fire").copyTo(fireroot)

        if not self.emitSound:
            self.emitSound = base.loadSfxOnNode(self.FlameEmitSfx, self)
        self.emitSound.play()

        self.scaleIval = LerpScaleInterval(fireroot, 0.2, Point3(1.25),
                                           Point3(0.01))
        self.scaleIval.start()

    def disable(self):
        if self.scaleIval:
            self.scaleIval.finish()
        self.scaleIval = None
        if self.emitSound:
            base.audio3d.detachSound(self.emitSound)
        self.emitSound = None
        LobProjectile.disable(self)

    def impact(self, pos, lastPos):
        CIGlobals.makeDustCloud(pos,
                                scale=(0.25, 0.9, 1),
                                sound=self.impactSound,
                                color=(0.2, 0.2, 0.2, 0.6))
Esempio n. 2
0
class FiredProjectile(LobProjectile):

    ImpactSoundPath = "phase_14/audio/sfx/SA_hot_air_flame_hit.ogg"
    FlameEmitSfx = "phase_14/audio/sfx/SA_hot_air_flame_emit.ogg"

    def __init__(self, cr):
        LobProjectile.__init__(self, cr)
        self.emitSound = None
        self.scaleIval = None

    def announceGenerate(self):
        LobProjectile.announceGenerate(self)
        self.setLightOff(1)
        self.hide(CIGlobals.ShadowCameraBitmask)
        self.hide(CIGlobals.ReflectionCameraBitmask)

        fireroot = getFireProj().copyTo(self)

        if not self.emitSound:
            self.emitSound = base.loadSfxOnNode(self.FlameEmitSfx, self)
        self.emitSound.play()

        self.scaleIval = LerpScaleInterval(fireroot, 0.2, Point3(1.25),
                                           Point3(0.01))
        self.scaleIval.start()

    def disable(self):
        if self.scaleIval:
            self.scaleIval.finish()
        self.scaleIval = None
        if self.emitSound:
            base.audio3d.detachSound(self.emitSound)
        self.emitSound = None
        LobProjectile.disable(self)

    def impact(self, pos, lastPos):
        CIGlobals.makeDustCloud(pos,
                                scale=0.25,
                                sound=self.impactSound,
                                color=(0.2, 0.2, 0.2, 0.6))
Esempio n. 3
0
class Droppable:
    """An object that can be dropped onto. (Part of the Drag & Drop protocol.)

    Initially droppable is disabled, users must call set_droppable(True) to
    enable it.

    """
    def __init__(self):

        pass        

    def drop(self,event):
        """A draggable has been dropped onto this droppable.
        Subclasses should extend this if they want to do something."""
        
        # Finish any intervals that are playing.
        # FIXME: this tightly couples Droppable to Highlightable. Move this code
        # into highlightable.
        if  hasattr(self,'scaleDownInterval') and self.scaleDownInterval.isPlaying():
            self.scaleDownInterval.finish()
        elif hasattr(self,'scaleUpInterval') and self.scaleUpInterval.isPlaying():
            self.scaleUpInterval.finish()
        # Reset the scale.
        if hasattr(self,'prevScale'):
            self.setScale(self.prevScale)                
        
    def set_droppable(self,b):
        """Enable or disable dropping onto the NodePath."""

        # FIXME: move this into Highlightable.
        # Finish any intervals that are playing.
        if  hasattr(self,'scaleDownInterval') and self.scaleDownInterval.isPlaying():
            self.scaleDownInterval.finish()
        elif hasattr(self,'scaleUpInterval') and self.scaleUpInterval.isPlaying():
            self.scaleUpInterval.finish()
        # Reset the scale.
        if hasattr(self,'prevScale'):
            self.setScale(self.prevScale)
        
        if b is True:
            self.np.setPythonTag('droppable',self)
        else:
            self.np.clearPythonTag('droppable')

    def highlight(self):
        """Subclasses should override this method to implement custom drag-over
        behaviour."""
        
        # If we are already scaling up, do nothing.
        if  hasattr(self,'scaleUpInterval') and self.scaleUpInterval.isPlaying():
            return
        # If we are in the process of scaling down, finish it off immediately.
        if  hasattr(self,'scaleDownInterval') and self.scaleDownInterval.isPlaying():
            self.scaleDownInterval.finish()
  
        from direct.interval.IntervalGlobal import LerpScaleInterval        
        self.prevScale = self.getScale()
        self.scaleUpInterval = LerpScaleInterval(self.np, duration=0.2, scale=self.getScale()*1.2, startScale=self.getScale())
        self.scaleUpInterval.start()
    
    def unhighlight(self):
        """Subclasses should override this method to implement custom drag-over
        behaviour."""
        
        # If we are already scaling down, do nothing.
        if  hasattr(self,'scaleDownInterval') and self.scaleDownInterval.isPlaying():
            return
        # If we are in the process of scaling up, stop.
        if  hasattr(self,'scaleUpInterval') and self.scaleUpInterval.isPlaying():
            self.scaleUpInterval.pause()        
        from direct.interval.IntervalGlobal import LerpScaleInterval
        self.scaleDownInterval = LerpScaleInterval(self.np, duration=0.2, scale=self.prevScale, startScale=self.getScale())
        self.scaleDownInterval.start()
Esempio n. 4
0
class Highlightable:   
    """A mixin class that receives notifications from zcanvas when the mouse
    pointer enters or leaves its nodepath. These events can be used to highlight
    a nodepath as the mouse cursor moves over it. The default implementation
    scales the nodepath to 120% of its original size over a 0.2 second interval
    when the mouse enters the nodepath, and scales it back over the same amount
    of time when the mouse leaves."""

    def __init__(self):
            
        pass

    def highlight(self):
        """The mouse pointer has entered the bounds of this nodepath. Subclasses
        should override this method to implement custom mouse-over behaviour.
        
        """        
        # If we are already scaling up, do nothing.
        if  hasattr(self,'scaleUpInterval') and self.scaleUpInterval.isPlaying():
            return

        # If we are in the process of scaling down, finish it off immediately.
        if  hasattr(self,'scaleDownInterval') and self.scaleDownInterval.isPlaying():
            self.scaleDownInterval.finish()
        
        from direct.interval.IntervalGlobal import LerpScaleInterval        
        self.prevScale = self.getScale()
        self.scaleUpInterval = LerpScaleInterval(self.np, duration=0.2, scale=self.getScale()*1.2, startScale=self.getScale())
        self.scaleUpInterval.start()

    def unhighlight(self):
        """The mouse pointer has left the bounds of this nodepath. Subclasses 
        should override this method to implement custom mouse-over behaviour.
        
        """
        # If we are already scaling down, do nothing.
        if  hasattr(self,'scaleDownInterval') and self.scaleDownInterval.isPlaying():
            return

        # If we are in the process of scaling up, stop.
        if  hasattr(self,'scaleUpInterval') and self.scaleUpInterval.isPlaying():
            self.scaleUpInterval.pause()
        
        from direct.interval.IntervalGlobal import LerpScaleInterval
        self.scaleDownInterval = LerpScaleInterval(self.np, duration=0.2, scale=self.prevScale, startScale=self.getScale())
        self.scaleDownInterval.start()

    def set_highlightable(self,boolean):
        """Enable or disable mouse-over highlighting of this nodepath. (When
        disabled, the highlight and unhighlight methods will not be
        called.)
        
        """    
        # Finish any intervals that are playing.
        if  hasattr(self,'scaleDownInterval') and self.scaleDownInterval.isPlaying():
            self.scaleDownInterval.finish()
        elif hasattr(self,'scaleUpInterval') and self.scaleUpInterval.isPlaying():
            self.scaleUpInterval.finish()
    
        # Reset the scale.
        if hasattr(self,'prevScale'):
            self.setScale(self.prevScale)

        if boolean:
            self.np.setPythonTag("highlightable",self)
        else:    
            self.np.clearPythonTag("highlightable")