def makeCrunchTrack(self):
        toonId = self.toon

        toon = base.cr.doId2do.get(toonId)
        if not toon:
            return

        self.virtualSuit.lookAt(toon)

        if self.virtualSuit.style.body in ['a', 'b']:
            throwDelay = 3
        elif self.virtualSuit.style.body == 'c':
            throwDelay = 2.3
        else:
            throwDelay = 2

        numberNames = ['one',
         'two',
         'three',
         'four',
         'five',
         'six']
        BattleParticles.loadParticles()
        numberSpill1 = BattleParticles.createParticleEffect(file='numberSpill')
        numberSpill2 = BattleParticles.createParticleEffect(file='numberSpill')
        spillTexture1 = random.choice(numberNames)
        spillTexture2 = random.choice(numberNames)
        BattleParticles.setEffectTexture(numberSpill1, 'audit-' + spillTexture1)
        BattleParticles.setEffectTexture(numberSpill2, 'audit-' + spillTexture2)
        numberSpillTrack1 = getPartTrack(numberSpill1, 1.1, 2.2, [numberSpill1, self.virtualSuit, 0])
        numberSpillTrack2 = getPartTrack(numberSpill2, 1.5, 1.0, [numberSpill2, self.virtualSuit, 0])
        numberSprayTracks = Parallel()
        numOfNumbers = random.randint(5, 9)
        for i in xrange(0, numOfNumbers - 1):
            nextSpray = BattleParticles.createParticleEffect(file='numberSpray')
            nextTexture = random.choice(numberNames)
            BattleParticles.setEffectTexture(nextSpray, 'audit-' + nextTexture)
            nextStartTime = random.random() * 0.6 + 3.03
            nextDuration = random.random() * 0.4 + 1.4
            nextSprayTrack = getPartTrack(nextSpray, nextStartTime, nextDuration, [nextSpray, self.virtualSuit, 0])
            numberSprayTracks.append(nextSprayTrack)

        def throwProp(prop):
            if not self.virtualSuit:
                return

            toon = self.cr.doId2do.get(toonId)
            if not toon:
                self.cleanupProp(prop, False)
                self.finishPropAttack()
                return

            self.virtualSuit.lookAt(toon)

            prop.wrtReparentTo(render)

            hitPos = toon.getPos() + Vec3(0, 0, 2.5)
            distance = (prop.getPos() - hitPos).length()
            speed = 50.0

            throwSequence = Sequence(
                prop.posInterval(distance / speed, hitPos),
                Func(self.cleanupProp, prop, False)
            )

            throwSequence.start()

        numberTracks = Parallel()
        for i in xrange(0, numOfNumbers):
            texture = random.choice(numberNames)
            next = copyProp(BattleParticles.getParticle('audit-' + texture))
            next.reparentTo(self.virtualSuit.getRightHand())
            next.setScale(0.01, 0.01, 0.01)
            next.setColor(Vec4(0.0, 0.0, 0.0, 1.0))
            next.setPos(random.random() * 0.6 - 0.3, random.random() * 0.6 - 0.3, random.random() * 0.6 - 0.3)
            next.setHpr(VBase3(-1.15, 86.58, -76.78))

            # Make prop virtual:
            next.setColorScale(1.0, 0.0, 0.0, 0.8)
            next.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd))

            # Prop collisions:
            colNode = CollisionNode(self.uniqueName('SuitAttack'))
            colNode.setTag('damage', str(self.attackInfo[1]))

            bounds = next.getBounds()
            center = bounds.getCenter()
            radius = bounds.getRadius()
            sphere = CollisionSphere(center.getX(), center.getY(), center.getZ(), radius)
            sphere.setTangible(0)
            colNode.addSolid(sphere)
            colNode.setIntoCollideMask(WallBitmask)
            next.attachNewNode(colNode)

            numberTrack = Sequence(
                Wait(throwDelay),
                Parallel(
                    LerpScaleInterval(next, 0.6, Point3(1.0, 1.0, 1.0)),
                    Func(throwProp, next),
                ),
            )
            numberTracks.append(numberTrack)

            suitTrack = Parallel(
                    Func(self.sayFaceoffTaunt),
                    Sequence(
                        ActorInterval(self.virtualSuit, 'throw-object'),
                        ActorInterval(self.virtualSuit, 'neutral')
                    ),
            )

            return Sequence(
                Parallel(
                    suitTrack,
                    numberSpillTrack1,
                    numberSpillTrack2,
                    numberTracks,
                    numberSprayTracks
                ),
                Func(self.virtualSuit.loop, 'walk', 0),
                Func(self.virtualSuit.setHpr, 0, 0, 0),
            )
