コード例 #1
0
 def load(self):
     self.notify.debug('load')
     DistributedMinigame.load(self)
     self.gameDuration = PairingGameGlobals.calcGameDuration(self.getDifficulty())
     self.gameBoard = loader.loadModel('phase_4/models/minigames/memory_room')
     self.gameBoard.setPosHpr(0.5, 0, 0, 0, 0, 0)
     self.gameBoard.setScale(1.0)
     self.deck = PairingGameGlobals.createDeck(self.deckSeed, self.numPlayers)
     self.notify.debug('%s' % self.deck.cards)
     testCard = self.getDeckOrderIndex(self.cardsPerCol - 1, 0)
     if not testCard > -1:
         self.yCardInc *= 1.25
     
     self.cards = []
     for index in xrange(len(self.deck.cards)):
         cardValue = self.deck.cards[index]
         oneCard = PairingGameCard.PairingGameCard(cardValue)
         oneCard.load()
         (xPos, yPos) = self.getCardPos(index)
         oneCard.setPos(xPos, yPos, 0)
         oneCard.reparentTo(render)
         self.notify.debug('%s' % oneCard.getPos())
         self.notify.debug('suit %s rank %s value %s' % (oneCard.suit, oneCard.rank, oneCard.value))
         self.accept('entercardCollision-%d' % oneCard.value, self.enterCard)
         self.accept('exitcardCollision-%d' % oneCard.value, self.exitCard)
         oneCard.turnDown(doInterval = False)
         self.cards.append(oneCard)
     
     self.bonusTraversal = range(len(self.cards))
     self.bonusGlow = render.attachNewNode('bonusGlow')
     sign = loader.loadModel('phase_4/models/minigames/garden_sign_memory')
     sign.find('**/sign1').removeNode()
     sign.find('**/sign2').removeNode()
     sign.find('**/collision').removeNode()
     sign.setPos(0, 0, 0.050000000000000003)
     sign.reparentTo(self.bonusGlow)
     self.bonusGlow.setScale(2.5)
     self.pointsFrame = DirectFrame(relief = None, geom = DGG.getDefaultDialogGeom(), geom_color = GlobalDialogColor, geom_scale = (4, 1, 1), pos = (-0.33000000000000002, 0, 0.90000000000000002), scale = 0.10000000000000001, text = TTLocalizer.PairingGamePoints, text_align = TextNode.ALeft, text_scale = TTLocalizer.DPGpointsFrame, text_pos = (-1.9399999999999999, -0.10000000000000001, 0.0))
     self.pointsLabel = DirectLabel(parent = self.pointsFrame, relief = None, text = '0', text_fg = VBase4(0, 0.5, 0, 1), text_align = TextNode.ARight, text_scale = 0.69999999999999996, pos = (1.8200000000000001, 0, -0.14999999999999999))
     self.flipsFrame = DirectFrame(relief = None, geom = DGG.getDefaultDialogGeom(), geom_color = GlobalDialogColor, geom_scale = (4, 1, 1), pos = (0.33000000000000002, 0, 0.90000000000000002), scale = 0.10000000000000001, text = TTLocalizer.PairingGameFlips, text_align = TextNode.ALeft, text_scale = TTLocalizer.DPGflipsFrame, text_pos = (-1.9399999999999999, -0.10000000000000001, 0.0))
     self.flipsLabel = DirectLabel(parent = self.flipsFrame, relief = None, text = '0', text_fg = VBase4(0, 1.0, 0, 1), text_align = TextNode.ARight, text_scale = 0.69999999999999996, pos = (1.8200000000000001, 0, -0.14999999999999999))
     self._DistributedPairingGame__textGen = TextNode('ringGame')
     self._DistributedPairingGame__textGen.setFont(ToontownGlobals.getSignFont())
     self._DistributedPairingGame__textGen.setAlign(TextNode.ACenter)
     self.sndPerfect = base.loadSfx('phase_4/audio/sfx/MG_pairing_all_matched.mp3')
     self.calcBonusTraversal()
     self.music = base.loadMusic('phase_4/audio/bgm/MG_Pairing.mid')
     self.matchSfx = base.loadSfx('phase_4/audio/sfx/MG_pairing_match.mp3')
     self.matchWithBonusSfx = base.loadSfx('phase_4/audio/sfx/MG_pairing_match_bonus_both.mp3')
     self.signalSfx = []
     for i in range(4):
         self.signalSfx.append(base.loadSfx('phase_4/audio/sfx/MG_pairing_jumping_signal.mp3'))
     
     self.bonusMovesSfx = base.loadSfx('phase_4/audio/sfx/MG_pairing_bonus_moves.mp3')
