Exemplo n.º 1
0
 def makeNodePath(self):
     if self.type == 0:
         self.nodePath = DroppedGag(self.uniqueName('gag'), base.race.banana)
         if self.billboard:
             self.nodePath.setBillboardPointEye()
         self.nodePath.setScale(0.9 * self.scale)
     if self.type == 1:
         self.nodePath = DroppedGag(self.uniqueName('gag'), base.race.banana)
         if self.billboard:
             self.nodePath.setBillboardPointEye()
         self.nodePath.setScale(4.0 * self.scale)
Exemplo n.º 2
0
 def makeNodePath(self):
     if self.type == 0:
         self.nodePath = DroppedGag(self.uniqueName('gag'), base.race.banana)
         if self.billboard:
             self.nodePath.setBillboardPointEye()
         self.nodePath.setScale(0.9 * self.scale)
     if self.type == 1:
         self.nodePath = DroppedGag(self.uniqueName('gag'), base.race.banana)
         if self.billboard:
             self.nodePath.setBillboardPointEye()
         self.nodePath.setScale(4.0 * self.scale)
 def __init__(self, parent, slot, testPos):
     DirectObject.DirectObject.__init__(self)
     self.parent = parent
     self.name = 'gag-' + str(slot)
     self.geom = DroppedGag(self.name, base.race.qbox)
     self.geom.dropShadow.setScale(0.69999999999999996)
     self.geom.setPos(testPos + Vec3(0, 0, -1))
     qc = CollisionTube(Point3(0, 0, -2.5), Point3(0, 0, 2.5), 1)
     self.gagnp = NodePath(CollisionNode(self.name))
     self.gagnp.node().addSolid(qc)
     self.gagnp.reparentTo(self.geom)
     self.gagnp.node().setIntoCollideMask(BitMask32(32768))
     self.gagnp.node().setFromCollideMask(BitMask32(32768))
     self.slot = slot
     self.type = 0
     self.accept('imIn-' + self.name, self.hitGag)
     self.pickupSound = base.loadSfx('phase_6/audio/sfx/KART_getGag.mp3')
     self.fadeout = None
Exemplo n.º 4
0
 def __init__(self, parent, slot, testPos):
     DirectObject.DirectObject.__init__(self)
     self.parent = parent
     self.name = 'gag-' + str(slot)
     self.geom = DroppedGag(self.name, base.race.qbox)
     self.geom.dropShadow.setScale(0.7)
     self.geom.setPos(testPos + Vec3(0, 0, -1))
     qc = CollisionTube(Point3(0, 0, -2.5), Point3(0, 0, 2.5), 1)
     self.gagnp = NodePath(CollisionNode(self.name))
     self.gagnp.node().addSolid(qc)
     self.gagnp.reparentTo(self.geom)
     self.gagnp.node().setIntoCollideMask(BitMask32(32768))
     self.gagnp.node().setFromCollideMask(BitMask32(32768))
     self.slot = slot
     self.type = 0
     self.accept('imIn-' + self.name, self.hitGag)
     self.pickupSound = base.loadSfx('phase_6/audio/sfx/KART_getGag.mp3')
     self.fadeout = None
     return
