Esempio n. 1
0
 def letterboxOn(self, t=0.25, finishIval=None):
     """
     Move black bars in over t seconds.
     """
     self.noLetterbox()
     self.loadLetterbox()
     self.letterbox.unstash()
     if (t == 0):
         self.letterboxBottom.setPos(0, 0, -1)
         self.letterboxTop.setPos(0, 0, 0.8)
         fut = AsyncFuture()
         fut.setResult(None)
         return fut
     else:
         self.__letterboxFuture = AsyncFuture()
         self.letterboxIval = Sequence(Parallel(
             LerpPosInterval(self.letterboxBottom,
                             t,
                             pos = Vec3(0, 0, -1),
                             #startPos = Vec3(0, 0, -1.2),
                             ),
             LerpPosInterval(self.letterboxTop,
                             t,
                             pos = Vec3(0, 0, 0.8),
                             # startPos = Vec3(0, 0, 1),
                             ),
             ),
                                       Func(self.__finishLetterbox),
                                       name = self.letterboxTaskName,
                                       )
         if finishIval:
             self.letterboxIval.append(finishIval)
         self.letterboxIval.start()
         return self.__letterboxFuture
Esempio n. 2
0
 def letterboxOff(self, t=0.25, finishIval=None):
     """
     Move black bars away over t seconds.
     """
     self.noLetterbox()
     self.loadLetterbox()
     self.letterbox.unstash()
     if (t == 0):
         self.letterbox.stash()
     else:
         self.letterboxIval = Sequence(
             Parallel(
                 LerpPosInterval(
                     self.letterboxBottom,
                     t,
                     pos=Vec3(0, 0, -1.2),
                     # startPos = Vec3(0, 0, -1),
                 ),
                 LerpPosInterval(
                     self.letterboxTop,
                     t,
                     pos=Vec3(0, 0, 1),
                     # startPos = Vec3(0, 0, 0.8),
                 ),
             ),
             Func(self.letterbox.stash),
             Func(messenger.send, 'letterboxOff'),
             name=self.letterboxTaskName,
         )
         if finishIval:
             self.letterboxIval.append(finishIval)
         self.letterboxIval.start()
Esempio n. 3
0
    def __init__(self,
                 nodePath,
                 pos,
                 durationFactor=0.2,
                 startPos=None,
                 other=None,
                 blendType='noBlend',
                 bakeInStart=1,
                 fluid=0,
                 name=None,
                 lookAtTarget=True,
                 duration=None):
        self.nodePath = nodePath
        self.pos = pos

        if type(pos) != type(Point3()):
            self.notify.warning(
                "pos argument must be of type %s, not of type %s" %
                (type(Point3()), type(pos)))
            return None

        if nodePath.isEmpty():
            self.notify.warning('You must specify a non-empty NodePath!')
            return None

        if duration is None:
            _distance = (pos.getXy() -
                         (nodePath.getX(), nodePath.getY())).length()
            duration = _distance * durationFactor
        LerpPosInterval.__init__(self, nodePath, duration, pos, startPos,
                                 other, blendType, bakeInStart, fluid, name)
        if lookAtTarget:
            self.nodePath.headsUp(self.pos)
Esempio n. 4
0
 def changePosColorScale(self,key,pos = None,color = None, scale = None,time = 0):
     '''Change an item's position, color, and/or scale. 
     params should be lists having a length of 3 (pos, scale) or 4 (color) floats
     '''
     if pos:
         self.itemEntries[key].pos = pos
         if not time:
             self._sceneItems[key].setPos(pos)
         else:
             ival = LerpPosInterval(self._sceneItems[key],time,pos,self._sceneItems[key].getPos())
             self._intervals.append(ival)
             ival.start()
     if color:
         self.itemEntries[key].color = color
         if not time:
             self._sceneItems[key].setColor(color)
         else:
             ival = LerpColorInterval(self._sceneItems[key],time,color,self._sceneItems[key].getColor())
             self._intervals.append(ival)
             ival.start()
     if scale:
         self.itemEntries[key].scale = scale
         if not time:
             self._sceneItems[key].setScale(self._sceneItems[key].getSx()*scale[0],
                                            self._sceneItems[key].getSy()*scale[1],
                                            self._sceneItems[key].getSz()*scale[2])
         else:
             targetscale = (self._sceneItems[key].getSx()*scale[0],
                            self._sceneItems[key].getSy()*scale[1],
                            self._sceneItems[key].getSz()*scale[2])
             ival = LerpScaleInterval(self._sceneItems[key],time,targetscale,self._sceneItems[key].getScale())
             self._intervals.append(ival)
             ival.start()
Esempio n. 5
0
    def __init__(self):

        self.frameMain = DirectFrame(frameSize=(base.a2dLeft, base.a2dRight,
                                                base.a2dBottom, base.a2dTop),
                                     frameColor=(0.05, 0.05, 0.05, 1))
        self.frameMain.setTransparency(1)

        tpBig = TextProperties()
        tpBig.setTextScale(1.5)
        tpSmall = TextProperties()
        tpSmall.setTextScale(0.75)
        tpUs = TextProperties()
        tpUs.setUnderscore(True)
        tpMgr = TextPropertiesManager.getGlobalPtr()
        tpMgr.setProperties("big", tpBig)
        tpMgr.setProperties("small", tpSmall)
        tpMgr.setProperties("us", tpUs)

        creditsText = ""
        with open("credits.txt") as f:
            creditsText = f.read()
        self.lblCredits = DirectLabel(text=creditsText,
                                      text_fg=(1, 1, 1, 1),
                                      text_bg=(0, 0, 0, 0),
                                      frameColor=(0, 0, 0, 0),
                                      text_align=TextNode.ACenter,
                                      scale=0.1,
                                      pos=(0, 0, base.a2dTop - 0.2))
        self.lblCredits.setTransparency(1)
        self.lblCredits.reparentTo(self.frameMain)

        self.creditsScroll = LerpPosInterval(self.lblCredits,
                                             12.0, (0, 0, base.a2dTop + 3.5),
                                             startPos=(0, 0, base.a2dBottom),
                                             name="CreditsScroll")

        self.btnBack = DirectButton(text="BACK",
                                    text_fg=(1, 1, 1, 1),
                                    text_align=TextNode.ALeft,
                                    scale=0.1,
                                    pad=(0.15, 0.15),
                                    pos=(base.a2dLeft + 0.08, 0,
                                         base.a2dBottom + 0.05),
                                    frameColor=(
                                        (0.2, 0.2, 0.2, 0.8),
                                        (0.4, 0.4, 0.4, 0.8),
                                        (0.4, 0.4, 0.4, 0.8),
                                        (0.1, 0.1, 0.1, 0.8),
                                    ),
                                    relief=1,
                                    command=base.messenger.send,
                                    extraArgs=["Credits-Back"],
                                    pressEffect=False,
                                    rolloverSound=None,
                                    clickSound=None)
        self.btnBack.setTransparency(1)
        self.btnBack.reparentTo(self.frameMain)

        self.hide()
Esempio n. 6
0
 def on_button_press(self, button, cmd, event=None):
     self.last_button_pressed = button
     button['state'] = DGG.DISABLED
     pos = button.get_pos()
     Sequence(LerpPosInterval(button, 0.05, pos + _pos2d(0, 2)),
              LerpPosInterval(button, 0.05, pos),
              Func(button.configure, **{'state': DGG.NORMAL}),
              Func(_exec, cmd)).start()
Esempio n. 7
0
def animate_model(model, position, duration, callback=None, callback_args=None):
    interval = LerpPosInterval(
        model, duration, position, model.getPos())
    interval.start()

    if callback:
        if not callback_args:
            callback_args = []
        callback(*callback_args)
    def push(self):
        """Camera push caused by a kick/explosion."""
        if self._move_int is not None:
            self._move_int.pause()

        if self._turn_int is not None:
            self._turn_int.pause()

        self._move_int = Sequence()

        self._target.setZ(base.cam.getZ() -
                          random.uniform(-0.02, 0.02))  # noqa: F821
        self._target.setX(base.cam.getX() +
                          random.uniform(-0.03, 0.03))  # noqa: F821
        self._target.setY(base.cam.getY() +
                          random.uniform(-0.03, 0.03))  # noqa: F821

        self._move_int.append(
            Parallel(
                LerpPosInterval(
                    base.cam,
                    0.15,
                    self._target,
                    bakeInStart=False,  # noqa: F821
                ),
                LerpHprInterval(
                    self._np,
                    0.15,
                    (
                        self._np.getH() + random.uniform(-1, 1),
                        self._np.getP() + random.uniform(-2, 2),
                        self._np.getR() + random.uniform(-3, 3),
                    ),
                ),
            ))
        self._target.setX(base.cam.getX())  # noqa: F821
        self._target.setY(base.cam.getY())  # noqa: F821
        self._target.setZ(base.cam.getZ())  # noqa: F821

        self._move_int.append(
            Parallel(
                LerpPosInterval(
                    base.cam,  # noqa: F821
                    0.5,
                    self._target,
                    bakeInStart=False,
                    blendType="easeOut",
                ),
                LerpHprInterval(
                    self._np,
                    0.5,
                    (self._np.getH(), 0, self._np.getR()),
                    blendType="easeOut",
                ),
            ))
        self._move_int.start()
Esempio n. 9
0
 def enterFinalBackToSea(self):
     self.fish.setPosHpr(self.fish.myData['goodbyePosHpr'][0],
                         self.fish.myData['goodbyePosHpr'][1])
     self.fish.actor.changeAnimationTo('swimIdle')
     self.farewellInterval = LerpPosInterval(
         self.fish,
         FishingGlobals.waveToLegendaryFishDuration,
         pos=self.fish.myData['swimmingDistance'],
         startPos=self.fish.getPos(),
         name='%s_farewellInterval' % self.fish.getName())
     self.farewellInterval.start()
 def animateTile(self,x,y):
     """
     the floating animation of tiles.
     """
     Time = 2
     tile = self.getTileFromPos(x,y)
     if tile:
          if tile.getPythonTag("Seq").isPlaying() ==False:
             seq = Sequence( 
                     LerpPosInterval( tile, Time+(0.2*Time*random()),(x,y,.35),(x,y,0)  , blendType="easeInOut") ,  
                     LerpPosInterval( tile, Time+(0.2*Time*random()),(x,y, 0),(x,y,.35) , blendType="easeInOut")  )
             tile.setPythonTag("Seq", seq )
             seq.loop()  
Esempio n. 11
0
File: Npc.py Progetto: jaimodha/MMOG
 def stopChase(self):
     
     #self.AIbehaviors.pauseAi("pursue")
     if not self._is_dead:
         self.AIbehaviors.removeAi("pursue")
         p1 = LerpHprInterval(self.npc, 4, Point3(180,0,0))
         p2 = LerpPosInterval(self.npc, 4, Point3(self.anchorx, self.anchory, self.anchorz))
         animInterval = self.npc.actorInterval("walk", loop = 1, duration=4)
         p2.start()
         p1.start()
         animInterval.start()
         self.isMoving = False
         self.target = None
         self.isCurrentUser = False
Esempio n. 12
0
File: Npc.py Progetto: jaimodha/MMOG
    def stopChase(self):

        #self.AIbehaviors.pauseAi("pursue")
        if not self._is_dead:
            self.AIbehaviors.removeAi("pursue")
            p1 = LerpHprInterval(self.npc, 4, Point3(180, 0, 0))
            p2 = LerpPosInterval(
                self.npc, 4, Point3(self.anchorx, self.anchory, self.anchorz))
            animInterval = self.npc.actorInterval("walk", loop=1, duration=4)
            p2.start()
            p1.start()
            animInterval.start()
            self.isMoving = False
            self.target = None
            self.isCurrentUser = False
Esempio n. 13
0
 def letterboxOn(self, t=0.25, finishIval=None):
     self.noLetterbox()
     self.loadLetterbox()
     self.letterbox.unstash()
     if t == 0:
         self.letterboxBottom.setPos(0, 0, -1)
         self.letterboxTop.setPos(0, 0, 0.8)
     else:
         self.letterboxIval = Sequence(Parallel(
             LerpPosInterval(self.letterboxBottom, t, pos=Vec3(0, 0, -1)),
             LerpPosInterval(self.letterboxTop, t, pos=Vec3(0, 0, 0.8))),
                                       name=self.letterboxTaskName)
         if finishIval:
             self.letterboxIval.append(finishIval)
         self.letterboxIval.start()
Esempio n. 14
0
 def think(self, curTic, curT, unwalkables):
     self.TX = self.nextTX
     self.TY = self.nextTY
     self.lastDirection = self.direction
     self.direction = self.__chooseNewWalkDirection(unwalkables)
     self.nextTX, self.nextTY = self.__applyDirection(self.direction, self.TX, self.TY)
     self.occupiedTiles = [(self.TX, self.TY), (self.nextTX, self.nextTY)]
     if curTic == self.lastTicBeforeRender:
         fromCoords = self.maze.tile2world(self.TX, self.TY)
         toCoords = self.maze.tile2world(self.nextTX, self.nextTY)
         self.fromPos.set(fromCoords[0], fromCoords[1], self.SUIT_Z)
         self.toPos.set(toCoords[0], toCoords[1], self.SUIT_Z)
         self.moveIval = LerpPosInterval(self.suit, self.cellWalkDuration, self.toPos, startPos=self.fromPos, name=self.uniqueName(self.MOVE_IVAL_NAME))
         if self.direction != self.lastDirection:
             self.fromH = self.directionHs[self.lastDirection]
             toH = self.directionHs[self.direction]
             if self.fromH == 270 and toH == 0:
                 self.fromH = -90
             elif self.fromH == 0 and toH == 270:
                 self.fromH = 360
             self.fromHpr.set(self.fromH, 0, 0)
             self.toHpr.set(toH, 0, 0)
             turnIval = LerpHprInterval(self.suit, self.turnDuration, self.toHpr, startHpr=self.fromHpr, name=self.uniqueName('turnMazeSuit'))
             self.moveIval = Parallel(self.moveIval, turnIval, name=self.uniqueName(self.MOVE_IVAL_NAME))
         else:
             self.suit.setH(self.directionHs[self.direction])
         moveStartT = float(self.nextThinkTic) / float(self.ticFreq)
         self.moveIval.start(curT - (moveStartT + self.gameStartTime))
     self.nextThinkTic += self.ticPeriod
    def __shrinkLoadingBar(self):
        if self.__isValidDownloadBar():
            ivalDuration = 0.5
            barPosIval = LerpPosInterval(self.bar, ivalDuration,
                                         (-0.81, 0, -0.96))
            barScaleIval = LerpScaleInterval(self.bar, ivalDuration,
                                             (0.25, 0.25, 0.25))

            def posText(pos):
                self.bar['text_pos'] = (0, pos)

            def scaleText(scale):
                self.bar['text_scale'] = (scale, scale)

            textScaleIval = LerpFunc(scaleText,
                                     fromData=0.08,
                                     toData=0.16,
                                     duration=ivalDuration)

            textPosIval = LerpFunc(posText,
                                   fromData=-0.035,
                                   toData=-0.05,
                                   duration=ivalDuration)

            shrinkIval = Parallel(barPosIval, barScaleIval, textPosIval,
                                  textScaleIval, Func(self.loadingText.hide))

            self.hideBlockerIval = Sequence(shrinkIval, Wait(0.5),
                                            Func(self.__hideBlocker),
                                            Func(self.__resetLoadingBar),
                                            Func(self.destroy))
            self.hideBlockerIval.start()
