Example #1
0
def collide(self, other):
    if ((not self.m_done) and other.hasFlag("Player")):
        #Get the message property.
        message = self.getProperty("message", 0, "<message>")

        if (message != "<message>"):
            #If it was given, show it.
            GraLL2.showMessage(message.replace("\\n", "\n"),
                               float(self.getProperty("time", 0, "5")))
        else:
            #Otherwise show message from messageDict.
            showMessageFromDict(self.getProperty("messageKey", 0, "default"))

        #Don't to it again. :P
        self.m_done = True
        Ngf.destroyObject(self)
Example #2
0
def init(self):
    #Sound we play when moving.
    self.m_playSound = parseBool(self.getProperty("playSound", 0, "1"))

    if (self.m_playSound):
        self.v_sound = GraLL2.createSound("DoorOpen.wav", True, False)
        self.attachSound(self.v_sound)
        self.v_sound.setReferenceDistance(1.2)

    #Methods.
    self.open = open
    self.close = close
Example #3
0
def init(self):
    #Create a Pad mesh, set the JumpPad material, and make a Box physics body.
    self.createMesh("Template_Pad.mesh")
    self.setMaterial("Objects/JumpPad")
    self.createBody(GraLL2.CollisionShape.Box, GraLL2.BodyType.Static,
                    GraLL2.CollisionFlags.Static)

    #We get the jump impulse from the properties.
    self.m_impulse = float(self.getProperty("impulse", 0, "15"))

    #Create sound.
    self.v_sound = GraLL2.createSound("JumpPad.wav", False, False)
    self.attachSound(self.v_sound)
    self.v_sound.setReferenceDistance(1.2)
    self.v_sound.setGain(7)
Example #4
0
def init(self):
    #Get the properties.
    soundFile = self.getProperty("soundFile", 0, "Default.wav")
    loop = parseBool(self.getProperty("loop", 0, "1"))
    stream = parseBool(self.getProperty("stream", 0, "1"))

    #Create sound.
    self.v_sound = GraLL2.createSound(soundFile, loop, stream)
    self.v_sound.setPosition(self.getPosition())

    #Set sound properties.
    self.v_sound.setDistanceValues(
        float(self.getProperty("attenuation", 0, "20")),
        float(self.getProperty("attenuation", 1, "4")),
        float(self.getProperty("attenuation", 2, "6"))
    )
    self.v_sound.setGain(
        float(self.getProperty("gain", 0, "1"))
    )
Example #5
0
def init(self):
    #Create a Pad mesh, set the JumpPad material, and make a Box physics body.
    self.createMesh("Template_Pad.mesh")
    self.setMaterial("Objects/JumpPad")
    self.createBody(GraLL2.CollisionShape.Box, GraLL2.BodyType.Static,
                    GraLL2.CollisionFlags.Static)

    #Create Player detection cast.
    unitY = self.getOrientation() * Ngf.Vector3.UNIT_Y
    self.createBoxCast(Ngf.Vector3(0.3, 0.1, 0.3), 1.2, 
            self.getPosition() + 0.35*unitY,
            self.getPosition() + 0.45*unitY)

    #We get the jump impulse from the properties.
    self.m_impulse = float(self.getProperty("impulse", 0, "15")) * 0.5

    #Create sound.
    self.v_sound = GraLL2.createSound("JumpPad.wav", False, False)
    self.attachSound(self.v_sound)
    self.v_sound.setReferenceDistance(1.2)
    self.v_sound.setGain(7)
Example #6
0
def showMessageFromDict(key):
    pair = messageDict[key]
    message = pair[0]
    time = pair[1]

    GraLL2.showMessage(message, time)
Example #7
0
def destroy(self):
    if (self.m_playSound):
        GraLL2.destroySound(self.v_sound)
Example #8
0
def collide(self, other):
    if (other.hasFlag("Player")):
        if (self.m_unTouched):
            #We win! :D
            self.m_unTouched = False
            GraLL2.winLevel(True)
Example #9
0
def destroy(self):
    GraLL2.destroySound(self.v_sound)