Exemplo n.º 5
0
class RaceGag(DirectObject.DirectObject):
    def __init__(self, parent, slot, testPos):
        DirectObject.DirectObject.__init__(self)
        self.parent = parent
        self.name = 'gag-' + str(slot)
        self.geom = DroppedGag(self.name, base.race.qbox)
        self.geom.dropShadow.setScale(0.7)
        self.geom.setPos(testPos + Vec3(0, 0, -1))
        qc = CollisionTube(Point3(0, 0, -2.5), Point3(0, 0, 2.5), 1)
        self.gagnp = NodePath(CollisionNode(self.name))
        self.gagnp.node().addSolid(qc)
        self.gagnp.reparentTo(self.geom)
        self.gagnp.node().setIntoCollideMask(BitMask32(32768))
        self.gagnp.node().setFromCollideMask(BitMask32(32768))
        self.slot = slot
        self.type = 0
        self.accept('imIn-' + self.name, self.hitGag)
        self.pickupSound = base.loadSfx('phase_6/audio/sfx/KART_getGag.ogg')
        self.fadeout = None
        return

    def delete(self):
        if self.fadeout:
            self.fadeout.finish()
            self.fadeout = None
        self.gagnp.removeNode()
        self.gagnp = None
        self.geom.delete()
        self.geom = None
        del self.parent
        self.ignore('imIn-' + self.name)
        return

    def getType(self):
        return self.type

    def isActive(self):
        if self.type:
            return True
        else:
            return False

    def genGag(self, spot, type):
        self.type = type
        fadein = self.geom.scaleInterval(1, 4)
        self.geom.setScale(0.001)
        self.geom.reparentTo(self.parent.geom)
        self.gagnp.reparentTo(self.geom)
        fadein.start()

    def hideGeom(self):
        self.geom.detachNode()

    def disableGag(self):
        self.gagnp.reparentTo(hidden)
        self.type = 0
        if self.fadeout:
            self.fadeout.finish()
        self.fadeout = Sequence(self.geom.scaleInterval(0.2, 0),
                                Func(self.hideGeom))
        self.fadeout.start()

    def hitGag(self, cevent):
        if not self.parent.currGag:
            self.pickupSound.play()
            self.parent.pickupGag(self.slot, self.type)
            self.disableGag()
Exemplo n.º 6
0
class DistributedGag(DistributedObject.DistributedObject):
    def __init__(self, cr):
        DistributedObject.DistributedObject.__init__(self, cr)
        self.nodePath = None
        self.billboard = False
        self.scale = 1
        self.shadow = True
        self.dropShadow = None
        self.type = 0
        return

    def delete(self):
        DistributedObject.DistributedObject.delete(self)
        self.nodePath.delete()
        self.ignoreAll()

    def announceGenerate(self):
        DistributedObject.DistributedObject.announceGenerate(self)
        if not self.nodePath:
            self.makeNodePath()
        self.delta = -globalClockDelta.networkToLocalTime(
            self.initTime, globalClock.getFrameTime(), 16,
            100) + globalClock.getFrameTime()
        if self.type == 0:
            self.name = self.uniqueName('tnt')
        elif self.type == 1:
            self.name = self.uniqueName('birthday-cake')
        self.nodePath.reparentTo(self.race.geom)
        if self.ownerId == localAvatar.doId:
            base.race.thrownGags[0].removeNode()
            base.race.thrownGags = base.race.thrownGags[1:]
            self.nodePath.setPos(self.pos[0], self.pos[1], self.pos[2])
        else:
            startPos = base.cr.doId2do[self.ownerId].getPos(render)
            endPos = Vec3(self.pos[0], self.pos[1], self.pos[2])
            throwIt = ProjectileInterval(self.nodePath,
                                         startPos=startPos,
                                         endPos=endPos,
                                         duration=1)
            throwIt.start()
        taskMgr.doMethodLater(0.8 - self.delta, self.addCollider,
                              self.uniqueName('addCollider'))

    def addCollider(self, t):
        bs = CollisionSphere(0, 0, 0, 2)
        bn = CollisionNode(self.name)
        self.bnp = NodePath(bn)
        self.bnp.reparentTo(self.nodePath)
        self.bnp.node().addSolid(bs)
        self.bnp.node().setIntoCollideMask(BitMask32(32768))
        self.bnp.node().setFromCollideMask(BitMask32(32768))
        self.accept('imIn-' + self.name, self.b_imHit)

    def b_imHit(self, cevent):
        self.ignoreAll()
        self.sendUpdate(
            'hitSomebody',
            [localAvatar.doId,
             globalClockDelta.getFrameNetworkTime(16, 100)])
        if self.type == 0:
            base.race.localKart.hitBanana()
        elif self.type == 1:
            base.race.localKart.hitPie()
        self.nodePath.hide()
        if hasattr(self, 'bnp'):
            self.bnp.removeNode()

    def hitSomebody(self, avId, timeStamp):
        if localAvatar.doId != avId:
            kart = DistributedVehicle.getKartFromAvId(avId)
            if kart:
                self.nodePath.hide()
                if hasattr(self, 'bnp'):
                    self.bnp.removeNode()
                kart.playSpin(timeStamp)

    def setActivateTime(self, actTime):
        self.activateTime = actTime

    def setInitTime(self, initTime):
        self.initTime = initTime

    def setRace(self, doId):
        self.race = base.cr.doId2do.get(doId)

    def setPos(self, x, y, z):
        self.pos = (x, y, z)

    def makeNodePath(self):
        if self.type == 0:
            self.nodePath = DroppedGag(self.uniqueName('gag'),
                                       base.race.banana)
            if self.billboard:
                self.nodePath.setBillboardPointEye()
            self.nodePath.setScale(0.9 * self.scale)
        if self.type == 1:
            self.nodePath = DroppedGag(self.uniqueName('gag'),
                                       base.race.banana)
            if self.billboard:
                self.nodePath.setBillboardPointEye()
            self.nodePath.setScale(4.0 * self.scale)

    def setOwnerId(self, ownerId):
        self.ownerId = ownerId

    def setType(self, type):
        self.type = type