Esempio n. 16
0
 def letterboxOff(self, t=0.25, finishIval=None):
     self.noLetterbox()
     self.loadLetterbox()
     self.letterbox.unstash()
     if t == 0:
         self.letterbox.stash()
     else:
         self.letterboxIval = Sequence(Parallel(
             LerpPosInterval(self.letterboxBottom, t, pos=Vec3(0, 0, -1.2)),
             LerpPosInterval(self.letterboxTop, t, pos=Vec3(0, 0, 1))),
                                       Func(self.letterbox.stash),
                                       Func(messenger.send, 'letterboxOff'),
                                       name=self.letterboxTaskName)
         if finishIval:
             self.letterboxIval.append(finishIval)
         self.letterboxIval.start()
Esempio n. 17
0
 def append(self,text,width,height,spacing = 0, fadein = 0, fadeinType = 0):
     '''Add a NodePath that contains a generated text geom
     This method is called by SogalText
     '''
     self.__lock.acquire()
     
     self.items.append(text)
     text.reparentTo(self)
     textPos = self.currentPtr
     text.setPos(textPos)
     if fadein:
         interval = Parallel()
         if fadeinType == 0 or fadeinType == 'normal':
             interval.append(LerpFunc(_modifyAlphaScale,fadein,0,1,blendType = 'easeOut',extraArgs = [text]))
         if fadeinType == 1 or fadeinType == 'flyin':
             interval.append(LerpFunc(_modifyAlphaScale,fadein,0,1,blendType = 'easeOut',extraArgs = [text]))
             interval.append(LerpPosInterval(text,fadein,
                                             self.currentPtr,
                                             (self.currentPtr[0],self.currentPtr[1],self.currentPtr[2] -0.3),
                                             blendType = 'easeOut'))            
         interval.start()
         self.__lerpIntervals.append(interval)
         
     self.lineWidth = self.currentPtr[0] + width
     self.lineHeight = max(height, self.lineHeight)
     self.currentPtr = (self.lineWidth + spacing, 0, 0)
     
     self.__lock.release()
Esempio n. 18
0
 def update_fired_props(self, pos, fwd):
     if pos == (0, 0, 0) and fwd == (0, 0, 0): return
     wpn_np = self.gfx_np.node
     old_pos = wpn_np.get_pos(render)
     self.gfx_np.node.reparent_to(render)
     wpn_np.set_pos(old_pos)
     self.ipos = LerpPosInterval(wpn_np, self.eng.client.rate, pos)
     self.ipos.start()
     fwd_start = render.get_relative_vector(wpn_np, Vec3(0, 1, 0))
     if self.ifwd: self.ifwd.finish()
     self.ifwd = LerpFunc(self._rotate_wpn,
                          fromData=0,
                          toData=1,
                          duration=self.eng.client.rate,
                          extraArgs=[wpn_np, fwd_start, fwd])
     self.ifwd.start()
Esempio n. 19
0
 def set_view(self, view='front', num=0):
     views = {
         'front': (Vec3(90, 0, 0), Vec3(90, 0, 0)),
         'back': (Vec3(-90, 0, 0), Vec3(-90, 0, 0)),
         'left': (Vec3(0, 0, 0), Vec3(0, 0, 0)),
         'right': (Vec3(180, 0, 0), Vec3(180, 0, 0)),
         'top': (Vec3(90, 0, 0), Vec3(90, 90, 0)),
         'bottom': (Vec3(90, 0, 0), Vec3(90, -90, 0))
     }
     if view in views:
         if self.node.get_hpr(render).almost_equal(
                 views[view][0]) and self.gimbal.get_hpr(
                     render).almost_equal(views[view][1]):
             return
         else:
             if num > 3:
                 self.node.set_hpr(render, views[view][0])
                 self.gimbal.set_hpr(render, views[view][1])
                 self.node.set_pos(render, (0, 0, 0))
                 return
             Sequence(
                 Parallel(
                     LerpHprInterval(self.gimbal,
                                     0.21,
                                     views[view][1],
                                     other=render),
                     LerpHprInterval(self.node,
                                     0.21,
                                     views[view][0],
                                     other=render),
                     LerpPosInterval(self.node,
                                     0.21,
                                     Vec3(0, 0, 0),
                                     other=render)),
                 Func(self.set_view, view, 1 + num)).start()
    def _stop(self, stop_x, stop_zoom=False, is_hard=False):
        """Stop moving and rotating camera (on key release).

        Args:
            stop_x (bool):
                True - movement along x axis should be stopped.
                False - movement along y axis should be stopped.
            stop_zoom (bool):
                True if camera stopped zoom movement.
            is_hard (bool):
                If False, camera will be stopped with an deceleration
                interval. If True, stopping will be immediate.
        """
        if self._move_int is not None:
            self._move_int.pause()

        if self._turn_int is not None:
            self._turn_int.pause()

        if stop_zoom:
            self._target = base.cam.getPos()  # noqa: F821
        elif stop_x:
            self._target.setX(base.cam.getX())  # noqa: F821
        else:
            self._target.setY(base.cam.getY())  # noqa: F821

        if not is_hard:
            self._move_int = LerpPosInterval(
                base.cam,
                0.75,
                self._target,
                other=self._np  # noqa: F821
            )
            self._move_int.start()
    def _move(self, x, y, time):
        """Start camera movement with an interval (on key press).

        Args:
            x (float): Translation along x axis.
            y (float): Translation along y axis.
            time (float): Interval length.
        """
        if self._move_int is not None:
            self._move_int.pause()

        if x:
            # if camera moves forward, consider Z coordinate
            # to calibrate move limits when zoomed
            if x == 1:
                x -= MAX_Z - base.cam.getZ()  # noqa: F821

            self._target.setX(x)
        else:
            self._target.setY(y)

        self._move_int = LerpPosInterval(
            base.cam,
            time,
            self._target,
            other=self._np  # noqa: F821
        )
        self._move_int.start()
Esempio n. 22
0
    def createMovePaperInterval(self, newY):
        here = self.calcPaperPos(self.paperY)
        there = self.calcPaperPos(newY)

        posInterval = LerpPosInterval(
                self.target, abs(newY - self.paperY),
                there,
                startPos = here,
                blendType='easeInOut')

        posInterval.setDoneEvent('scrollDone')

        def isDone():
            self.paperY = newY

        self.base.acceptOnce('scrollDone', isDone)
        return posInterval
Esempio n. 23
0
    def createMovePaperInterval(self, newY):
        here = self.calcPaperPos(self.paperY)
        there = self.calcPaperPos(newY)

        posInterval = LerpPosInterval(self.target,
                                      abs(newY - self.paperY),
                                      there,
                                      startPos=here,
                                      blendType='easeInOut')

        posInterval.setDoneEvent('scrollDone')

        def isDone():
            self.paperY = newY

        self.base.acceptOnce('scrollDone', isDone)
        return posInterval
Esempio n. 24
0
    def init_game(self):
        configs.IN_MENU = False
        interval = LerpHprInterval(self.cameraPivot, 1, (0,10,0), (0,0,0))
        interval2 = LerpPosInterval(self.cameraPivot, 1, (0,0,-0.05), (0,0,0))
        interval.start()
        interval2.start()
        for entity_id, entity in configs.ENTITIES.items():
            if entity['CATEGORY'] == 'button':
                entity['BUTTON'].destroy()
                try:
                    entity['R_NODE'].removeNode()
                except: 
                    print "nothing to remove"
                try:
                    entity['L_NODE'].removeNode()
                except: 
                    print "nothing to remove"
            del(configs.ENTITIES[entity_id])
        used_positions = []
        for p in range(25):
            position = (random.uniform(-1.6, 1.6), 0, random.uniform(-0.8, 0.8))
            heading = random.randint(0,360)
            empty_space = False
            while empty_space == False:
                empty_space = True
                for other_position in used_positions:
                    distance = pow(pow((other_position[0] - position[0]),2) + pow((other_position[2] - position[2]),2),0.5)
                    if distance < 0.25:
                        empty_space = False
                        position = (random.uniform(-1.6, 1.6), 0, random.uniform(-0.8, 0.8))

            btn_left = configs.BUTTONS_MAP[p][0]
            btn_right = configs.BUTTONS_MAP[p][1]
            if (btn_right == '' or btn_left == '') and configs.ARDUINO_PLAYER_ON[p] == 0:
                continue
            used_positions += [position]
            init_player(self, btn_left, btn_right, p, pos=position, heading=heading)
        
        configs.BONUS_START_TIME[2] = globalClock.getFrameTime()

        if used_positions == []:
            self.init_menu()
        else:
            self.countDown = taskMgr.add(countDown, "countDown", extraArgs=[self, 5], appendTask=True) 
            self.gameTask = taskMgr.add(self.gameLoop, "gameLoop") 
Esempio n. 25
0
    def hide(self):
        if self.__hidden:
            return
        self.__hidden = True

        if not (self.__fading and self.__fadingDuration):
            NodePath.hide(self)
            self.removeFocus()
            if self.__mask:
                self.__mask.hide()
            if self.__bgPath:
                self.__bgPath.hide()
            if self.__hiddenFunc:
                self.__hiddenFunc(*self.__eventExtraArgs)
        else:
            #self.removeFocus()
            if self.__currentInterval:
                self.__currentInterval.pause()
            endpos = tuple(
                map(operator.add, self.__originPos,
                    self.__fadingPositionOffset))
            parallel = Parallel(
                LerpFunc(_modifyAlphaScale,
                         self.__fadingDuration,
                         1,
                         0,
                         blendType='easeIn',
                         extraArgs=[self]),
                LerpPosInterval(self,
                                self.__fadingDuration,
                                endpos,
                                self.__originPos,
                                blendType='easeIn'),
            )
            if self.__bgPath:
                parallel.append(
                    LerpFunc(_modifyAlphaScale,
                             self.__fadingDuration,
                             1,
                             0,
                             blendType='easeIn',
                             extraArgs=[self.__bgPath]))

            self.__currentInterval = Sequence(
                parallel,
                Func(NodePath.hide, self),
                Func(self.removeFocus),
            )
            if self.__mask:
                self.__currentInterval.append(Func(self.__mask.hide))
            if self.__bgPath:
                self.__currentInterval.append(Func(self.__bgPath.hide))
            if self.__hiddenFunc:
                self.__currentInterval.append(
                    Func(self.__hiddenFunc, *self.__eventExtraArgs))

            self.__currentInterval.start()
Esempio n. 26
0
    def startFloat(
        self
    ):  # This function is for estate cannon popsicles, makes the popsicles appear as though they are floating.
        if self.treasureType == TreasureGlobals.TreasureE:
            defaultPos = self.nodePath.getPos()
            randPos = random.random() - 6

            delayTime = random.uniform(0, 0.1)

            randChoice = random.choice([True, False])

            if randChoice:  # This either starts the icecream at the highest position, or the lowest position
                startPos = (defaultPos[0], defaultPos[1],
                            defaultPos[2] - randPos)
                endPos = (defaultPos[0], defaultPos[1], defaultPos[2])

                floatUp = LerpPosInterval(self.nodePath,
                                          2,
                                          Point3(startPos),
                                          blendType='easeInOut')
                floatDown = LerpPosInterval(self.nodePath,
                                            2,
                                            Point3(endPos),
                                            blendType='easeInOut')
            else:
                startPos = (defaultPos[0], defaultPos[1], defaultPos[2])
                endPos = (defaultPos[0], defaultPos[1],
                          defaultPos[2] + randPos)

                floatUp = LerpPosInterval(self.nodePath,
                                          2,
                                          Point3(endPos),
                                          blendType='easeInOut')
                floatDown = LerpPosInterval(self.nodePath,
                                            2,
                                            Point3(startPos),
                                            blendType='easeInOut')

            self.flyingSeq = Sequence(floatUp,
                                      Wait(delayTime),
                                      floatDown,
                                      Wait(delayTime),
                                      name=self.uniqueName('floatingIcecream'))
            self.flyingSeq.loop()
Esempio n. 27
0
    def createMoveCarriageInterval(self, newX, curX=None):
        if curX is None:
            curX = self.paperX
        here = self.calcCarriage(curX)
        there = self.calcCarriage(newX)

        posInterval = LerpPosInterval(
                self.carriageNP, abs(newX - curX),
                there,
                startPos = here,
                blendType='easeIn')

        posInterval.setDoneEvent('carriageReset')

        def isReset():
            self.paperX = newX

        self.base.acceptOnce('carriageReset', isReset)
        return posInterval
Esempio n. 28
0
 def transition_enter(self):
     self.update_texts()
     for wdg in self.widgets:
         pos = wdg.get_pos()
         start_pos = (pos[0] - 3.6, pos[1], pos[2])
         wdg.set_pos(start_pos)
         Sequence(Wait(abs(pos[2] - 1) / 4),
                  LerpPosInterval(wdg, .5, pos,
                                  blendType='easeInOut')).start()
     self.enable()