コード例 #2
0
    def load(self):
        self.notify.debug('load')
        DistributedMinigame.load(self)
        self.gameDuration = PairingGameGlobals.calcGameDuration(self.getDifficulty())
        self.gameBoard = loader.loadModel('phase_4/models/minigames/memory_room')
        self.gameBoard.setPosHpr(0.5, 0, 0, 0, 0, 0)
        self.gameBoard.setScale(1.0)
        self.deck = PairingGameGlobals.createDeck(self.deckSeed, self.numPlayers)
        self.notify.debug('%s' % self.deck.cards)
        testCard = self.getDeckOrderIndex(self.cardsPerCol - 1, 0)
        if not testCard > -1:
            self.yCardInc *= 1.25
        self.cards = []
        for index in xrange(len(self.deck.cards)):
            cardValue = self.deck.cards[index]
            oneCard = PairingGameCard.PairingGameCard(cardValue)
            oneCard.load()
            xPos, yPos = self.getCardPos(index)
            oneCard.setPos(xPos, yPos, 0)
            oneCard.reparentTo(render)
            self.notify.debug('%s' % oneCard.getPos())
            self.notify.debug('suit %s rank %s value %s' % (oneCard.suit, oneCard.rank, oneCard.value))
            self.accept('entercardCollision-%d' % oneCard.value, self.enterCard)
            self.accept('exitcardCollision-%d' % oneCard.value, self.exitCard)
            oneCard.turnDown(doInterval=False)
            self.cards.append(oneCard)

        self.bonusTraversal = range(len(self.cards))
        self.bonusGlow = render.attachNewNode('bonusGlow')
        sign = loader.loadModel('phase_4/models/minigames/garden_sign_memory')
        sign.find('**/sign1').removeNode()
        sign.find('**/sign2').removeNode()
        sign.find('**/collision').removeNode()
        sign.setPos(0, 0, 0.05)
        sign.reparentTo(self.bonusGlow)
        self.bonusGlow.setScale(2.5)
        self.pointsFrame = DirectFrame(relief=None, geom=DGG.getDefaultDialogGeom(), geom_color=GlobalDialogColor, geom_scale=(4, 1, 1), pos=(-0.33, 0, 0.9), scale=0.1, text=TTLocalizer.PairingGamePoints, text_align=TextNode.ALeft, text_scale=TTLocalizer.DPGpointsFrame, text_pos=(-1.94, -0.1, 0.0))
        self.pointsLabel = DirectLabel(parent=self.pointsFrame, relief=None, text='0', text_fg=VBase4(0, 0.5, 0, 1), text_align=TextNode.ARight, text_scale=0.7, pos=(1.82, 0, -0.15))
        self.flipsFrame = DirectFrame(relief=None, geom=DGG.getDefaultDialogGeom(), geom_color=GlobalDialogColor, geom_scale=(4, 1, 1), pos=(0.33, 0, 0.9), scale=0.1, text=TTLocalizer.PairingGameFlips, text_align=TextNode.ALeft, text_scale=TTLocalizer.DPGflipsFrame, text_pos=(-1.94, -0.1, 0.0))
        self.flipsLabel = DirectLabel(parent=self.flipsFrame, relief=None, text='0', text_fg=VBase4(0, 1.0, 0, 1), text_align=TextNode.ARight, text_scale=0.7, pos=(1.82, 0, -0.15))
        self.__textGen = TextNode('ringGame')
        self.__textGen.setFont(ToontownGlobals.getSignFont())
        self.__textGen.setAlign(TextNode.ACenter)
        self.sndPerfect = base.loadSfx('phase_4/audio/sfx/MG_pairing_all_matched.ogg')
        self.calcBonusTraversal()
        self.music = base.loadMusic('phase_4/audio/bgm/MG_Pairing.ogg')
        self.matchSfx = base.loadSfx('phase_4/audio/sfx/MG_pairing_match.ogg')
        self.matchWithBonusSfx = base.loadSfx('phase_4/audio/sfx/MG_pairing_match_bonus_both.ogg')
        self.signalSfx = []
        for i in range(4):
            self.signalSfx.append(base.loadSfx('phase_4/audio/sfx/MG_pairing_jumping_signal.ogg'))

        self.bonusMovesSfx = base.loadSfx('phase_4/audio/sfx/MG_pairing_bonus_moves.ogg')
        return
コード例 #3
0
 def updateFlipText(self):
     self.flipsLabel['text'] = str(self.flips)
     lowFlipModifier = PairingGameGlobals.calcLowFlipModifier(
         self.matches, self.flips)
     red = 1.0 - lowFlipModifier
     green = lowFlipModifier
     self.flipsLabel['text_fg'] = Vec4(red, green, 0, 1.0)