Exemplo n.º 7
0
class RaceGag(DirectObject.DirectObject):
    __module__ = __name__

    def __init__(self, parent, slot, testPos):
        DirectObject.DirectObject.__init__(self)
        self.parent = parent
        self.name = 'gag-' + str(slot)
        self.geom = DroppedGag(self.name, base.race.qbox)
        self.geom.dropShadow.setScale(0.7)
        self.geom.setPos(testPos + Vec3(0, 0, -1))
        qc = CollisionTube(Point3(0, 0, -2.5), Point3(0, 0, 2.5), 1)
        self.gagnp = NodePath(CollisionNode(self.name))
        self.gagnp.node().addSolid(qc)
        self.gagnp.reparentTo(self.geom)
        self.gagnp.node().setIntoCollideMask(BitMask32(32768))
        self.gagnp.node().setFromCollideMask(BitMask32(32768))
        self.slot = slot
        self.type = 0
        self.accept('imIn-' + self.name, self.hitGag)
        self.pickupSound = base.loadSfx('phase_6/audio/sfx/KART_getGag.mp3')
        self.fadeout = None
        return

    def delete(self):
        if self.fadeout:
            self.fadeout.finish()
            self.fadeout = None
        self.gagnp.removeNode()
        self.gagnp = None
        self.geom.delete()
        self.geom = None
        del self.parent
        self.ignore('imIn-' + self.name)
        return

    def getType(self):
        return self.type

    def isActive(self):
        if self.type:
            return True
        else:
            return False

    def genGag(self, spot, type):
        self.type = type
        fadein = self.geom.scaleInterval(1, 4)
        self.geom.setScale(0.001)
        self.geom.reparentTo(self.parent.geom)
        self.gagnp.reparentTo(self.geom)
        fadein.start()

    def hideGeom(self):
        self.geom.detachNode()

    def disableGag(self):
        self.gagnp.reparentTo(hidden)
        self.type = 0
        if self.fadeout:
            self.fadeout.finish()
        self.fadeout = Sequence(self.geom.scaleInterval(0.2, 0), Func(self.hideGeom))
        self.fadeout.start()

    def hitGag(self, cevent):
        if not self.parent.currGag:
            self.pickupSound.play()
            self.parent.pickupGag(self.slot, self.type)
            self.disableGag()