Esempio n. 29
0
    def createMoveCarriageInterval(self, newX, curX=None):
        if curX is None:
            curX = self.paperX
        here = self.calcCarriage(curX)
        there = self.calcCarriage(newX)

        posInterval = LerpPosInterval(self.carriageNP,
                                      abs(newX - curX),
                                      there,
                                      startPos=here,
                                      blendType='easeIn')

        posInterval.setDoneEvent('carriageReset')

        def isReset():
            self.paperX = newX

        self.base.acceptOnce('carriageReset', isReset)
        return posInterval
Esempio n. 30
0
    def attack(self, task):
        if self.attackTrig == True:
            speed = 1
            turnSpeed = 0.5
            attackPos, distance, direction = self.minotaurObj.attack(self.camera.getPos(), self.minotaur.getPos(), \
                self.ptGrid, self.spacing, self.lstWalls)
            origPt = self.minotaur.getPos()
            if attackPos != None:
                attack = LerpPosInterval(self.minotaur, speed, Point3(attackPos))
                turnToPlayer = LerpHprInterval(self.minotaur, turnSpeed, self.minotaurObj.facePlayer(direction))
                if distance == 'short':
                    retract = LerpPosInterval(self.minotaur, speed, origPt)
                    attackSeq = Sequence(turnToPlayer, attack, retract, name = 'attack')
                    attackSeq.start()
                else: 
                    attackSeq = Sequence(turnToPlayer, attack, name = 'attack')
                    attackSeq.start()

            self.attackTrig = False
Esempio n. 31
0
    def stab(self, task):
        timer = globalClock.getFrameTime()
        
        speed = 0.2
        stabIn = LerpPosInterval(self.sword, speed, Point3(0,4,0.2))
        stabOut = LerpPosInterval(self.sword, speed, Point3(0.5,1,0.2))
        stab = Sequence(stabIn, stabOut, name = 'stab')
        stab.start()

        self.stabbing = True 

        if self.hit == True: 
            self.minotaurObj.hit()

            self.hurtTime = globalClock.getFrameTime()
            self.hurtShow(task)
            
            self.hit = False
            self.stabbing = False
Esempio n. 32
0
 def __process_player_info(self, data_lst, sender):
     from racing.car.car import NetworkCar
     pos = (data_lst[1], data_lst[2], data_lst[3])
     hpr = (data_lst[4], data_lst[5], data_lst[6])
     velocity = (data_lst[7], data_lst[8], data_lst[9])
     self.server_info[sender] = (pos, hpr, velocity)
     car_name = eng.car_mapping[sender]
     for car in [car for car in game.cars if car.__class__ == NetworkCar]:
         if car_name in car.path:
             LerpPosInterval(car.gfx.nodepath, .2, pos).start()
             LerpHprInterval(car.gfx.nodepath, .2, hpr).start()
Esempio n. 33
0
    def __init__(self):

        ShowBase.__init__(self)

        model = self.loader.loadModel("/e/models/ralph/ralph.egg")
        model.reparentTo(self.render)
        model.setPos(0, 0, 0)

        posItvl = LerpPosInterval(model,
                                  1,
                                  pos = (1, 0, 0),
                                  )
        hprItvl = LerpHprInterval(model,
                                  1,
                                  hpr = (50, 50, 50))

        posItvl.loop()
        hprItvl.loop()

        self.trackball.node().setPos(0, 10, -2)
Esempio n. 34
0
 def transition_exit(self, destroy=True):
     for wdg in self.widgets:
         pos = wdg.get_pos()
         end_pos = (pos[0] + 3.6, pos[1], pos[2])
         seq = Sequence(
             Wait(abs(pos[2] - 1) / 4),
             LerpPosInterval(wdg, .5, end_pos, blendType='easeInOut'),
             Func(wdg.destroy if destroy else wdg.hide))
         if not destroy:
             seq.append(Func(wdg.set_pos, pos))
         seq.start()
Esempio n. 35
0
 def __process_game_packet(data_lst):
     from racing.car.car import NetworkCar
     for i in range(1, len(data_lst), 10):
         car_name = data_lst[i]
         car_pos = (data_lst[i + 1], data_lst[i + 2], data_lst[i + 3])
         car_hpr = (data_lst[i + 4], data_lst[i + 5], data_lst[i + 6])
         cars = self.mdt.logic.cars
         netcars = [car for car in cars if car.__class__ == NetworkCar]
         for car in netcars:
             if car_name in car.path:
                 LerpPosInterval(car.gfx.nodepath, .2, car_pos).start()
                 LerpHprInterval(car.gfx.nodepath, .2, car_hpr).start()
Esempio n. 36
0
    def zoom(self, amount):
        if self.game.isChatting:
            return

        self.targetY = clampScalar(self.targetY + amount, -2, -15)

        if self.interval is not None:
            self.interval.pause()
        self.interval = LerpPosInterval(
            base.camera,
            duration=0.6,
            pos=Vec3(base.camera.getX(), self.targetY, base.camera.getZ()),
            blendType="easeOut",
            name="Camera.zoom",
        )
        self.interval.start()
Esempio n. 37
0
    def __init__(self):

        self.frameMain = DirectFrame(
            frameSize = (base.a2dLeft, base.a2dRight,
                         base.a2dBottom, base.a2dTop),
            frameColor = (0.05, 0.05, 0.05, 1))
        self.frameMain.setTransparency(1)

        tpBig = TextProperties()
        tpBig.setTextScale(1.5)
        tpSmall = TextProperties()
        tpSmall.setTextScale(0.75)
        tpUs = TextProperties()
        tpUs.setUnderscore(True)
        tpMgr = TextPropertiesManager.getGlobalPtr()
        tpMgr.setProperties("big", tpBig)
        tpMgr.setProperties("small", tpSmall)
        tpMgr.setProperties("us", tpUs)

        creditsText = ""
        with open("credits.txt") as f:
            creditsText = f.read()
        self.lblCredits = DirectLabel(
            text = creditsText,
            text_fg = (1,1,1,1),
            text_bg = (0,0,0,0),
            frameColor = (0,0,0,0),
            text_align = TextNode.ACenter,
            scale = 0.1,
            pos = (0, 0, base.a2dTop - 0.2))
        self.lblCredits.setTransparency(1)
        self.lblCredits.reparentTo(self.frameMain)

        self.creditsScroll = LerpPosInterval(
            self.lblCredits,
            12.0,
            (0, 0, base.a2dTop + 3.5),
            startPos=(0, 0, base.a2dBottom),
            name="CreditsScroll")

        self.btnBack = DirectButton(
            text = "BACK",
            text_fg = (1,1,1,1),
            text_align = TextNode.ALeft,
            scale = 0.1,
            pad = (0.15, 0.15),
            pos = (base.a2dLeft + 0.08, 0, base.a2dBottom + 0.05),
            frameColor = (
                (0.2,0.2,0.2,0.8),
                (0.4,0.4,0.4,0.8),
                (0.4,0.4,0.4,0.8),
                (0.1,0.1,0.1,0.8),
                ),
            relief = 1,
            command = base.messenger.send,
            extraArgs = ["Credits-Back"],
            pressEffect = False,
            rolloverSound = None,
            clickSound = None)
        self.btnBack.setTransparency(1)
        self.btnBack.reparentTo(self.frameMain)

        self.hide()
Esempio n. 38
0
 def init_menu(self):
     interval = LerpHprInterval(self.cameraPivot, 1, (0,0,0), (0,10,0))
     interval2 = LerpPosInterval(self.cameraPivot, 1, (0,0,0), (0,0,-0.05))
     interval.start()
     interval2.start()
     taskMgr.doMethodLater(1, spawnButton, "spawnButton")         