コード例 #4
0
    def setGameReady(self):
        self.notify.debug('setGameReady')
        if self.OneCardInMultiplayer and len(self.avIdList) > 1:
            self.maxOpenCards = 1
        self.sendUpdate('setMaxOpenCards', [self.maxOpenCards])
        DistributedMinigameAI.setGameReady(self)
        for avId in self.avIdList:
            self.faceUpDict[avId] = []

        self.deck = PairingGameGlobals.createDeck(self.deckSeed, self.numPlayers)
        for index in xrange(len(self.deck.cards)):
            cardValue = self.deck.cards[index]
            oneCard = PlayingCardBase(cardValue)
            self.cards.append(oneCard)
    def setGameReady(self):
        self.notify.debug('setGameReady')
        if self.OneCardInMultiplayer and len(self.avIdList) > 1:
            self.maxOpenCards = 1
        self.sendUpdate('setMaxOpenCards', [self.maxOpenCards])
        DistributedMinigameAI.setGameReady(self)
        for avId in self.avIdList:
            self.faceUpDict[avId] = []

        self.deck = PairingGameGlobals.createDeck(self.deckSeed,
                                                  self.numPlayers)
        for index in xrange(len(self.deck.cards)):
            cardValue = self.deck.cards[index]
            oneCard = PlayingCardBase(cardValue)
            self.cards.append(oneCard)
コード例 #6
0
    def enterPlay(self):
        self.notify.debug('enterPlay')

        def allToonsDone(self = self):
            self.notify.debug('allToonsDone')
            self.sendUpdate('setEveryoneDone')
            if not PairingGameGlobals.EndlessGame:
                self.gameOver()

        def handleTimeout(avIds, self = self):
            self.notify.debug('handleTimeout: avatars %s did not report "done"' % avIds)
            self.setGameAbort()

        self.gameDuration = PairingGameGlobals.calcGameDuration(self.getDifficulty())
        self.doneBarrier = ToonBarrier('waitClientsDone', self.uniqueName('waitClientsDone'), self.avIdList, self.gameDuration + MinigameGlobals.latencyTolerance, allToonsDone, handleTimeout)
コード例 #7
0
    def enterPlay(self):
        self.notify.debug('enterPlay')
        
        def allToonsDone(self = self):
            self.notify.debug('allToonsDone')
            self.sendUpdate('setEveryoneDone')
            if not PairingGameGlobals.EndlessGame:
                self.gameOver()
            

        
        def handleTimeout(avIds, self = self):
            self.notify.debug('handleTimeout: avatars %s did not report "done"' % avIds)
            self.setGameAbort()

        self.gameDuration = PairingGameGlobals.calcGameDuration(self.getDifficulty())
        self.doneBarrier = ToonBarrier('waitClientsDone', self.uniqueName('waitClientsDone'), self.avIdList, self.gameDuration + MinigameGlobals.latencyTolerance, allToonsDone, handleTimeout)
コード例 #8
0
    def setGameReady(self):
        self.notify.debug("setGameReady")

        # make sure we broadcast how many cards open per toon
        if self.OneCardInMultiplayer and len(self.avIdList) > 1:
            self.maxOpenCards = 1
        self.sendUpdate('setMaxOpenCards', [self.maxOpenCards])

        DistributedMinigameAI.setGameReady(self)
        # all of the players have checked in
        # they will now be shown the rules

        # init face up dict and other fields
        for avId in self.avIdList:
            self.faceUpDict[avId] = []
        self.deck = PairingGameGlobals.createDeck(self.deckSeed,
                                                  self.numPlayers)
        for index in range(len(self.deck.cards)):
            cardValue = self.deck.cards[index]
            oneCard = PlayingCardBase(cardValue)
            self.cards.append(oneCard)
コード例 #9
0
 def calcLowFlipBonus(self):
     lowFlipModifier = PairingGameGlobals.calcLowFlipModifier(self.matches, self.flips)
     bonus = lowFlipModifier * self.matches
     self.notify.debug('low flip bonus = %d' % bonus)
     return bonus
