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),
            )