class LegendaryFishingGameGUI:
    
    def __init__(self, gameObject = None):
        base.loadingScreen.beginStep('LegendaryGameGUI', 4, 20)
        self.gameObject = gameObject
        self.guiImage = loader.loadModel('models/minigames/pir_m_gam_fsh_legendaryGui')
        self.UICompoments = { }
        self.uiBaseNode = NodePath('baseNode')
        self.uiBaseNode.reparentTo(aspect2d)
        self.uiBaseNode.show()
        self.leftBaseNode = NodePath('leftBaseNode')
        self.leftBaseNode.reparentTo(base.a2dLeftCenter)
        self.leftBaseNode.show()
        self.fishActor = None
        self.actorAnim = { }
        self.scaleSize = {
            InventoryType.Collection_Set11_Part1: 0.059999999999999998,
            InventoryType.Collection_Set11_Part2: 0.055,
            InventoryType.Collection_Set11_Part3: 0.12,
            InventoryType.Collection_Set11_Part4: 0.086999999999999994,
            InventoryType.Collection_Set11_Part5: 0.080000000000000002 }
        self.meterFrame = DirectFrame(parent = self.leftBaseNode, frameSize = (-0.29999999999999999, 0.29999999999999999, -1.0, 0.0), frameColor = (1.0, 1.0, 1.0, 0.0), relief = None, state = DGG.DISABLED, pos = (1.0, 0.0, -0.45000000000000001), hpr = (0, 0, 0), scale = (1.3, 0.0, 1.3), image = self.guiImage.find('**/pir_t_gui_fsh_meter'), image_scale = (0.20000000000000001, 0.0, 0.80000000000000004), image_pos = (0, 0, 0), text = '', textMayChange = 1, text_scale = PiratesGuiGlobals.TextScaleTitleLarge, text_pos = (-0.55000000000000004, 0.10000000000000001), text_shadow = PiratesGuiGlobals.TextShadow)
        self.UICompoments['meterFrame'] = self.meterFrame
        self.fishingRod = DirectFrame(parent = self.meterFrame, frameSize = (-0.29999999999999999, 0.29999999999999999, -1.0, 0.0), relief = None, state = DGG.DISABLED, pos = FishingGlobals.fishingRodScreenPosition, image = self.guiImage.find('**/pir_t_gui_fsh_fullRod'), image_scale = (1.0, 0.0, 0.125), image_pos = (0.20000000000000001, 0, 0))
        self.fishingRod.setR(FishingGlobals.fishingRodInitSlope)
        self.UICompoments['fishingRod'] = self.fishingRod
        base.loadingScreen.tick()
        self.fishingHandleBaseFrame = DirectFrame(parent = self.uiBaseNode, frameSize = (-0.29999999999999999, 0.29999999999999999, -1.5, 1.5), frameColor = (1.0, 1.0, 1.0, 0.0), relief = None, state = DGG.DISABLED, pos = (0.0, 0.0, 0.0), hpr = (0, 0, 0), scale = (0.71999999999999997, 0.0, 0.71999999999999997), image = self.guiImage.find('**/pir_t_gui_fsh_partialRod'), image_scale = (3.7999999999999998, 0.0, 1.8999999999999999), image_pos = (0, 0, 0), image_hpr = (0.0, 0.0, 0))
        self.fishingHandleBaseFrame.hide()
        self.UICompoments['fishingHandleBaseFrame'] = self.fishingHandleBaseFrame
        self.fishingHandle = DirectFrame(parent = self.fishingHandleBaseFrame, frameSize = (-0.080000000000000002, 0.080000000000000002, -0.20000000000000001, 0.20000000000000001), relief = None, state = DGG.DISABLED, pos = (-0.10000000000000001, 0.0, -0.050000000000000003), hpr = (0, 0, 0), image = self.guiImage.find('**/pir_t_gui_fsh_handleArm'), image_scale = (1.0, 0.0, 1.0), image_pos = (-0.042000000000000003, 0, -0.115), image_hpr = (0.0, 0.0, 0))
        self.UICompoments['fishingHandle'] = self.fishingHandle
        self.arrowImage = DirectFrame(parent = self.fishingHandleBaseFrame, frameSize = (-0.40000000000000002, 0.40000000000000002, -0.40000000000000002, 0.40000000000000002), relief = None, state = DGG.DISABLED, pos = (0.0, 0.0, 0.0), hpr = (0, 0, 0), scale = (1.2, 0.0, 1.2), image = self.guiImage.find('**/pir_t_gui_fsh_arrow'), image_scale = (1.0, 0.0, 1.0), image_pos = (0.0, 0, 0.0), image_hpr = (0.0, 0.0, 0.0))
        self.arrowImage.hide()
        self.UICompoments['arrowImage'] = self.arrowImage
        btnGeom = (self.guiImage.find('**/pir_t_gui_fsh_handle'), self.guiImage.find('**/pir_t_gui_fsh_handle'), self.guiImage.find('**/pir_t_gui_fsh_handleOn'))
        self.fishingHandleButton = GuiButton(pos = (-0.29999999999999999, 0, -0.55000000000000004), hpr = (0, 0, 0), scale = 0.45000000000000001, image = btnGeom, image_pos = (0, 0, 0), image_scale = 1.0, sortOrder = 2)
        self.fishingHandleButton.bind(DGG.B1PRESS, self.handleButtonClicked)
        self.fishingHandleButton.reparentTo(self.fishingHandle)
        self.UICompoments['fishingHandleButton'] = self.fishingHandleButton
        self.fishingHandleBaseFrame.setTransparency(TransparencyAttrib.MAlpha)
        self.meterFrame.setTransparency(TransparencyAttrib.MAlpha)
        self.lineOneTransitTextNode = TextNode('lineOneTransitText')
        self.lineOneTransitTextNode.setFont(PiratesGlobals.getPirateFont())
        self.lineOneTransitTextNode.setText('')
        self.lineOneTransitTextNode.setAlign(TextNode.ACenter)
        self.lineOneTransitTextNode.setTextColor(1.0, 1.0, 1.0, 0.5)
        self.lineOneTransitTextNodePath = NodePath(self.lineOneTransitTextNode)
        self.lineOneTransitTextNodePath.setPos(0.0, 0.0, -0.80000000000000004)
        self.lineOneTransitTextNodePath.setScale(0.34999999999999998, 0.34999999999999998, 0.34999999999999998)
        self.lineOneTransitTextNodePath.reparentTo(self.uiBaseNode)
        self.lineOneTransitTextNodePath.hide()
        self.UICompoments['lineOneTransitText'] = self.lineOneTransitTextNodePath
        self.lineTwoTransitTextNode = TextNode('lineTwoTransitText')
        self.lineTwoTransitTextNode.setFont(PiratesGlobals.getPirateFont())
        self.lineTwoTransitTextNode.setText('')
        self.lineTwoTransitTextNode.setAlign(TextNode.ACenter)
        self.lineTwoTransitTextNode.setTextColor(1.0, 1.0, 1.0, 0.5)
        self.lineTwoTransitTextNodePath = NodePath(self.lineTwoTransitTextNode)
        self.lineTwoTransitTextNodePath.setPos(-0.40000000000000002, 0.0, -0.94999999999999996)
        self.lineTwoTransitTextNodePath.setScale(0.12, 0.12, 0.12)
        self.lineTwoTransitTextNodePath.reparentTo(self.uiBaseNode)
        self.lineTwoTransitTextNodePath.hide()
        self.UICompoments['lineTwoTransitText'] = self.lineTwoTransitTextNodePath
        base.loadingScreen.tick()
        self.test_guiImage = loader.loadModel('models/gui/toplevel_gui')
        self.buttonIcon = (self.test_guiImage.find('**/treasure_chest_closed'), self.test_guiImage.find('**/treasure_chest_closed'), self.test_guiImage.find('**/treasure_chest_closed_over'))
        self.winImagePanel = GuiPanel.GuiPanel('', 2.6000000000000001, 1.8999999999999999, True)
        self.winImagePanel.setPos(-1.3, 0.0, -0.94999999999999996)
        self.winImagePanel.reparentTo(self.uiBaseNode)
        self.winImagePanel.background = OnscreenImage(parent = self.winImagePanel, scale = (2.3999999999999999, 0, 1.8), image = self.guiImage.find('**/pir_t_gui_fsh_posterBackground'), hpr = (0, 0, 0), pos = (1.3, 0, 0.94999999999999996))
        self.winImagePanel.setBin('gui-popup', -4)
        self.winTitleTextNode = TextNode('winTitleTextNode')
        self.winTitleTextNode.setText('Congratulations!')
        self.winTitleTextNode.setAlign(TextNode.ACenter)
        self.winTitleTextNode.setFont(PiratesGlobals.getPirateFont())
        self.winTitleTextNode.setTextColor(0.23000000000000001, 0.089999999999999997, 0.029999999999999999, 1.0)
        self.winTitleTextNodePath = NodePath(self.winTitleTextNode)
        self.winTitleTextNodePath.setPos(1.3500000000000001, 0.0, 1.6699999999999999)
        self.winTitleTextNodePath.setScale(0.17999999999999999)
        self.winTitleTextNodePath.reparentTo(self.winImagePanel)
        self.wholeStoryTextNode = TextNode('storyTextNode')
        self.wholeStoryTextNode.setText('')
        self.wholeStoryTextNode.setWordwrap(19.0)
        self.wholeStoryTextNode.setTextColor(0.23000000000000001, 0.089999999999999997, 0.029999999999999999, 1.0)
        self.wholeStoryTextNodePath = NodePath(self.wholeStoryTextNode)
        self.wholeStoryTextNodePath.setPos(0.33000000000000002, 0.0, 1.6399999999999999)
        self.wholeStoryTextNodePath.setScale(0.050000000000000003)
        self.wholeStoryTextNodePath.reparentTo(self.winImagePanel)
        self.winImagePanel.closeButton['command'] = self.closeDialogGotNextState
        self.winImagePanel.closeButton['extraArgs'] = [
            'winImagePanel',
            'FarewellLegendaryFish',
            False]
        self.UICompoments['winImagePanel'] = self.winImagePanel
        self.winImagePanel.hide()
        self.luiCloseDialogSequence = Sequence()
        self.arrowImageRotationInterval = LerpHprInterval(self.arrowImage, 2.2000000000000002, self.arrowImage.getHpr() + Point3(0.0, 0.0, 280.0), self.arrowImage.getHpr())
        self.luiArrowRotatingSequence = Sequence(Func(self.showGui, [
            'arrowImage']), Parallel(Func(self.arrowImageRotationInterval.start), Wait(2.2000000000000002)), Func(self.hideGui, [
            'arrowImage']), Func(self.arrowImage.setHpr, self.arrowImage.getHpr() + Point3(0.0, 0.0, 5.0)), name = self.gameObject.distributedFishingSpot.uniqueName('luiArrowRotatingSequence'))
        self.lineOneColorChange = LerpColorScaleInterval(self.lineOneTransitTextNodePath, FishingGlobals.legendaryTransitionTextDuration, (1.0, 1.0, 1.0, 0.0), (1.0, 1.0, 1.0, 1.0), blendType = 'easeOut')
        self.lineOnePosChange = LerpPosInterval(self.lineOneTransitTextNodePath, FishingGlobals.legendaryTransitionTextDuration, (0.0, 0.0, -0.20000000000000001), (0.0, 0.0, -0.80000000000000004), blendType = 'easeOut')
        self.lineTwoCholorChange = LerpColorScaleInterval(self.lineTwoTransitTextNodePath, FishingGlobals.legendaryTransitionTextDuration, (1.0, 1.0, 1.0, 1.0), (1.0, 1.0, 1.0, 1.0), blendType = 'easeOut')
        self.lineTwoPosChange = LerpPosInterval(self.lineTwoTransitTextNodePath, FishingGlobals.legendaryTransitionTextDuration, (0.0, 0.0, -0.32000000000000001), (0.0, 0.0, -0.94999999999999996), blendType = 'easeOut')
        self.transitionTextMovingSequence = Sequence(Func(self.lineOneTransitTextNodePath.show), Func(self.lineTwoTransitTextNodePath.show), Parallel(self.lineOnePosChange, self.lineTwoPosChange, self.lineOneColorChange, self.lineTwoCholorChange), Func(self.lineOneTransitTextNodePath.hide), Func(self.lineTwoTransitTextNodePath.hide), name = self.gameObject.distributedFishingSpot.uniqueName('transitionTextMovingSequence'))
        self.meterFadeInInterval = Sequence(Func(self.meterFrame.show), LerpColorScaleInterval(self.meterFrame, FishingGlobals.legendaryTransitionTextDuration, colorScale = (1.0, 1.0, 1.0, 1.0), startColorScale = (1.0, 1.0, 1.0, 0.0), blendType = 'easeOut'), name = 'FadeInLegendaryMeter')
        self.meterFadeOutInterval = Sequence(LerpColorScaleInterval(self.meterFrame, FishingGlobals.legendaryTransitionTextDuration, colorScale = (1.0, 1.0, 1.0, 0.0), startColorScale = (1.0, 1.0, 1.0, 1.0), blendType = 'easeOut'), Func(self.meterFrame.hide), name = 'FadeOutLegendaryMeter')
        self.rodFadeInInterval = Sequence(Func(self.fishingHandleBaseFrame.show), LerpColorScaleInterval(self.fishingHandleBaseFrame, FishingGlobals.legendaryTransitionTextDuration, colorScale = (1.0, 1.0, 1.0, 1.0), startColorScale = (1.0, 1.0, 1.0, 0.0), blendType = 'easeOut'), name = 'FadeInLegendaryRodInterface')
        self.rodFadeOutInterval = Sequence(LerpColorScaleInterval(self.fishingHandleBaseFrame, FishingGlobals.legendaryTransitionTextDuration, colorScale = (1.0, 1.0, 1.0, 0.0), startColorScale = (1.0, 1.0, 1.0, 1.0), blendType = 'easeOut'), Func(self.fishingHandleBaseFrame.hide), name = 'FadeOutLegendaryRodInterface')
        base.loadingScreen.tick()
        smallScale = self.fishingHandleButton['scale']
        bigScale = self.fishingHandleButton['scale'] * 1.2
        self.buttonGrowUpInterval = LerpScaleInterval(self.fishingHandleButton, 1.0, bigScale, smallScale)
        self.luiFightTransitSequence = Sequence(Parallel(Func(self.fishingHandleBaseFrame.show), Func(self.meterFadeOutInterval.start), Func(self.rodFadeInInterval.start), Func(self.buttonGrowUpInterval.start)), Wait(1.0), Func(self.meterFrame.hide), name = self.gameObject.distributedFishingSpot.uniqueName('luiFightTransitSequence'))
        self.luiReelTransitSequence = Sequence(Parallel(Func(self.fishingHandleBaseFrame.show), Func(self.meterFadeOutInterval.start), Func(self.rodFadeInInterval.start)), Wait(1.0), Func(self.meterFrame.hide), name = self.gameObject.distributedFishingSpot.uniqueName('luiReelTransitSequence'))
        self.luiStruggleTransitSequence = Sequence(Parallel(Func(self.meterFrame.show), Func(self.resetFishingRod), self.meterFadeInInterval, self.rodFadeOutInterval), Wait(1.0), Func(self.fishingHandleBaseFrame.hide), name = self.gameObject.distributedFishingSpot.uniqueName('luiStruggleTransitSequence'))
        self.meterFadeOutInterval.start()
        self.rodFadeOutInterval.start()
        self.hideAllGUI()
        base.loadingScreen.endStep('LegendaryGameGUI')

    
    def hideAllGUI(self):
        self.uiBaseNode.reparentTo(hidden)
        self.leftBaseNode.reparentTo(hidden)

    
    def showAllGUI(self):
        self.uiBaseNode.reparentTo(aspect2d)
        self.leftBaseNode.reparentTo(base.a2dLeftCenter)

    
    def hideGui(self, nameList):
        for ui in nameList:
            self.UICompoments[ui].hide()
        

    
    def showGui(self, nameList):
        for ui in nameList:
            self.UICompoments[ui].show()
        

    
    def destroy(self):
        self.arrowImageRotationInterval.pause()
        self.arrowImageRotationInterval.clearToInitial()
        self.luiArrowRotatingSequence.pause()
        self.luiArrowRotatingSequence.clearToInitial()
        self.luiCloseDialogSequence.pause()
        self.luiCloseDialogSequence.clearToInitial()
        totalKey = self.UICompoments.keys()
        for iKey in totalKey:
            del self.UICompoments[iKey]
        
        self.fishingHandle = None
        self.fishingHandleButton = None
        self.fishingRod.removeNode()
        self.leftBaseNode.removeNode()
        self.uiBaseNode.removeNode()
        if self.fishActor:
            self.fishActor.destroy()
            self.fishActor = None
        

    
    def handleButtonClicked(self, mouseKey):
        if self.gameObject.lfgFsm.getCurrentOrNextState() in [
            'CatchIt']:
            self.gameObject.lfgFsm.request('Transition', 'Struggle')
            self.gameObject.sfx['legendaryGreen'].play()
        

    
    def setTransitionText(self, state):
        self.lineOneTransitTextNode.setText(PLocalizer.LegendaryFishingGui[state][0])
        self.lineTwoTransitTextNode.setText(PLocalizer.LegendaryFishingGui[state][1])

    
    def resetInterval(self):
        self.transitionTextMovingSequence.pause()
        self.transitionTextMovingSequence.clearToInitial()
        self.lineOneColorChange.pause()
        self.lineOneColorChange.clearToInitial()
        self.lineOnePosChange.pause()
        self.lineOnePosChange.clearToInitial()
        self.lineTwoCholorChange.pause()
        self.lineTwoCholorChange.clearToInitial()
        self.lineTwoPosChange.pause()
        self.lineTwoPosChange.clearToInitial()
        self.luiReelTransitSequence.pause()
        self.luiReelTransitSequence.clearToInitial()
        self.luiStruggleTransitSequence.pause()
        self.luiStruggleTransitSequence.clearToInitial()
        self.luiFightTransitSequence.pause()
        self.luiFightTransitSequence.clearToInitial()
        self.buttonGrowUpInterval.pause()
        self.buttonGrowUpInterval.clearToInitial()
        self.meterFadeOutInterval.pause()
        self.meterFadeOutInterval.clearToInitial()
        self.rodFadeInInterval.pause()
        self.rodFadeInInterval.clearToInitial()
        self.meterFadeInInterval.pause()
        self.meterFadeInInterval.clearToInitial()
        self.rodFadeOutInterval.pause()
        self.rodFadeOutInterval.clearToInitial()

    
    def fightingTransit(self):
        self.luiFightTransitSequence.start()

    
    def reelTransit(self):
        self.luiReelTransitSequence.start()

    
    def struggleTransit(self):
        self.luiStruggleTransitSequence.start()

    
    def resetFishingRod(self):
        self.fishingRod.setR(FishingGlobals.fishingRodInitSlope)

    
    def showWinImage(self, fish):
        self.hideGui([
            'meterFrame',
            'fishingHandleBaseFrame'])
        result = fish.myData['name'].split(' ')
        fileName = str(result[0]).capitalize()
        imgName = 'pir_t_gui_fsh_render%s' % fileName
        self.actorAnim['swimIdleOpposite'] = 'models/char/pir_a_gam_fsh_%s_%s.bam' % (fish.myData['model'], 'swimIdleOpposite')
        self.fishActor = BlendActor('models/char/pir_r_gam_fsh_%s.bam' % fish.myData['model'], self.actorAnim, FishingGlobals.defaultFishBlendTime, FishingGlobals.fishBlendTimeDict)
        self.fishActor.setPlayRate(fish.myData['speed'] * fish.myData['swimAnimationMultiplier'], 'swimIdleOpposite')
        self.fishActor.changeAnimationTo('swimIdleOpposite')
        self.fishActor.reparentTo(self.winImagePanel)
        self.fishActor.setScale(self.scaleSize[fish.myData['id']])
        self.fishActor.setPos(1.7, 0, 1.0)
        self.fishActor.setHpr(0, 0, 35)
        self.fishActor.setDepthWrite(True)
        self.fishActor.setDepthTest(True)
        self.wholeStoryTextNode.setText(PLocalizer.LegendSelectionGui['wholeStory'][fish.myData['id']])
        self.winImagePanel.show()

    
    def closeDialogGotNextState(self, object, targetState, ifFadeInAgain):
        if self.fishActor:
            self.fishActor.destroy()
            self.fishActor = None
        
        self.luiCloseDialogSequence = Sequence(Func(self.gameObject.distributedFishingSpot.fadeOut), Wait(0.40000000000000002), Func(self.UICompoments[object].hide), Func(self.gameObject.lfgFsm.request, targetState), name = self.gameObject.distributedFishingSpot.uniqueName('luiCloseDialogSequence'))
        self.luiCloseDialogSequence.start()

    
    def updateStruggleTimerText(self, time, percent):
        self.meterFrame['text'] = str(time)
        self.meterFrame['text_fg'] = (1.0 - percent, percent, 0.0, 1.0)