コード例 #10
0
    def load(self):
        # load resources and create objects here
        self.notify.debug("load")
        DistributedMinigame.load(self)

        self.gameDuration = PairingGameGlobals.calcGameDuration(
            self.getDifficulty())

        #self.gameBoard = loader.loadModel("phase_4/models/minigames/toon_cannon_gameground")
        self.gameBoard = loader.loadModel(
            "phase_4/models/minigames/memory_room")
        self.gameBoard.setPosHpr(0.5, 0, 0, 0, 0, 0)
        self.gameBoard.setScale(1.0)
        #self.gameBoard.find('**/tree_ring').removeNode()

        #self.debugAxis = loader.loadModel('models/misc/xyzAxis')
        #self.debugAxis.reparentTo(self.gameBoard)
        self.deck = PairingGameGlobals.createDeck(self.deckSeed,
                                                  self.numPlayers)
        self.notify.debug('%s' % self.deck.cards)

        testCard = self.getDeckOrderIndex(self.cardsPerCol - 1, 0)
        if not testCard > -1:
            self.yCardInc *= 1.25

        self.cards = []

        for index in xrange(len(self.deck.cards)):
            cardValue = self.deck.cards[index]
            oneCard = PairingGameCard.PairingGameCard(cardValue)
            oneCard.load()
            xPos, yPos = self.getCardPos(index)
            oneCard.setPos(xPos, yPos, 0)
            oneCard.reparentTo(render)
            self.notify.debug('%s' % oneCard.getPos())
            self.notify.debug('suit %s rank %s value %s' %
                              (oneCard.suit, oneCard.rank, oneCard.value))
            self.accept('entercardCollision-%d' % oneCard.value,
                        self.enterCard)
            self.accept('exitcardCollision-%d' % oneCard.value, self.exitCard)
            oneCard.turnDown(doInterval=False)
            self.cards.append(oneCard)

        self.bonusTraversal = range(len(self.cards))

        self.bonusGlow = render.attachNewNode('bonusGlow')

        sign = loader.loadModel("phase_4/models/minigames/garden_sign_memory")
        # remove the bits we don't want
        sign.find('**/sign1').removeNode()
        sign.find('**/sign2').removeNode()
        sign.find('**/collision').removeNode()
        #sign.setTransparency(1)
        #sign.setColorScale(1,1,0,0.5)
        sign.setPos(0, 0, 0.05)
        sign.reparentTo(self.bonusGlow)

        self.bonusGlow.setScale(2.5)

        self.pointsFrame = DirectFrame(
            #parent = self.gui,
            relief=None,
            geom=DGG.getDefaultDialogGeom(),
            geom_color=GlobalDialogColor,
            geom_scale=(4, 1, 1),
            pos=(-0.33, 0, 0.9),
            scale=0.1,
            text=TTLocalizer.PairingGamePoints,
            text_align=TextNode.ALeft,
            text_scale=TTLocalizer.DPGpointsFrame,
            text_pos=(-1.94, -0.1, 0.0))
        self.pointsLabel = DirectLabel(
            parent=self.pointsFrame,
            relief=None,
            text='0',
            text_fg=VBase4(0, 0.5, 0, 1),
            text_align=TextNode.ARight,
            text_scale=0.7,
            pos=(1.82, 0, -0.15),
        )

        self.flipsFrame = DirectFrame(
            #parent = self.gui,
            relief=None,
            geom=DGG.getDefaultDialogGeom(),
            geom_color=GlobalDialogColor,
            geom_scale=(4, 1, 1),
            pos=(0.33, 0, 0.9),
            scale=0.1,
            text=TTLocalizer.PairingGameFlips,
            text_align=TextNode.ALeft,
            text_scale=TTLocalizer.DPGflipsFrame,
            text_pos=(-1.94, -0.1, 0.0))
        self.flipsLabel = DirectLabel(
            parent=self.flipsFrame,
            relief=None,
            text='0',
            text_fg=VBase4(0, 1.0, 0, 1),
            text_align=TextNode.ARight,
            text_scale=0.7,
            pos=(1.82, 0, -0.15),
        )

        # this will be used to generate textnodes
        self.__textGen = TextNode("ringGame")
        self.__textGen.setFont(ToontownGlobals.getSignFont())
        self.__textGen.setAlign(TextNode.ACenter)

        self.sndPerfect = base.loadSfx(
            "phase_4/audio/sfx/MG_pairing_all_matched.mp3")

        self.calcBonusTraversal()

        self.music = base.loadMusic("phase_4/audio/bgm/MG_Pairing.mid")
        self.matchSfx = base.loadSfx("phase_4/audio/sfx/MG_pairing_match.mp3")
        self.matchWithBonusSfx = base.loadSfx(
            "phase_4/audio/sfx/MG_pairing_match_bonus_both.mp3")
        self.signalSfx = []
        for i in range(4):
            self.signalSfx.append(
                base.loadSfx(
                    "phase_4/audio/sfx/MG_pairing_jumping_signal.mp3"))
        self.bonusMovesSfx = base.loadSfx(
            "phase_4/audio/sfx/MG_pairing_bonus_moves.mp3")
コード例 #11
0
 def updateFlipText(self):
     self.flipsLabel['text'] = str(self.flips)
     lowFlipModifier = PairingGameGlobals.calcLowFlipModifier(self.matches, self.flips)
     red = 1.0 - lowFlipModifier
     green = lowFlipModifier
     self.flipsLabel['text_fg'] = Vec4(red, green, 0, 1.0)
コード例 #12
0
 def calcLowFlipBonus(self):
     lowFlipModifier = PairingGameGlobals.calcLowFlipModifier(self.matches, self.flips)
     bonus = lowFlipModifier * self.matches
     self.notify.debug('low flip bonus = %d' % bonus)
     return bonus