Exemplo n.º 8
0
class DistributedGag(DistributedObject.DistributedObject):
    __module__ = __name__

    def __init__(self, cr):
        DistributedObject.DistributedObject.__init__(self, cr)
        self.nodePath = None
        self.billboard = False
        self.scale = 1
        self.shadow = True
        self.dropShadow = None
        self.type = 0
        return

    def delete(self):
        DistributedObject.DistributedObject.delete(self)
        self.nodePath.delete()
        self.ignoreAll()

    def announceGenerate(self):
        DistributedObject.DistributedObject.announceGenerate(self)
        if not self.nodePath:
            self.makeNodePath()
        self.delta = -globalClockDelta.networkToLocalTime(self.initTime, globalClock.getFrameTime(), 16, 100) + globalClock.getFrameTime()
        if self.type == 0:
            self.name = self.uniqueName('banana')
        elif self.type == 1:
            self.name = self.uniqueName('pie')
        self.nodePath.reparentTo(self.race.geom)
        if self.ownerId == localAvatar.doId:
            base.race.thrownGags[0].remove()
            base.race.thrownGags = base.race.thrownGags[1:]
            self.nodePath.setPos(self.pos[0], self.pos[1], self.pos[2])
        else:
            startPos = base.cr.doId2do[self.ownerId].getPos(render)
            endPos = Vec3(self.pos[0], self.pos[1], self.pos[2])
            throwIt = ProjectileInterval(self.nodePath, startPos=startPos, endPos=endPos, duration=1)
            throwIt.start()
        taskMgr.doMethodLater(0.8 - self.delta, self.addCollider, self.uniqueName('addCollider'))

    def addCollider(self, t):
        bs = CollisionSphere(0, 0, 0, 2)
        bn = CollisionNode(self.name)
        self.bnp = NodePath(bn)
        self.bnp.reparentTo(self.nodePath)
        self.bnp.node().addSolid(bs)
        self.bnp.node().setIntoCollideMask(BitMask32(32768))
        self.bnp.node().setFromCollideMask(BitMask32(32768))
        self.accept('imIn-' + self.name, self.b_imHit)

    def b_imHit(self, cevent):
        self.ignoreAll()
        self.sendUpdate('hitSomebody', [localAvatar.doId, globalClockDelta.getFrameNetworkTime(16, 100)])
        if self.type == 0:
            base.race.localKart.hitBanana()
        elif self.type == 1:
            base.race.localKart.hitPie()
        self.nodePath.hide()
        if hasattr(self, 'bnp'):
            self.bnp.remove()

    def hitSomebody(self, avId, timeStamp):
        if localAvatar.doId != avId:
            kart = DistributedVehicle.getKartFromAvId(avId)
            if kart:
                self.nodePath.hide()
                if hasattr(self, 'bnp'):
                    self.bnp.remove()
                kart.playSpin(timeStamp)

    def setActivateTime(self, actTime):
        self.activateTime = actTime

    def setInitTime(self, initTime):
        self.initTime = initTime

    def setRace(self, doId):
        self.race = base.cr.doId2do.get(doId)

    def setPos(self, x, y, z):
        self.pos = (x, y, z)

    def makeNodePath(self):
        if self.type == 0:
            self.nodePath = DroppedGag(self.uniqueName('gag'), base.race.banana)
            if self.billboard:
                self.nodePath.setBillboardPointEye()
            self.nodePath.setScale(0.9 * self.scale)
        if self.type == 1:
            self.nodePath = DroppedGag(self.uniqueName('gag'), base.race.banana)
            if self.billboard:
                self.nodePath.setBillboardPointEye()
            self.nodePath.setScale(4.0 * self.scale)

    def setOwnerId(self, ownerId):
        self.ownerId = ownerId

    def setType(self, type):
        self.type = type