Esempio n. 40
0
	def __init__(self):
		self.keyMap = {"left":0, "right":0, "forward":0,"backward":0, "cam-left":0, "cam-right":0,"res":0,
		"w" : 0, "s" : 0, "a" : 0, "d" : 0,"firstPerson":0,"ThirdPerson":1,"l":0}
		base.win.setClearColor(Vec4(0,0,0,1))
		wp = WindowProperties()
		wp.setFullscreen(1)
		wp.setSize(1024,768)
		base.openMainWindow()
		base.win.requestProperties(wp)
		base.graphicsEngine.openWindows()
		#Post the instructions
		
		#Intro Starts
		tex = MovieTexture("name")
		assert tex.read("models/play/entrance.avi"), "Failed to load video!"
		cm = CardMaker("My Fullscreen Card");
		cm.setFrameFullscreenQuad()
		cm.setUvRange(tex)
		card = NodePath(cm.generate())
		card.reparentTo(render2d)
		card.setTexture(tex)
		card.setTexScale(TextureStage.getDefault(), tex.getTexScale())
		sound=loader.loadSfx("models/play/entrance.avi")
		tex.synchronizeTo(sound)
		tex.setLoop(False)
		sound.play()
		def myTask(task):
			if (int(tex.getTime()) >=14):
				print "Stoping"
				card.remove()
				return task.done
			return task.cont
		taskMgr.add(myTask, "Task")
		
		mytimer = DirectLabel()
		mytimer.reparentTo(render)
		#mytimer.setY(0)
		textObject = OnscreenText(text = "", pos = (0.95,-0.95), 
scale = 0.07,fg=(1,0.5,0.5,1),align=TextNode.ACenter,mayChange=1)

		def dCharstr(theString):
			if len(theString) != 2:
				theString = '0' + theString
				return theString
	    
		


		def timerTask(task):
			secondsTime = int(task.time)
			minutesTime = int(secondsTime/60)
			hoursTime = int(minutesTime/60)
			mytimer['text'] = "%02d:%02d:%02d" % (hoursTime, minutesTime%60, secondsTime%60)
			#print mytimer['text']
			textObject.setText(mytimer['text'])
			return task.cont

		taskMgr.add(timerTask, 'timerTask')
		mytimer.reparentTo(render)
		
		self.inst1 = addInstructions(0.95, "[ESC]: Quit")
		self.inst2 = addInstructions(0.90, "[L]: Map View")
		self.inst3 = addInstructions(0.85, "Movement: Arrow Keys")
		self.inst2 = addInstructions(0.80, "[R]: Reset Position")

		self.road = loader.loadModel("models/floor")
		
		emin,emax =self.road.getTightBounds()
		env = []
		esize=20
		for en in range(0,esize):
			for j in range(0,esize):
				#if (j%2==0):
				#print j+(en*9),"Here"
				env.append(self.road)
				env[j+(en*9)].copyTo(render)
				env[j+(en*9)].setPos(emin.x*(en-esize/2),emax.y*(j-esize/2),0)
		
		self.BuildingRow = [loader.loadModel("models/BuildingCluster1col"),
					loader.loadModel("models/BuildingCluster2col"),
					loader.loadModel("models/BuildingCluster3col"),
					loader.loadModel("models/BuildingCluster4col")]

		e0,e1=env[0].getTightBounds()
		mapsize=e0.x*len(env)
		self.vehicle_carsx=loader.loadModel("models/vehicles/carnsxcol")
		self.sign=Actor("models/squarrow-model",{
                        "play":"models/squarrow-anim"})
		self.sign1=Actor("models/squarrow-model",{
                        "play":"models/squarrow-anim"})
		self.vehicle_ford=loader.loadModel("models/vehicles/fordcol")
		self.vehicle_girlcar=loader.loadModel("models/vehicles/girlcarcol")
		self.vehicle_policecar=loader.loadModel("models/vehicles/policecarcol")
		self.vehicle_fireengine=loader.loadModel("models/vehicles/fireenginecol")
		self.vehicle_carsx.reparentTo(render)
		self.sign.reparentTo(render)
		self.sign1.reparentTo(render)
		self.vehicle_carsx.setPos(-35,295,0)
		self.vehicle_carsx.setScale(5)
		self.vehicle_ford.reparentTo(render)
		self.vehicle_ford.setPos(52,270,0)
		self.vehicle_ford.setScale(3)
		self.vehicle_girlcar.reparentTo(render)
		self.vehicle_girlcar.setPos(200,20,0)
		self.vehicle_girlcar.setScale(5)
		self.vehicle_girlcar.setH(-90)
		self.vehicle_policecar.reparentTo(render)
		self.vehicle_policecar.setPos(-33,295,0)
		self.vehicle_policecar.setScale(3)
		self.vehicle_fireengine.reparentTo(render)
		self.vehicle_fireengine.setPos(-60,-294,0)
		self.vehicle_fireengine.setH(90)
		self.vehicle_fireengine.setScale(3)
		self.sign1.setPos(-129,-44,150)
		self.sign.setPos(89,172.6,150)
                self.sign1.setHpr(-90,0,60)
                self.sign.setHpr(-90,0,60)
		self.sign1.loop("play")
		self.sign.loop("play")
		self.vehicle_carsxinterval=LerpPosInterval(self.vehicle_carsx, 10,Vec3(-33,-325,0) ,Vec3(52,295,0))
		self.vehicle_carsxinterval.loop()
		self.vehicle_fordinterval=LerpPosInterval(self.vehicle_ford, 10,Vec3(52,-325,0) ,Vec3(52,270,0))
		self.vehicle_fordinterval.loop()
		self.vehicle_policecarinterval=LerpPosInterval(self.vehicle_policecar, 10,Vec3(-33,295,0) ,Vec3(-33,-325,0))
		self.vehicle_policecarinterval.loop()
		self.vehicle_fireengineinterval=LerpPosInterval(self.vehicle_fireengine, 10,Vec3(52,270,0) ,Vec3(52,-350,0))
		self.vehicle_girlcar=LerpPosInterval(self.vehicle_girlcar,10,Vec3(-54,33,6),Vec3(-258,33,6))
		self.vehicle_girlcar.loop()
		
		for j in self.BuildingRow:
			j.setPos(e0.x,e1.y,0)
		
		building=[]
		for j in range(0,8):
			building.append(self.BuildingRow)
			offset=0
			c=env[0].getX()
			x=e0.x
			y=e1.y+(emin.x*4*j);
			for i in building[j]:
				x=x-emin.x
				i.copyTo(render)
				min,max =i.getTightBounds()
				width=max-min
				i.setPos(x,y,0)
				x=x-emin.x
				i.copyTo(render)
				i.setPos(-x+50,y,0)
		
							
		# Create the main character, Ralph
		sonicStartPos = (0,0,-2)
		self.sonic = Actor("models/people/sonic/sonic",{
			"board":"models/people/sonic/sonic-board",
			"fallingwboard":"models/people/sonic/sonic-fallingwboard",
			"fallingwoboard":"models/people/sonic/sonic-fallingwoboard",
			"run":"models/people/sonic/sonic-run",
			"win":"models/people/sonic/sonic-win",
			})
		self.sonic.reparentTo(render)
		self.sonic.setScale(.5)
		self.sonic.setPos(sonicStartPos)
		
		# Create a floater object.  We use the "floater" as a temporary
		# variable in a variety of calculations.
		
		self.floater = NodePath(PandaNode("floater"))
		self.floater.reparentTo(render)

		# Accept the control keys for movement and rotation

		self.accept("escape", sys.exit)
		self.accept("arrow_left", self.setKey, ["left",1])
		self.accept("arrow_right", self.setKey, ["right",1])
		self.accept("arrow_up", self.setKey, ["forward",1])
		self.accept("arrow_down", self.setKey, ["backward",1])
		self.accept("arrow_left-up", self.setKey, ["left",0])
		self.accept("arrow_right-up", self.setKey, ["right",0])
		self.accept("arrow_up-up", self.setKey, ["forward",0])
		self.accept("arrow_down-up", self.setKey, ["backward",0])

		self.accept("z", self.setKey, ["cam-left",1])
		self.accept("x", self.setKey, ["cam-right",1])
		self.accept("z-up", self.setKey, ["cam-left",0])
		self.accept("x-up", self.setKey, ["cam-right",0])
		self.accept("l", self.setKey, ["l", 1])
		self.accept("l-up", self.setKey, ["l", 0])
		self.accept("w", self.setKey, ["w", 1])
		self.accept("s", self.setKey, ["s", 1])   
		self.accept("a", self.setKey, ["a", 1])   
		self.accept("d", self.setKey, ["d", 1])
		self.accept("r", self.setKey, ["res", 1])
		self.accept("w-up", self.setKey, ["w", 0])
		self.accept("s-up", self.setKey, ["s", 0])
		self.accept("a-up", self.setKey, ["a", 0])
		self.accept("d-up", self.setKey, ["d", 0])

		self.accept("j", self.setKey, ["firstPerson",1])
		self.accept("j", self.setKey, ["ThirdPerson",0])
		self.accept("k", self.setKey, ["firstPerson",0])
		self.accept("k", self.setKey, ["ThirdPerson",1])
		
		

		# taskMgr.add(self.cameraControl, "Camera Control")
		taskMgr.add(self.move,"moveTask")

		# Game state variables
		self.isMoving = False

		# Set up the camera
		
		#base.disableMouse()
		base.camera.setPos(self.sonic.getX(),self.sonic.getY()-10,40)
		# base.camera.setH(-90)
		self.cTrav = CollisionTraverser()

		self.sonicGroundRay = CollisionRay()
		self.sonicGroundRay.setOrigin(0,0,1000)
		self.sonicGroundRay.setDirection(0,0,-1)
		self.sonicGroundCol = CollisionNode('sonicRay')
		self.sonicGroundCol.addSolid(self.sonicGroundRay)
		self.sonicGroundCol.setFromCollideMask(BitMask32.bit(0))
		self.sonicGroundCol.setIntoCollideMask(BitMask32.allOff())
		self.sonicGroundColNp = self.sonic.attachNewNode(self.sonicGroundCol)
		self.sonicGroundHandler = CollisionHandlerQueue()
		self.cTrav.addCollider(self.sonicGroundColNp, self.sonicGroundHandler)

		# Uncomment this line to see the collision rays
		#self.sonicGroundColNp.show()
		#self.camGroundColNp.show()
	   
		# Uncomment this line to show a visual representation of the 
		# collisions occuring
		#self.cTrav.showCollisions(render)
		
		# Create some lighting
		ambientLight = AmbientLight("ambientLight")
		ambientLight.setColor(Vec4(.3, .3, .3, 1))
		directionalLight = DirectionalLight("dlight")
		directionalLight.setDirection(Vec3(0,-5, -5))
		directionalLight.setColor(Vec4(1, 1, 1, 1))
		#directionalLight.setHpr(0, -60, 0)
		directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
		ml=render.attachNewNode(directionalLight)
		#self.mylight= render.attachNewNode("dl")
		inter=Func(light,directionalLight)
		#directionalLight.reparentTo(self.mylight)
		#print dir(inter)
		inter.start()
		inter.loop()
		render.setLight(render.attachNewNode(ambientLight))
		render.setLight(ml)
Esempio n. 41
0
class Camera(object):
    """Uses mouse controls to orbit the camera around a parent."""

    def __init__(self, game, parent):
        self.game = game

        # class properties for camera rotation
        self.heading = 0
        self.pitch = 0

        # class properties for camera zoom
        self.targetY = -6
        self.interval = None

        # find screen center
        props = base.win.getProperties()
        self.centerX = props.getXSize() / 2
        self.centerY = props.getYSize() / 2

        # constrain mouse
        base.disableMouse()  # disable default mouse camera control
        self.hideMouse()

        # set up floater
        self.floater = render.attachNewNode("floater")
        self.floater.reparentTo(parent)  # inherit position from parent, but rotation and scale from render
        self.floater.setEffect(CompassEffect.make(render, CompassEffect.P_rot | CompassEffect.P_scale))
        self.floater.setZ(1)  # distance above model

        # set up camera
        base.camera.reparentTo(self.floater)
        base.camera.setY(self.targetY)  # original distance from model
        base.camera.lookAt(self.floater)

        # camera zooming
        # TODO move into method, clamp Y value?
        base.accept("wheel_up", lambda: self.zoom(2))
        base.accept("shift-wheel_up", lambda: self.zoom(2))
        base.accept("wheel_down", lambda: self.zoom(-2))
        base.accept("shift-wheel_down", lambda: self.zoom(-2))

        # start task
        taskMgr.add(self.mouseControl, "Camera.mouseControl")

    def hideMouse(self):
        props = WindowProperties()
        props.setCursorHidden(True)
        props.setMouseMode(WindowProperties.M_relative)
        base.win.requestProperties(props)

    def showMouse(self):
        props = WindowProperties()
        props.setCursorHidden(False)
        props.setMouseMode(WindowProperties.M_absolute)
        base.win.requestProperties(props)

    def mouseControl(self, task):
        if self.game.isChatting:
            return task.cont

        md = base.win.getPointer(0)
        x = md.getX()
        y = md.getY()

        # update heading & pitch based on mouse movement from screen center
        if base.win.movePointer(0, self.centerX, self.centerY):
            self.heading -= (x - self.centerX) * 0.5
            self.pitch -= (y - self.centerY) * 0.5

        # constrain pitch
        if self.pitch < 280:
            self.pitch = 280
        if self.pitch > 360:
            self.pitch = 360

        # update floater
        self.floater.setHpr(self.heading, self.pitch, 0)

        return task.cont

    def zoom(self, amount):
        if self.game.isChatting:
            return

        self.targetY = clampScalar(self.targetY + amount, -2, -15)

        if self.interval is not None:
            self.interval.pause()
        self.interval = LerpPosInterval(
            base.camera,
            duration=0.6,
            pos=Vec3(base.camera.getX(), self.targetY, base.camera.getZ()),
            blendType="easeOut",
            name="Camera.zoom",
        )
        self.interval.start()