示例#2
0
    def makeCrunchTrack(self):
        toonId = self.toon

        toon = base.cr.doId2do.get(toonId)
        if not toon:
            return

        self.virtualSuit.lookAt(toon)

        if self.virtualSuit.style.body in ['a', 'b']:
            throwDelay = 3
        elif self.virtualSuit.style.body == 'c':
            throwDelay = 2.3
        else:
            throwDelay = 2

        numberNames = ['one', 'two', 'three', 'four', 'five', 'six']
        BattleParticles.loadParticles()
        numberSpill1 = BattleParticles.createParticleEffect(file='numberSpill')
        numberSpill2 = BattleParticles.createParticleEffect(file='numberSpill')
        spillTexture1 = random.choice(numberNames)
        spillTexture2 = random.choice(numberNames)
        BattleParticles.setEffectTexture(numberSpill1,
                                         'audit-' + spillTexture1)
        BattleParticles.setEffectTexture(numberSpill2,
                                         'audit-' + spillTexture2)
        numberSpillTrack1 = getPartTrack(numberSpill1, 1.1, 2.2,
                                         [numberSpill1, self.virtualSuit, 0])
        numberSpillTrack2 = getPartTrack(numberSpill2, 1.5, 1.0,
                                         [numberSpill2, self.virtualSuit, 0])
        numberSprayTracks = Parallel()
        numOfNumbers = random.randint(5, 9)
        for i in xrange(0, numOfNumbers - 1):
            nextSpray = BattleParticles.createParticleEffect(
                file='numberSpray')
            nextTexture = random.choice(numberNames)
            BattleParticles.setEffectTexture(nextSpray, 'audit-' + nextTexture)
            nextStartTime = random.random() * 0.6 + 3.03
            nextDuration = random.random() * 0.4 + 1.4
            nextSprayTrack = getPartTrack(nextSpray, nextStartTime,
                                          nextDuration,
                                          [nextSpray, self.virtualSuit, 0])
            numberSprayTracks.append(nextSprayTrack)

        def throwProp(prop):
            if not self.virtualSuit:
                return

            toon = self.cr.doId2do.get(toonId)
            if not toon:
                self.cleanupProp(prop, False)
                self.finishPropAttack()
                return

            self.virtualSuit.lookAt(toon)

            prop.wrtReparentTo(render)

            hitPos = toon.getPos() + Vec3(0, 0, 2.5)
            distance = (prop.getPos() - hitPos).length()
            speed = 50.0

            throwSequence = Sequence(
                prop.posInterval(distance / speed, hitPos),
                Func(self.cleanupProp, prop, False))

            throwSequence.start()

        numberTracks = Parallel()
        for i in xrange(0, numOfNumbers):
            texture = random.choice(numberNames)
            next = copyProp(BattleParticles.getParticle('audit-' + texture))
            next.reparentTo(self.virtualSuit.getRightHand())
            next.setScale(0.01, 0.01, 0.01)
            next.setColor(Vec4(0.0, 0.0, 0.0, 1.0))
            next.setPos(random.random() * 0.6 - 0.3,
                        random.random() * 0.6 - 0.3,
                        random.random() * 0.6 - 0.3)
            next.setHpr(VBase3(-1.15, 86.58, -76.78))

            # Make prop virtual:
            next.setColorScale(1.0, 0.0, 0.0, 0.8)
            next.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd))

            # Prop collisions:
            colNode = CollisionNode(self.uniqueName('SuitAttack'))
            colNode.setTag('damage', str(self.attackInfo[1]))

            bounds = next.getBounds()
            center = bounds.getCenter()
            radius = bounds.getRadius()
            sphere = CollisionSphere(center.getX(), center.getY(),
                                     center.getZ(), radius)
            sphere.setTangible(0)
            colNode.addSolid(sphere)
            colNode.setIntoCollideMask(WallBitmask)
            next.attachNewNode(colNode)

            numberTrack = Sequence(
                Wait(throwDelay),
                Parallel(
                    LerpScaleInterval(next, 0.6, Point3(1.0, 1.0, 1.0)),
                    Func(throwProp, next),
                ),
            )
            numberTracks.append(numberTrack)

            suitTrack = Parallel(
                Func(self.sayFaceoffTaunt),
                Sequence(ActorInterval(self.virtualSuit, 'throw-object'),
                         ActorInterval(self.virtualSuit, 'neutral')),
            )

            return Sequence(
                Parallel(suitTrack, numberSpillTrack1, numberSpillTrack2,
                         numberTracks, numberSprayTracks),
                Func(self.virtualSuit.loop, 'walk', 0),
                Func(self.virtualSuit.setHpr, 0, 0, 0),
            )
    def makeWriteOffTrack(self):
        pad = BattleProps.globalPropPool.getProp('pad')
        pad.setScale(1.89)
        pencil = BattleProps.globalPropPool.getProp('pencil')
        BattleParticles.loadParticles()
        checkmark = copyProp(BattleParticles.getParticle('checkmark'))
        checkmark.setBillboardPointEye()

        # Make prop virtual:
        pad.setColorScale(1.0, 0.0, 0.0, 0.8)
        pad.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd))
        pencil.setColorScale(1.0, 0.0, 0.0, 0.8)
        pencil.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd))
        checkmark.setColorScale(1.0, 0.0, 0.0, 0.8)
        checkmark.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd))

        # Prop collisions:
        colNode = CollisionNode(self.uniqueName('SuitAttack'))
        colNode.setTag('damage', str(self.attackInfo[1]))

        bounds = checkmark.getBounds()
        center = bounds.getCenter()
        radius = bounds.getRadius()
        sphere = CollisionSphere(center.getX(), center.getY(), center.getZ(), radius)
        sphere.setTangible(0)
        colNode.addSolid(sphere)
        colNode.setIntoCollideMask(WallBitmask)
        checkmark.attachNewNode(colNode)

        toonId = self.toon

        toon = base.cr.doId2do.get(toonId)
        if not toon:
            return

        self.virtualSuit.lookAt(toon)

        if self.virtualSuit.style.body in ['a', 'b']:
            throwDelay = 3
        elif self.virtualSuit.style.body == 'c':
            throwDelay = 2.3
        else:
            throwDelay = 2

        def throwProp():
            if not self.virtualSuit:
                return

            toon = self.cr.doId2do.get(toonId)
            if not toon:
                self.cleanupProp(checkmark, False)
                self.finishPropAttack()
                return

            self.virtualSuit.lookAt(toon)

            checkmark.wrtReparentTo(render)

            hitPos = toon.getPos() + Vec3(0, 0, 2.5)
            distance = (checkmark.getPos() - hitPos).length()
            speed = 50.0

            if self.attackProp == 'teeth':
                throwSequence = Sequence(
                    Parallel(
                        checkmark.posInterval(distance / speed, hitPos),
                        ActorInterval(checkmark, 'teeth', duration=distance / speed),
                    ),
                    Func(self.cleanupProp, checkmark, False),
                )
            else:
                throwSequence = Sequence(
                    checkmark.posInterval(distance / speed, hitPos),
                    Func(self.cleanupProp, checkmark, False)
                )

            throwSequence.start()

        pencilTrack = Sequence(
            Wait(0.5),
            Func(pencil.setPosHpr, -0.47, 1.08, 0.28, 21.045, 12.702, -176.374),
            Func(pencil.reparentTo, self.virtualSuit.getRightHand()),
            LerpScaleInterval(pencil, 0.5, Point3(1.5, 1.5, 1.5),
                              startScale=Point3(0.01)),
            Wait(throwDelay),
            Func(checkmark.reparentTo, render),
            Func(checkmark.setScale, 1.6),
            Func(checkmark.setPosHpr, pencil, 0, 0, 0, 0, 0, 0),
            Func(checkmark.setP, 0),
            Func(checkmark.setR, 0),
            Func(throwProp),
            Wait(0.3),
            LerpScaleInterval(pencil, 0.5, Point3(0.01, 0.01, 0.01)),
            Func(pencil.removeNode),
        )

        suitTrack = Sequence(
            ActorInterval(self.virtualSuit, 'hold-pencil'),
            Func(self.virtualSuit.loop, 'neutral', 0),
        )

        soundTrack = Sequence(
            Wait(2.3),
            SoundInterval(self.writeOffSfx, duration=0.9, node=self.virtualSuit),
            SoundInterval(self.dingSfx, node=self.virtualSuit)
        )

        padTrack = Track(
            (0.0, Func(pad.setPosHpr, -0.25, 1.38, -0.08, -19.078, -6.603, -171.594)),
            (0.4, Func(pad.reparentTo, self.virtualSuit.getLeftHand())),
            (3.0, Func(pad.removeNode)),
        )

        track = Sequence(
            Parallel(
                suitTrack, soundTrack, padTrack, pencilTrack, Func(self.sayFaceoffTaunt)
            ),
            Func(self.virtualSuit.loop, 'walk', 0)
        )
        return track