Exemplo n.º 9
0
class DistributedGag(DistributedObject.DistributedObject):
    def __init__(self, cr):
        DistributedObject.DistributedObject.__init__(self, cr)
        self.nodePath = None
        self.billboard = False
        self.scale = 1
        self.shadow = True
        self.dropShadow = None
        self.type = 0

    def delete(self):
        DistributedObject.DistributedObject.delete(self)
        self.nodePath.delete()
        self.ignoreAll()

    def announceGenerate(self):
        DistributedObject.DistributedObject.announceGenerate(self)
        if not self.nodePath:
            self.makeNodePath()
        self.delta = -globalClockDelta.networkToLocalTime(
            self.initTime, globalClock.getFrameTime(), 16,
            100) + globalClock.getFrameTime()
        #print self.delta

        if self.type == 0:  #banana
            self.name = self.uniqueName("banana")
        elif self.type == 1:  #pie
            self.name = self.uniqueName("pie")

        self.nodePath.reparentTo(self.race.geom)
        if (self.ownerId == localAvatar.doId):
            base.race.thrownGags[0].remove()
            base.race.thrownGags = base.race.thrownGags[1:]
            self.nodePath.setPos(self.pos[0], self.pos[1], self.pos[2])
        else:
            startPos = base.cr.doId2do[self.ownerId].getPos(render)
            endPos = Vec3(self.pos[0], self.pos[1], self.pos[2])
            throwIt = ProjectileInterval(self.nodePath,
                                         startPos=startPos,
                                         endPos=endPos,
                                         duration=1)
            throwIt.start()
        taskMgr.doMethodLater(.8 - self.delta, self.addCollider,
                              self.uniqueName("addCollider"))

    def addCollider(self, t):
        bs = CollisionSphere(0, 0, 0, 2)
        bn = CollisionNode(self.name)
        self.bnp = NodePath(bn)
        self.bnp.reparentTo(self.nodePath)
        self.bnp.node().addSolid(bs)
        self.bnp.node().setIntoCollideMask(BitMask32(0x8000))
        self.bnp.node().setFromCollideMask(BitMask32(0x8000))
        #self.bnp.show()
        self.accept("imIn-" + self.name, self.b_imHit)

    def b_imHit(self, cevent):
        self.ignoreAll()
        self.sendUpdate("hitSomebody", [
            base.race.localKart.doId,
            globalClockDelta.getFrameNetworkTime(16, 100)
        ])
        if self.type == 0:
            base.race.localKart.hitBanana()
        elif self.type == 1:
            base.race.localKart.hitPie()
        self.nodePath.hide()
        if (hasattr(self, "bnp")):
            self.bnp.remove()

    def hitSomebody(self, kartId, timeStamp):
        if (base.race.localKart.doId != kartId):
            assert kartId in base.cr.doId2do
            #Okay, this is correct
            self.nodePath.hide()
            if (hasattr(self, "bnp")):
                self.bnp.remove()
            base.cr.doId2do[kartId].playSpin(timeStamp)

    def setActivateTime(self, actTime):
        self.activateTime = actTime

    def setInitTime(self, initTime):
        self.initTime = initTime

    def setRace(self, doId):
        self.race = base.cr.doId2do.get(doId)

    # The handler that catches the initial position established on the AI
    def setPos(self, x, y, z):
        #print x, ": ", y, ": ", z
        self.pos = (x, y, z)

    def makeNodePath(self):
        if self.type == 0:  #banana
            self.nodePath = DroppedGag(self.uniqueName("gag"),
                                       base.race.banana)
            if self.billboard:
                self.nodePath.setBillboardPointEye()
            self.nodePath.setScale(0.9 * self.scale)
        if self.type == 1:  #pie
            self.nodePath = DroppedGag(self.uniqueName("gag"),
                                       base.race.banana)
            if self.billboard:
                self.nodePath.setBillboardPointEye()
            self.nodePath.setScale(4.0 * self.scale)

    def setOwnerId(self, ownerId):
        self.ownerId = ownerId

    def setType(self, type):
        self.type = type