class LegendaryFishFSM(FishFSM):
    
    def __init__(self, fish):
        FishFSM.__init__(self, fish)
        self.defaultTransitions = {
            'Offscreen': [
                'FinalBackToSea',
                'Swimming',
                'TurnAround',
                'HookedFighting',
                'AboutToBiteLure'],
            'Swimming': [
                'TurnAround',
                'Biting',
                'AboutToBiteLure',
                'Offscreen'],
            'AboutToBiteLure': [
                'Swimming',
                'Biting',
                'Offscreen'],
            'TurnAround': [
                'AboutToBiteLure',
                'Swimming',
                'Offscreen'],
            'Biting': [
                'Swimming',
                'PullingLure',
                'Hooked',
                'Flee',
                'Offscreen'],
            'Hooked': [
                'HookedFighting',
                'PullingLure',
                'Offscreen'],
            'PullingLure': [
                'Hooked',
                'HookedFighting',
                'Flee',
                'Offscreen'],
            'HookedFighting': [
                'PullingLure',
                'Hooked',
                'Flee',
                'Offscreen'],
            'Flee': [
                'Swimming',
                'TurnAround',
                'Offscreen'],
            'FinalBackToSea': [
                'Offscreen'] }

    
    def enterAboutToBiteLure(self):
        self.fish.initVariables()
        self.fish.showStaminaBar()
        self.fish.actor.clearControlEffectWeights()
        self.fish.reparentTo(self.fish.fishManager.objectsWithCaustics)
        self.fish.setPos(FishingGlobals.rightFishBarrier + FishingGlobals.fullyOffscreenXOffset, 0.0, max(-63.0, self.fish.fishManager.gameObject.lure.getZ()))
        self.fish.actor.changeAnimationTo('swimIdleOpposite')
        self.lfChaseLureSequence = Sequence(self.fish.posInterval(self.fish.myData['swimLeftDuration'], Point3(self.fish.myData['fishTurnX'], 0.0, self.fish.getZ())), Func(self.fish.actor.changeAnimationTo, 'turnOpposite', False), Wait(self.fish.actor.getDuration('turnOpposite') / 4.0), Func(self.fish.actor.changeAnimationTo, 'swimIdle'), self.fish.posInterval(self.fish.myData['swimRightDuration'], Point3(self.fish.fishManager.gameObject.lure.getX() - self.fish.myData['biteXOffset'], 0.0, self.fish.getZ())), Func(self.request, 'Biting'), name = self.fish.fishManager.gameObject.distributedFishingSpot.uniqueName('lfChaseLureSequence'))
        self.lfChaseLureSequence.start()

    
    def exitAboutToBiteLure(self):
        self.lfChaseLureSequence.pause()
        self.lfChaseLureSequence.clearToInitial()

    
    def checkForBite(self):
        pass

    
    def enterHooked(self):
        self.fish.fishMoveSequence.pause()
        self.fish.actor.changeAnimationTo('reelIdle')

    
    def exitHooked(self):
        taskName = '%s_StartFighting' % self.fish.getName()
        taskMgr.remove(self.fish.fishManager.gameObject.distributedFishingSpot.uniqueName(taskName))
        self.fish.lfStruggleSequence.pause()
        self.fish.lfStruggleSequence.clearToInitial()

    
    def enterHookedFighting(self):
        self.fish.actor.changeAnimationTo('fightIdle')

    
    def exitHookedFighting(self):
        pass

    
    def enterPullingLure(self):
        self.fish.actor.changeAnimationTo('fightIdle')

    
    def exitPullingLure(self):
        self.fish.setY(0.0)

    
    def enterFinalBackToSea(self):
        self.fish.setPosHpr(self.fish.myData['goodbyePosHpr'][0], self.fish.myData['goodbyePosHpr'][1])
        self.fish.actor.changeAnimationTo('swimIdle')
        self.farewellInterval = LerpPosInterval(self.fish, FishingGlobals.waveToLegendaryFishDuration, pos = self.fish.myData['swimmingDistance'], startPos = self.fish.getPos(), name = '%s_farewellInterval' % self.fish.getName())
        self.farewellInterval.start()

    
    def exitFinalBackToSea(self):
        self.farewellInterval.pause()
        self.farewellInterval.clearToInitial()
 def __init__(self, gameObject = None):
     base.loadingScreen.beginStep('LegendaryGameGUI', 4, 20)
     self.gameObject = gameObject
     self.guiImage = loader.loadModel('models/minigames/pir_m_gam_fsh_legendaryGui')
     self.UICompoments = { }
     self.uiBaseNode = NodePath('baseNode')
     self.uiBaseNode.reparentTo(aspect2d)
     self.uiBaseNode.show()
     self.leftBaseNode = NodePath('leftBaseNode')
     self.leftBaseNode.reparentTo(base.a2dLeftCenter)
     self.leftBaseNode.show()
     self.fishActor = None
     self.actorAnim = { }
     self.scaleSize = {
         InventoryType.Collection_Set11_Part1: 0.059999999999999998,
         InventoryType.Collection_Set11_Part2: 0.055,
         InventoryType.Collection_Set11_Part3: 0.12,
         InventoryType.Collection_Set11_Part4: 0.086999999999999994,
         InventoryType.Collection_Set11_Part5: 0.080000000000000002 }
     self.meterFrame = DirectFrame(parent = self.leftBaseNode, frameSize = (-0.29999999999999999, 0.29999999999999999, -1.0, 0.0), frameColor = (1.0, 1.0, 1.0, 0.0), relief = None, state = DGG.DISABLED, pos = (1.0, 0.0, -0.45000000000000001), hpr = (0, 0, 0), scale = (1.3, 0.0, 1.3), image = self.guiImage.find('**/pir_t_gui_fsh_meter'), image_scale = (0.20000000000000001, 0.0, 0.80000000000000004), image_pos = (0, 0, 0), text = '', textMayChange = 1, text_scale = PiratesGuiGlobals.TextScaleTitleLarge, text_pos = (-0.55000000000000004, 0.10000000000000001), text_shadow = PiratesGuiGlobals.TextShadow)
     self.UICompoments['meterFrame'] = self.meterFrame
     self.fishingRod = DirectFrame(parent = self.meterFrame, frameSize = (-0.29999999999999999, 0.29999999999999999, -1.0, 0.0), relief = None, state = DGG.DISABLED, pos = FishingGlobals.fishingRodScreenPosition, image = self.guiImage.find('**/pir_t_gui_fsh_fullRod'), image_scale = (1.0, 0.0, 0.125), image_pos = (0.20000000000000001, 0, 0))
     self.fishingRod.setR(FishingGlobals.fishingRodInitSlope)
     self.UICompoments['fishingRod'] = self.fishingRod
     base.loadingScreen.tick()
     self.fishingHandleBaseFrame = DirectFrame(parent = self.uiBaseNode, frameSize = (-0.29999999999999999, 0.29999999999999999, -1.5, 1.5), frameColor = (1.0, 1.0, 1.0, 0.0), relief = None, state = DGG.DISABLED, pos = (0.0, 0.0, 0.0), hpr = (0, 0, 0), scale = (0.71999999999999997, 0.0, 0.71999999999999997), image = self.guiImage.find('**/pir_t_gui_fsh_partialRod'), image_scale = (3.7999999999999998, 0.0, 1.8999999999999999), image_pos = (0, 0, 0), image_hpr = (0.0, 0.0, 0))
     self.fishingHandleBaseFrame.hide()
     self.UICompoments['fishingHandleBaseFrame'] = self.fishingHandleBaseFrame
     self.fishingHandle = DirectFrame(parent = self.fishingHandleBaseFrame, frameSize = (-0.080000000000000002, 0.080000000000000002, -0.20000000000000001, 0.20000000000000001), relief = None, state = DGG.DISABLED, pos = (-0.10000000000000001, 0.0, -0.050000000000000003), hpr = (0, 0, 0), image = self.guiImage.find('**/pir_t_gui_fsh_handleArm'), image_scale = (1.0, 0.0, 1.0), image_pos = (-0.042000000000000003, 0, -0.115), image_hpr = (0.0, 0.0, 0))
     self.UICompoments['fishingHandle'] = self.fishingHandle
     self.arrowImage = DirectFrame(parent = self.fishingHandleBaseFrame, frameSize = (-0.40000000000000002, 0.40000000000000002, -0.40000000000000002, 0.40000000000000002), relief = None, state = DGG.DISABLED, pos = (0.0, 0.0, 0.0), hpr = (0, 0, 0), scale = (1.2, 0.0, 1.2), image = self.guiImage.find('**/pir_t_gui_fsh_arrow'), image_scale = (1.0, 0.0, 1.0), image_pos = (0.0, 0, 0.0), image_hpr = (0.0, 0.0, 0.0))
     self.arrowImage.hide()
     self.UICompoments['arrowImage'] = self.arrowImage
     btnGeom = (self.guiImage.find('**/pir_t_gui_fsh_handle'), self.guiImage.find('**/pir_t_gui_fsh_handle'), self.guiImage.find('**/pir_t_gui_fsh_handleOn'))
     self.fishingHandleButton = GuiButton(pos = (-0.29999999999999999, 0, -0.55000000000000004), hpr = (0, 0, 0), scale = 0.45000000000000001, image = btnGeom, image_pos = (0, 0, 0), image_scale = 1.0, sortOrder = 2)
     self.fishingHandleButton.bind(DGG.B1PRESS, self.handleButtonClicked)
     self.fishingHandleButton.reparentTo(self.fishingHandle)
     self.UICompoments['fishingHandleButton'] = self.fishingHandleButton
     self.fishingHandleBaseFrame.setTransparency(TransparencyAttrib.MAlpha)
     self.meterFrame.setTransparency(TransparencyAttrib.MAlpha)
     self.lineOneTransitTextNode = TextNode('lineOneTransitText')
     self.lineOneTransitTextNode.setFont(PiratesGlobals.getPirateFont())
     self.lineOneTransitTextNode.setText('')
     self.lineOneTransitTextNode.setAlign(TextNode.ACenter)
     self.lineOneTransitTextNode.setTextColor(1.0, 1.0, 1.0, 0.5)
     self.lineOneTransitTextNodePath = NodePath(self.lineOneTransitTextNode)
     self.lineOneTransitTextNodePath.setPos(0.0, 0.0, -0.80000000000000004)
     self.lineOneTransitTextNodePath.setScale(0.34999999999999998, 0.34999999999999998, 0.34999999999999998)
     self.lineOneTransitTextNodePath.reparentTo(self.uiBaseNode)
     self.lineOneTransitTextNodePath.hide()
     self.UICompoments['lineOneTransitText'] = self.lineOneTransitTextNodePath
     self.lineTwoTransitTextNode = TextNode('lineTwoTransitText')
     self.lineTwoTransitTextNode.setFont(PiratesGlobals.getPirateFont())
     self.lineTwoTransitTextNode.setText('')
     self.lineTwoTransitTextNode.setAlign(TextNode.ACenter)
     self.lineTwoTransitTextNode.setTextColor(1.0, 1.0, 1.0, 0.5)
     self.lineTwoTransitTextNodePath = NodePath(self.lineTwoTransitTextNode)
     self.lineTwoTransitTextNodePath.setPos(-0.40000000000000002, 0.0, -0.94999999999999996)
     self.lineTwoTransitTextNodePath.setScale(0.12, 0.12, 0.12)
     self.lineTwoTransitTextNodePath.reparentTo(self.uiBaseNode)
     self.lineTwoTransitTextNodePath.hide()
     self.UICompoments['lineTwoTransitText'] = self.lineTwoTransitTextNodePath
     base.loadingScreen.tick()
     self.test_guiImage = loader.loadModel('models/gui/toplevel_gui')
     self.buttonIcon = (self.test_guiImage.find('**/treasure_chest_closed'), self.test_guiImage.find('**/treasure_chest_closed'), self.test_guiImage.find('**/treasure_chest_closed_over'))
     self.winImagePanel = GuiPanel.GuiPanel('', 2.6000000000000001, 1.8999999999999999, True)
     self.winImagePanel.setPos(-1.3, 0.0, -0.94999999999999996)
     self.winImagePanel.reparentTo(self.uiBaseNode)
     self.winImagePanel.background = OnscreenImage(parent = self.winImagePanel, scale = (2.3999999999999999, 0, 1.8), image = self.guiImage.find('**/pir_t_gui_fsh_posterBackground'), hpr = (0, 0, 0), pos = (1.3, 0, 0.94999999999999996))
     self.winImagePanel.setBin('gui-popup', -4)
     self.winTitleTextNode = TextNode('winTitleTextNode')
     self.winTitleTextNode.setText('Congratulations!')
     self.winTitleTextNode.setAlign(TextNode.ACenter)
     self.winTitleTextNode.setFont(PiratesGlobals.getPirateFont())
     self.winTitleTextNode.setTextColor(0.23000000000000001, 0.089999999999999997, 0.029999999999999999, 1.0)
     self.winTitleTextNodePath = NodePath(self.winTitleTextNode)
     self.winTitleTextNodePath.setPos(1.3500000000000001, 0.0, 1.6699999999999999)
     self.winTitleTextNodePath.setScale(0.17999999999999999)
     self.winTitleTextNodePath.reparentTo(self.winImagePanel)
     self.wholeStoryTextNode = TextNode('storyTextNode')
     self.wholeStoryTextNode.setText('')
     self.wholeStoryTextNode.setWordwrap(19.0)
     self.wholeStoryTextNode.setTextColor(0.23000000000000001, 0.089999999999999997, 0.029999999999999999, 1.0)
     self.wholeStoryTextNodePath = NodePath(self.wholeStoryTextNode)
     self.wholeStoryTextNodePath.setPos(0.33000000000000002, 0.0, 1.6399999999999999)
     self.wholeStoryTextNodePath.setScale(0.050000000000000003)
     self.wholeStoryTextNodePath.reparentTo(self.winImagePanel)
     self.winImagePanel.closeButton['command'] = self.closeDialogGotNextState
     self.winImagePanel.closeButton['extraArgs'] = [
         'winImagePanel',
         'FarewellLegendaryFish',
         False]
     self.UICompoments['winImagePanel'] = self.winImagePanel
     self.winImagePanel.hide()
     self.luiCloseDialogSequence = Sequence()
     self.arrowImageRotationInterval = LerpHprInterval(self.arrowImage, 2.2000000000000002, self.arrowImage.getHpr() + Point3(0.0, 0.0, 280.0), self.arrowImage.getHpr())
     self.luiArrowRotatingSequence = Sequence(Func(self.showGui, [
         'arrowImage']), Parallel(Func(self.arrowImageRotationInterval.start), Wait(2.2000000000000002)), Func(self.hideGui, [
         'arrowImage']), Func(self.arrowImage.setHpr, self.arrowImage.getHpr() + Point3(0.0, 0.0, 5.0)), name = self.gameObject.distributedFishingSpot.uniqueName('luiArrowRotatingSequence'))
     self.lineOneColorChange = LerpColorScaleInterval(self.lineOneTransitTextNodePath, FishingGlobals.legendaryTransitionTextDuration, (1.0, 1.0, 1.0, 0.0), (1.0, 1.0, 1.0, 1.0), blendType = 'easeOut')
     self.lineOnePosChange = LerpPosInterval(self.lineOneTransitTextNodePath, FishingGlobals.legendaryTransitionTextDuration, (0.0, 0.0, -0.20000000000000001), (0.0, 0.0, -0.80000000000000004), blendType = 'easeOut')
     self.lineTwoCholorChange = LerpColorScaleInterval(self.lineTwoTransitTextNodePath, FishingGlobals.legendaryTransitionTextDuration, (1.0, 1.0, 1.0, 1.0), (1.0, 1.0, 1.0, 1.0), blendType = 'easeOut')
     self.lineTwoPosChange = LerpPosInterval(self.lineTwoTransitTextNodePath, FishingGlobals.legendaryTransitionTextDuration, (0.0, 0.0, -0.32000000000000001), (0.0, 0.0, -0.94999999999999996), blendType = 'easeOut')
     self.transitionTextMovingSequence = Sequence(Func(self.lineOneTransitTextNodePath.show), Func(self.lineTwoTransitTextNodePath.show), Parallel(self.lineOnePosChange, self.lineTwoPosChange, self.lineOneColorChange, self.lineTwoCholorChange), Func(self.lineOneTransitTextNodePath.hide), Func(self.lineTwoTransitTextNodePath.hide), name = self.gameObject.distributedFishingSpot.uniqueName('transitionTextMovingSequence'))
     self.meterFadeInInterval = Sequence(Func(self.meterFrame.show), LerpColorScaleInterval(self.meterFrame, FishingGlobals.legendaryTransitionTextDuration, colorScale = (1.0, 1.0, 1.0, 1.0), startColorScale = (1.0, 1.0, 1.0, 0.0), blendType = 'easeOut'), name = 'FadeInLegendaryMeter')
     self.meterFadeOutInterval = Sequence(LerpColorScaleInterval(self.meterFrame, FishingGlobals.legendaryTransitionTextDuration, colorScale = (1.0, 1.0, 1.0, 0.0), startColorScale = (1.0, 1.0, 1.0, 1.0), blendType = 'easeOut'), Func(self.meterFrame.hide), name = 'FadeOutLegendaryMeter')
     self.rodFadeInInterval = Sequence(Func(self.fishingHandleBaseFrame.show), LerpColorScaleInterval(self.fishingHandleBaseFrame, FishingGlobals.legendaryTransitionTextDuration, colorScale = (1.0, 1.0, 1.0, 1.0), startColorScale = (1.0, 1.0, 1.0, 0.0), blendType = 'easeOut'), name = 'FadeInLegendaryRodInterface')
     self.rodFadeOutInterval = Sequence(LerpColorScaleInterval(self.fishingHandleBaseFrame, FishingGlobals.legendaryTransitionTextDuration, colorScale = (1.0, 1.0, 1.0, 0.0), startColorScale = (1.0, 1.0, 1.0, 1.0), blendType = 'easeOut'), Func(self.fishingHandleBaseFrame.hide), name = 'FadeOutLegendaryRodInterface')
     base.loadingScreen.tick()
     smallScale = self.fishingHandleButton['scale']
     bigScale = self.fishingHandleButton['scale'] * 1.2
     self.buttonGrowUpInterval = LerpScaleInterval(self.fishingHandleButton, 1.0, bigScale, smallScale)
     self.luiFightTransitSequence = Sequence(Parallel(Func(self.fishingHandleBaseFrame.show), Func(self.meterFadeOutInterval.start), Func(self.rodFadeInInterval.start), Func(self.buttonGrowUpInterval.start)), Wait(1.0), Func(self.meterFrame.hide), name = self.gameObject.distributedFishingSpot.uniqueName('luiFightTransitSequence'))
     self.luiReelTransitSequence = Sequence(Parallel(Func(self.fishingHandleBaseFrame.show), Func(self.meterFadeOutInterval.start), Func(self.rodFadeInInterval.start)), Wait(1.0), Func(self.meterFrame.hide), name = self.gameObject.distributedFishingSpot.uniqueName('luiReelTransitSequence'))
     self.luiStruggleTransitSequence = Sequence(Parallel(Func(self.meterFrame.show), Func(self.resetFishingRod), self.meterFadeInInterval, self.rodFadeOutInterval), Wait(1.0), Func(self.fishingHandleBaseFrame.hide), name = self.gameObject.distributedFishingSpot.uniqueName('luiStruggleTransitSequence'))
     self.meterFadeOutInterval.start()
     self.rodFadeOutInterval.start()
     self.hideAllGUI()
     base.loadingScreen.endStep('LegendaryGameGUI')