示例#4
0
    def makeWriteOffTrack(self):
        pad = BattleProps.globalPropPool.getProp('pad')
        pad.setScale(1.89)
        pencil = BattleProps.globalPropPool.getProp('pencil')
        BattleParticles.loadParticles()
        checkmark = copyProp(BattleParticles.getParticle('checkmark'))
        checkmark.setBillboardPointEye()

        # Make prop virtual:
        pad.setColorScale(1.0, 0.0, 0.0, 0.8)
        pad.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd))
        pencil.setColorScale(1.0, 0.0, 0.0, 0.8)
        pencil.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd))
        checkmark.setColorScale(1.0, 0.0, 0.0, 0.8)
        checkmark.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd))

        # Prop collisions:
        colNode = CollisionNode(self.uniqueName('SuitAttack'))
        colNode.setTag('damage', str(self.attackInfo[1]))

        bounds = checkmark.getBounds()
        center = bounds.getCenter()
        radius = bounds.getRadius()
        sphere = CollisionSphere(center.getX(), center.getY(), center.getZ(),
                                 radius)
        sphere.setTangible(0)
        colNode.addSolid(sphere)
        colNode.setIntoCollideMask(WallBitmask)
        checkmark.attachNewNode(colNode)

        toonId = self.toon

        toon = base.cr.doId2do.get(toonId)
        if not toon:
            return

        self.virtualSuit.lookAt(toon)

        if self.virtualSuit.style.body in ['a', 'b']:
            throwDelay = 3
        elif self.virtualSuit.style.body == 'c':
            throwDelay = 2.3
        else:
            throwDelay = 2

        def throwProp():
            if not self.virtualSuit:
                return

            toon = self.cr.doId2do.get(toonId)
            if not toon:
                self.cleanupProp(checkmark, False)
                self.finishPropAttack()
                return

            self.virtualSuit.lookAt(toon)

            checkmark.wrtReparentTo(render)

            hitPos = toon.getPos() + Vec3(0, 0, 2.5)
            distance = (checkmark.getPos() - hitPos).length()
            speed = 50.0

            if self.attackProp == 'teeth':
                throwSequence = Sequence(
                    Parallel(
                        checkmark.posInterval(distance / speed, hitPos),
                        ActorInterval(checkmark,
                                      'teeth',
                                      duration=distance / speed),
                    ),
                    Func(self.cleanupProp, checkmark, False),
                )
            else:
                throwSequence = Sequence(
                    checkmark.posInterval(distance / speed, hitPos),
                    Func(self.cleanupProp, checkmark, False))

            throwSequence.start()

        pencilTrack = Sequence(
            Wait(0.5),
            Func(pencil.setPosHpr, -0.47, 1.08, 0.28, 21.045, 12.702,
                 -176.374),
            Func(pencil.reparentTo, self.virtualSuit.getRightHand()),
            LerpScaleInterval(pencil,
                              0.5,
                              Point3(1.5, 1.5, 1.5),
                              startScale=Point3(0.01)),
            Wait(throwDelay),
            Func(checkmark.reparentTo, render),
            Func(checkmark.setScale, 1.6),
            Func(checkmark.setPosHpr, pencil, 0, 0, 0, 0, 0, 0),
            Func(checkmark.setP, 0),
            Func(checkmark.setR, 0),
            Func(throwProp),
            Wait(0.3),
            LerpScaleInterval(pencil, 0.5, Point3(0.01, 0.01, 0.01)),
            Func(pencil.removeNode),
        )

        suitTrack = Sequence(
            ActorInterval(self.virtualSuit, 'hold-pencil'),
            Func(self.virtualSuit.loop, 'neutral', 0),
        )

        soundTrack = Sequence(
            Wait(2.3),
            SoundInterval(self.writeOffSfx,
                          duration=0.9,
                          node=self.virtualSuit),
            SoundInterval(self.dingSfx, node=self.virtualSuit))

        padTrack = Track(
            (0.0,
             Func(pad.setPosHpr, -0.25, 1.38, -0.08, -19.078, -6.603,
                  -171.594)),
            (0.4, Func(pad.reparentTo, self.virtualSuit.getLeftHand())),
            (3.0, Func(pad.removeNode)),
        )

        track = Sequence(
            Parallel(suitTrack, soundTrack, padTrack, pencilTrack,
                     Func(self.sayFaceoffTaunt)),
            Func(self.virtualSuit.loop, 'walk', 0))
        return track