Esempio n. 44
0
class World(DirectObject):
	
	def cameraControl(self, task):
		if(self.keyMap["firstPerson"]==0 and self.keyMap["ThirdPerson"]!=0):
			return task.cont
		dt = globalClock.getDt()
		if(dt > .20):
		   return task.cont
		    
		if(base.mouseWatcherNode.hasMouse() == 1):
		   mpos = base.mouseWatcherNode.getMouse()
		   base.camera.setP(mpos.getY() * 30)
		   base.camera.setH(mpos.getX() * -50)
		   if (mpos.getX() < 0.1 and mpos.getX() > -0.1 ):
		      self.sonic.setH(self.sonic.getH())
		   else:
		      self.sonic.setH(self.sonic.getH() + mpos.getX() * -1)
		   
		if(self.keyMap["w"] == 1):
		   self.sonic.setY(self.sonic, 15 * dt)
		   print("camera moving forward")
		   return task.cont
		elif(self.keyMap["s"] == 1):
		   self.sonic.setY(self.sonic, -15 * dt)
		   print("camera moving backwards")
		   return task.cont
		elif(self.keyMap["a"] == 1):
		   self.sonic.setX(self.sonic, -10 * dt)
		   print("camera moving left")
		   return task.cont
		elif(self.keyMap["d"] == 1):
		   self.sonic.setX(self.sonic, 10 * dt)
		   print("camera moving right")
		   return task.cont
		else:
		   return task.cont

	def __init__(self):
		self.keyMap = {"left":0, "right":0, "forward":0,"backward":0, "cam-left":0, "cam-right":0,"res":0,
		"w" : 0, "s" : 0, "a" : 0, "d" : 0,"firstPerson":0,"ThirdPerson":1,"l":0}
		base.win.setClearColor(Vec4(0,0,0,1))
		wp = WindowProperties()
		wp.setFullscreen(1)
		wp.setSize(1024,768)
		base.openMainWindow()
		base.win.requestProperties(wp)
		base.graphicsEngine.openWindows()
		#Post the instructions
		
		#Intro Starts
		tex = MovieTexture("name")
		assert tex.read("models/play/entrance.avi"), "Failed to load video!"
		cm = CardMaker("My Fullscreen Card");
		cm.setFrameFullscreenQuad()
		cm.setUvRange(tex)
		card = NodePath(cm.generate())
		card.reparentTo(render2d)
		card.setTexture(tex)
		card.setTexScale(TextureStage.getDefault(), tex.getTexScale())
		sound=loader.loadSfx("models/play/entrance.avi")
		tex.synchronizeTo(sound)
		tex.setLoop(False)
		sound.play()
		def myTask(task):
			if (int(tex.getTime()) >=14):
				print "Stoping"
				card.remove()
				return task.done
			return task.cont
		taskMgr.add(myTask, "Task")
		
		mytimer = DirectLabel()
		mytimer.reparentTo(render)
		#mytimer.setY(0)
		textObject = OnscreenText(text = "", pos = (0.95,-0.95), 
scale = 0.07,fg=(1,0.5,0.5,1),align=TextNode.ACenter,mayChange=1)

		def dCharstr(theString):
			if len(theString) != 2:
				theString = '0' + theString
				return theString
	    
		


		def timerTask(task):
			secondsTime = int(task.time)
			minutesTime = int(secondsTime/60)
			hoursTime = int(minutesTime/60)
			mytimer['text'] = "%02d:%02d:%02d" % (hoursTime, minutesTime%60, secondsTime%60)
			#print mytimer['text']
			textObject.setText(mytimer['text'])
			return task.cont

		taskMgr.add(timerTask, 'timerTask')
		mytimer.reparentTo(render)
		
		self.inst1 = addInstructions(0.95, "[ESC]: Quit")
		self.inst2 = addInstructions(0.90, "[L]: Map View")
		self.inst3 = addInstructions(0.85, "Movement: Arrow Keys")
		self.inst2 = addInstructions(0.80, "[R]: Reset Position")

		self.road = loader.loadModel("models/floor")
		
		emin,emax =self.road.getTightBounds()
		env = []
		esize=20
		for en in range(0,esize):
			for j in range(0,esize):
				#if (j%2==0):
				#print j+(en*9),"Here"
				env.append(self.road)
				env[j+(en*9)].copyTo(render)
				env[j+(en*9)].setPos(emin.x*(en-esize/2),emax.y*(j-esize/2),0)
		
		self.BuildingRow = [loader.loadModel("models/BuildingCluster1col"),
					loader.loadModel("models/BuildingCluster2col"),
					loader.loadModel("models/BuildingCluster3col"),
					loader.loadModel("models/BuildingCluster4col")]

		e0,e1=env[0].getTightBounds()
		mapsize=e0.x*len(env)
		self.vehicle_carsx=loader.loadModel("models/vehicles/carnsxcol")
		self.sign=Actor("models/squarrow-model",{
                        "play":"models/squarrow-anim"})
		self.sign1=Actor("models/squarrow-model",{
                        "play":"models/squarrow-anim"})
		self.vehicle_ford=loader.loadModel("models/vehicles/fordcol")
		self.vehicle_girlcar=loader.loadModel("models/vehicles/girlcarcol")
		self.vehicle_policecar=loader.loadModel("models/vehicles/policecarcol")
		self.vehicle_fireengine=loader.loadModel("models/vehicles/fireenginecol")
		self.vehicle_carsx.reparentTo(render)
		self.sign.reparentTo(render)
		self.sign1.reparentTo(render)
		self.vehicle_carsx.setPos(-35,295,0)
		self.vehicle_carsx.setScale(5)
		self.vehicle_ford.reparentTo(render)
		self.vehicle_ford.setPos(52,270,0)
		self.vehicle_ford.setScale(3)
		self.vehicle_girlcar.reparentTo(render)
		self.vehicle_girlcar.setPos(200,20,0)
		self.vehicle_girlcar.setScale(5)
		self.vehicle_girlcar.setH(-90)
		self.vehicle_policecar.reparentTo(render)
		self.vehicle_policecar.setPos(-33,295,0)
		self.vehicle_policecar.setScale(3)
		self.vehicle_fireengine.reparentTo(render)
		self.vehicle_fireengine.setPos(-60,-294,0)
		self.vehicle_fireengine.setH(90)
		self.vehicle_fireengine.setScale(3)
		self.sign1.setPos(-129,-44,150)
		self.sign.setPos(89,172.6,150)
                self.sign1.setHpr(-90,0,60)
                self.sign.setHpr(-90,0,60)
		self.sign1.loop("play")
		self.sign.loop("play")
		self.vehicle_carsxinterval=LerpPosInterval(self.vehicle_carsx, 10,Vec3(-33,-325,0) ,Vec3(52,295,0))
		self.vehicle_carsxinterval.loop()
		self.vehicle_fordinterval=LerpPosInterval(self.vehicle_ford, 10,Vec3(52,-325,0) ,Vec3(52,270,0))
		self.vehicle_fordinterval.loop()
		self.vehicle_policecarinterval=LerpPosInterval(self.vehicle_policecar, 10,Vec3(-33,295,0) ,Vec3(-33,-325,0))
		self.vehicle_policecarinterval.loop()
		self.vehicle_fireengineinterval=LerpPosInterval(self.vehicle_fireengine, 10,Vec3(52,270,0) ,Vec3(52,-350,0))
		self.vehicle_girlcar=LerpPosInterval(self.vehicle_girlcar,10,Vec3(-54,33,6),Vec3(-258,33,6))
		self.vehicle_girlcar.loop()
		
		for j in self.BuildingRow:
			j.setPos(e0.x,e1.y,0)
		
		building=[]
		for j in range(0,8):
			building.append(self.BuildingRow)
			offset=0
			c=env[0].getX()
			x=e0.x
			y=e1.y+(emin.x*4*j);
			for i in building[j]:
				x=x-emin.x
				i.copyTo(render)
				min,max =i.getTightBounds()
				width=max-min
				i.setPos(x,y,0)
				x=x-emin.x
				i.copyTo(render)
				i.setPos(-x+50,y,0)
		
							
		# Create the main character, Ralph
		sonicStartPos = (0,0,-2)
		self.sonic = Actor("models/people/sonic/sonic",{
			"board":"models/people/sonic/sonic-board",
			"fallingwboard":"models/people/sonic/sonic-fallingwboard",
			"fallingwoboard":"models/people/sonic/sonic-fallingwoboard",
			"run":"models/people/sonic/sonic-run",
			"win":"models/people/sonic/sonic-win",
			})
		self.sonic.reparentTo(render)
		self.sonic.setScale(.5)
		self.sonic.setPos(sonicStartPos)
		
		# Create a floater object.  We use the "floater" as a temporary
		# variable in a variety of calculations.
		
		self.floater = NodePath(PandaNode("floater"))
		self.floater.reparentTo(render)

		# Accept the control keys for movement and rotation

		self.accept("escape", sys.exit)
		self.accept("arrow_left", self.setKey, ["left",1])
		self.accept("arrow_right", self.setKey, ["right",1])
		self.accept("arrow_up", self.setKey, ["forward",1])
		self.accept("arrow_down", self.setKey, ["backward",1])
		self.accept("arrow_left-up", self.setKey, ["left",0])
		self.accept("arrow_right-up", self.setKey, ["right",0])
		self.accept("arrow_up-up", self.setKey, ["forward",0])
		self.accept("arrow_down-up", self.setKey, ["backward",0])

		self.accept("z", self.setKey, ["cam-left",1])
		self.accept("x", self.setKey, ["cam-right",1])
		self.accept("z-up", self.setKey, ["cam-left",0])
		self.accept("x-up", self.setKey, ["cam-right",0])
		self.accept("l", self.setKey, ["l", 1])
		self.accept("l-up", self.setKey, ["l", 0])
		self.accept("w", self.setKey, ["w", 1])
		self.accept("s", self.setKey, ["s", 1])   
		self.accept("a", self.setKey, ["a", 1])   
		self.accept("d", self.setKey, ["d", 1])
		self.accept("r", self.setKey, ["res", 1])
		self.accept("w-up", self.setKey, ["w", 0])
		self.accept("s-up", self.setKey, ["s", 0])
		self.accept("a-up", self.setKey, ["a", 0])
		self.accept("d-up", self.setKey, ["d", 0])

		self.accept("j", self.setKey, ["firstPerson",1])
		self.accept("j", self.setKey, ["ThirdPerson",0])
		self.accept("k", self.setKey, ["firstPerson",0])
		self.accept("k", self.setKey, ["ThirdPerson",1])
		
		

		# taskMgr.add(self.cameraControl, "Camera Control")
		taskMgr.add(self.move,"moveTask")

		# Game state variables
		self.isMoving = False

		# Set up the camera
		
		#base.disableMouse()
		base.camera.setPos(self.sonic.getX(),self.sonic.getY()-10,40)
		# base.camera.setH(-90)
		self.cTrav = CollisionTraverser()

		self.sonicGroundRay = CollisionRay()
		self.sonicGroundRay.setOrigin(0,0,1000)
		self.sonicGroundRay.setDirection(0,0,-1)
		self.sonicGroundCol = CollisionNode('sonicRay')
		self.sonicGroundCol.addSolid(self.sonicGroundRay)
		self.sonicGroundCol.setFromCollideMask(BitMask32.bit(0))
		self.sonicGroundCol.setIntoCollideMask(BitMask32.allOff())
		self.sonicGroundColNp = self.sonic.attachNewNode(self.sonicGroundCol)
		self.sonicGroundHandler = CollisionHandlerQueue()
		self.cTrav.addCollider(self.sonicGroundColNp, self.sonicGroundHandler)

		# Uncomment this line to see the collision rays
		#self.sonicGroundColNp.show()
		#self.camGroundColNp.show()
	   
		# Uncomment this line to show a visual representation of the 
		# collisions occuring
		#self.cTrav.showCollisions(render)
		
		# Create some lighting
		ambientLight = AmbientLight("ambientLight")
		ambientLight.setColor(Vec4(.3, .3, .3, 1))
		directionalLight = DirectionalLight("dlight")
		directionalLight.setDirection(Vec3(0,-5, -5))
		directionalLight.setColor(Vec4(1, 1, 1, 1))
		#directionalLight.setHpr(0, -60, 0)
		directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
		ml=render.attachNewNode(directionalLight)
		#self.mylight= render.attachNewNode("dl")
		inter=Func(light,directionalLight)
		#directionalLight.reparentTo(self.mylight)
		#print dir(inter)
		inter.start()
		inter.loop()
		render.setLight(render.attachNewNode(ambientLight))
		render.setLight(ml)

		
	#Records the state of the arrow keys
	def setKey(self, key, value):
		self.keyMap[key] = value
	
	# Accepts arrow keys to move either the player or the menu cursor,
	# Also deals with grid checking and collision detection
	def move(self, task):

		# If the camera-left key is pressed, move camera left.
		# If the camera-right key is pressed, move camera right.

		base.camera.lookAt(self.sonic)
		if (self.keyMap["cam-left"]!=0):
			print "z"
			base.camera.setX(base.camera, -20 * globalClock.getDt())
		if (self.keyMap["cam-right"]!=0):
			print "x"
			base.camera.setX(base.camera, +20 * globalClock.getDt())

		if (self.keyMap["res"]==1):
			self.sonic.setPos(0,0,-2)
			self.keyMap["res"]=0


		startpos = self.sonic.getPos()

		if (self.keyMap["left"]!=0):
			self.sonic.setH(self.sonic.getH() + 300 * globalClock.getDt())
		if (self.keyMap["right"]!=0):
			self.sonic.setH(self.sonic.getH() - 300 * globalClock.getDt())
		if (self.keyMap["forward"]!=0):
			self.sonic.setY(self.sonic, -50 * globalClock.getDt())
		if (self.keyMap["backward"]!=0):
			self.sonic.setY(self.sonic, +50 * globalClock.getDt())

		if (self.keyMap["forward"]!=0) and (self.keyMap["backward"]==0):
			if self.isMoving is False:
				self.sonic.loop("board")
				self.isMoving = True

		elif (self.keyMap["backward"]!=0) and (self.keyMap["forward"]==0):
			if self.isMoving is False:
				self.sonic.loop("board")
				self.isMoving = True
				
		elif (self.keyMap["backward"]==0) and (self.keyMap["forward"]==0):
			if self.isMoving:
				self.sonic.stop()
				self.sonic.pose("run",5)
				print self.sonic.getX(),self.sonic.getY(),self.sonic.getZ()
				self.isMoving = False
		

		# If the camera is too far from ralph, move it closer.
		# If the camera is too close to ralph, move it farther.

		camvec = self.sonic.getPos() - base.camera.getPos()
		camvec.setZ(15)
		camdist = camvec.length()
		camvec.normalize()
		if (camdist > 10.0):
			base.camera.setPos(base.camera.getPos() + camvec*(camdist-10))
			camdist = 10.0
		if (camdist < 5.0):
			base.camera.setPos(base.camera.getPos() - camvec*(5-camdist))
			camdist = 5.0

		# Now check for collisions.

		self.cTrav.traverse(render)

		entries = []
		for i in range(self.sonicGroundHandler.getNumEntries()):
			entry = self.sonicGroundHandler.getEntry(i)
			entries.append(entry)
		entries.sort(lambda x,y: cmp(y.getSurfacePoint(render).getZ(),
									 x.getSurfacePoint(render).getZ()))
		if (len(entries)>0) and (entries[0].getIntoNode().getName() == "BuildingCluster1"):
			self.sonic.setPos(startpos)
			self.isMoving = False
		elif (len(entries)>0) and (entries[0].getIntoNode().getName() == "BuildingCluster2"):
			self.sonic.setPos(startpos)
			self.isMoving = False
		elif (len(entries)>0) and (entries[0].getIntoNode().getName() == "BuildingCluster4"):
			self.sonic.setPos(startpos)
			self.isMoving = False
		elif (len(entries)>0) and (entries[0].getIntoNode().getName() == "BuildingCluster5"):
			self.sonic.setPos(startpos)
			self.isMoving = False
		elif (len(entries)>0):
			print entries[0].getIntoNode().getName(),self.sonic.getPos()
			if(entries[0].getIntoNode().getName()=="parked_car" or entries[0].getIntoNode().getName()=="body"):
				self.sonic.setY(self.sonic.getY()-50)
				self.sonic.setX(self.sonic.getX()-5)
			elif(entries[0].getIntoNode().getName()=="PoliceCar"):
				self.sonic.setY(self.sonic.getY()+50)
				self.sonic.setX(self.sonic.getX()-5)
			elif(entries[0].getIntoNode().getName()=="girlRacer"):
				self.sonic.setX(self.sonic.getX()+50)
				self.sonic.setY(self.sonic.getY()+5)
			elif(entries[0].getIntoNode().getName()=="building1"):
				if(abs(abs(self.sonic.getX())-130)<10 and abs(abs(self.sonic.getY())-44)<10):
					print "Pizza Delivery"
					#Intro Starts
					tex = MovieTexture("name")
					assert tex.read("models/play/happy.mp4"), "Failed to load video!"
					cm = CardMaker("My Fullscreen Card");
					cm.setFrameFullscreenQuad()
					cm.setUvRange(tex)
					card = NodePath(cm.generate())
					card.reparentTo(render2d)
					card.setTexture(tex)
					card.setTexScale(TextureStage.getDefault(), tex.getTexScale())
					sound=loader.loadSfx("models/play/happy.mp4")
					tex.synchronizeTo(sound)
					tex.setLoop(False)
					sound.play()
					def myTask(task):
						if (int(tex.getTime()) >=20):
					 		print "Stoping"
							c=0
					 		card.remove()
					 		self.sonic.setPos(0,0,-2)
							self.keyMap["res"]=0
							myscore = DirectLabel()
							myscore.reparentTo(render)
							#mytimer.setY(0)
							textObj = OnscreenText(text = "", pos = (0.95,0.95), 
							scale = 0.07,fg=(1,0.5,0.5,1),align=TextNode.ACenter,mayChange=1)
							c=c+1
							myscore['text'] = "Score:"+"1"
							#print mytimer['text']
							textObj.setText(myscore['text'])
							return task.done
							#if myMovieTexture.getTime() == myMovieLength:
							#	print "movie puri"
					 	return task.cont
					taskMgr.add(myTask, "Task")
					

				elif(abs(abs(self.sonic.getX())-88)<10 and abs(abs(self.sonic.getY())-172)<10):
					print "Pizza Delivery"
					#Intro Starts
					tex = MovieTexture("name")
					assert tex.read("models/play/angry.mp4"), "Failed to load video!"
					cm = CardMaker("My Fullscreen Card");
					cm.setFrameFullscreenQuad()
					cm.setUvRange(tex)
					card = NodePath(cm.generate())
					card.reparentTo(render2d)
					card.setTexture(tex)
					card.setTexScale(TextureStage.getDefault(), tex.getTexScale())
					sound=loader.loadSfx("models/play/angry.mp4")
					tex.synchronizeTo(sound)
					tex.setLoop(False)
					sound.play()
					def myTask(task):
					 	if (int(tex.getTime()) >=20):
					 		print "Stoping"
							c=0
					 		card.remove()
					 		self.sonic.setPos(0,0,-2)
							self.keyMap["res"]=0
							myscore = DirectLabel()
							myscore.reparentTo(render)
							#mytimer.setY(0)
							textObj = OnscreenText(text = "", pos = (0.95,0.95), 
							scale = 0.07,fg=(1,0.5,0.5,1),align=TextNode.ACenter,mayChange=1)
							c=c+1
							myscore['text'] = "Score:"+"2"
							#print mytimer['text']
							textObj.setText(myscore['text'])
							return task.done
							#if myMovieTexture.getTime() == myMovieLength:
							#	print "movie puri"
					 	return task.cont
					taskMgr.add(myTask, "Task")

			#self.sonic.setPos(startpos)

		# Keep the camera at one foot above the terrain,
		# or two feet above ralph, whichever is greater.
		
		'''entries = []
		for i in range(self.camGroundHandler.getNumEntries()):
				entry = self.camGroundHandler.getEntry(i)
				entries.append(entry)
		entries.sort(lambda x,y: cmp(y.getSurfacePoint(render).getZ(),
																 x.getSurfacePoint(render).getZ()))
		if (len(entries)>0) and (entries[0].getIntoNode().getName() == "BuildingCluster1"):
				base.camera.setZ(entries[0].getSurfacePoint(render).getZ()+1.0)
		if (base.camera.getZ() < self.sonic.getZ() + 2.0):
				base.camera.setZ(self.sonic.getZ() + 2.0)'''

		# The camera should look in ralph's direction,
		# but it should also try to stay horizontal, so look at
		# a floater which hovers above ralph's head.
		
		base.camera.setPos(self.sonic.getPos())
		base.camera.setY(self.sonic.getY()+50*cos(self.sonic.getH()*pi/180))
		base.camera.setX(self.sonic.getX()-50*sin(self.sonic.getH()*pi/180))
		base.camera.setZ(self.sonic.getZ() + 15.0)
		if(self.keyMap["l"]==1):
			base.camera.setZ(self.sonic.getZ() + 1000.0)	
		sa =self.sonic.getPos();
		base.camera.lookAt(sa.x,sa.y,sa.z+15)
		

		# self.floater.setPos(self.sonic.getX()-4, self.floater.getY()-4, 5)
		# base.camera.setY(-base.camera.getY())
		# self.floater.setX(self.sonic.getX()-10)
		# base.camera.reparentTo(self.sonic)
		# self.floater.setH(180)
		# base.camera.setZ(+50)
		# base.camera.lookAt(self.floater)

		return task.cont
 def enterFinalBackToSea(self):
     self.fish.setPosHpr(self.fish.myData['goodbyePosHpr'][0], self.fish.myData['goodbyePosHpr'][1])
     self.fish.actor.changeAnimationTo('swimIdle')
     self.farewellInterval = LerpPosInterval(self.fish, FishingGlobals.waveToLegendaryFishDuration, pos = self.fish.myData['swimmingDistance'], startPos = self.fish.getPos(), name = '%s_farewellInterval' % self.fish.getName())
     self.farewellInterval.start()