コード例 #1
0
    def walkInPlace(self, avatar, lane, place, time):
        place = min(place, len(self.posHprArray[lane]) - 1)
        posH = self.posHprArray[lane][place]

        def startWalk(task):
            task.avatar.setAnimState('walk', 1)
            return Task.done

        startWalkTask = Task(startWalk, 'startWalk-' + str(lane))
        startWalkTask.avatar = avatar

        def stopWalk(task, raceBoard=self.raceBoard, posH=posH):
            task.avatar.setAnimState('neutral', 1)
            if raceBoard.isEmpty():
                task.avatar.setPosHpr(0, 0, 0, 0, 0, 0)
            else:
                task.avatar.setPosHpr(raceBoard, posH[0], posH[1], posH[2],
                                      posH[3], 0, 0)
            return Task.done

        stopWalkTask = Task(stopWalk, 'stopWalk-' + str(lane))
        stopWalkTask.avatar = avatar
        walkTask = Task.sequence(
            startWalkTask,
            avatar.lerpPosHpr(posH[0],
                              posH[1],
                              posH[2],
                              posH[3],
                              0,
                              0,
                              time,
                              other=self.raceBoard), stopWalkTask)
        taskMgr.add(walkTask, 'walkAvatar-' + str(lane))
コード例 #2
0
    def runInPlace(self, avatar, lane, currentPlace, newPlace, time):
        place = min(newPlace, len(self.posHprArray[lane]) - 1)
        step = (place - currentPlace) / 3
        pos1 = self.posHprArray[lane][currentPlace + step]
        pos2 = self.posHprArray[lane][currentPlace + 2 * step]
        pos3 = self.posHprArray[lane][place]

        def startRun(task):
            task.avatar.setAnimState('run', 1)
            return Task.done

        startRunTask = Task(startRun, 'startRun-' + str(lane))
        startRunTask.avatar = avatar

        def stopRun(task, raceBoard=self.raceBoard, pos3=pos3):
            task.avatar.setAnimState('neutral', 1)
            task.avatar.setPosHpr(raceBoard, pos3[0], pos3[1], pos3[2],
                                  pos3[3], 0, 0)
            return Task.done

        stopRunTask = Task(stopRun, 'stopRun-' + str(lane))
        stopRunTask.avatar = avatar
        runTask = Task.sequence(
            startRunTask,
            avatar.lerpPosHpr(pos1[0],
                              pos1[1],
                              pos1[2],
                              pos1[3],
                              0,
                              0,
                              time / 3.0,
                              other=self.raceBoard),
            avatar.lerpPosHpr(pos2[0],
                              pos2[1],
                              pos2[2],
                              pos2[3],
                              0,
                              0,
                              time / 3.0,
                              other=self.raceBoard),
            avatar.lerpPosHpr(pos3[0],
                              pos3[1],
                              pos3[2],
                              pos3[3],
                              0,
                              0,
                              time / 3.0,
                              other=self.raceBoard), stopRunTask)
        taskMgr.add(runTask, 'runAvatar-' + str(lane))
コード例 #3
0
    def walkInPlace(self, avatar, lane, place, time):
        # Put the avatar in lane and place specified
        # Clamp the place to the length of the lane
        place = min(place, len(self.posHprArray[lane]) - 1)
        posH = self.posHprArray[lane][place]

        def startWalk(task):
            task.avatar.setAnimState("walk", 1)
            return Task.done

        startWalkTask = Task(startWalk, "startWalk-" + str(lane))
        startWalkTask.avatar = avatar

        def stopWalk(task, raceBoard=self.raceBoard, posH=posH):
            task.avatar.setAnimState("neutral", 1)
            if raceBoard.isEmpty():
                task.avatar.setPosHpr(0, 0, 0, 0, 0, 0)
            else:
                task.avatar.setPosHpr(raceBoard, posH[0], posH[1], posH[2],
                                      posH[3], 0, 0)
            return Task.done

        stopWalkTask = Task(stopWalk, "stopWalk-" + str(lane))
        stopWalkTask.avatar = avatar

        walkTask = Task.sequence(
            startWalkTask,
            avatar.lerpPosHpr(
                posH[0],
                posH[1],
                posH[2],
                posH[3],
                0,
                0,
                time,  # seconds
                other=self.raceBoard),
            stopWalkTask,
        )

        taskMgr.add(walkTask, "walkAvatar-" + str(lane))
コード例 #4
0
    def runInPlace(self, avatar, lane, currentPlace, newPlace, time):
        place = min(newPlace, len(self.posHprArray[lane]) - 1)
        step = (place - currentPlace) / 3
        pos1 = self.posHprArray[lane][currentPlace + step]
        pos2 = self.posHprArray[lane][currentPlace + 2 * step]
        pos3 = self.posHprArray[lane][place]

        def startRun(task):
            task.avatar.setAnimState('run', 1)
            return Task.done

        startRunTask = Task(startRun, 'startRun-' + str(lane))
        startRunTask.avatar = avatar

        def stopRun(task, raceBoard = self.raceBoard, pos3 = pos3):
            task.avatar.setAnimState('neutral', 1)
            task.avatar.setPosHpr(raceBoard, pos3[0], pos3[1], pos3[2], pos3[3], 0, 0)
            return Task.done

        stopRunTask = Task(stopRun, 'stopRun-' + str(lane))
        stopRunTask.avatar = avatar
        runTask = Task.sequence(startRunTask, avatar.lerpPosHpr(pos1[0], pos1[1], pos1[2], pos1[3], 0, 0, time / 3.0, other=self.raceBoard), avatar.lerpPosHpr(pos2[0], pos2[1], pos2[2], pos2[3], 0, 0, time / 3.0, other=self.raceBoard), avatar.lerpPosHpr(pos3[0], pos3[1], pos3[2], pos3[3], 0, 0, time / 3.0, other=self.raceBoard), stopRunTask)
        taskMgr.add(runTask, 'runAvatar-' + str(lane))
コード例 #5
0
    def walkInPlace(self, avatar, lane, place, time):
        place = min(place, len(self.posHprArray[lane]) - 1)
        posH = self.posHprArray[lane][place]

        def startWalk(task):
            task.avatar.setAnimState('walk', 1)
            return Task.done

        startWalkTask = Task(startWalk, 'startWalk-' + str(lane))
        startWalkTask.avatar = avatar

        def stopWalk(task, raceBoard = self.raceBoard, posH = posH):
            task.avatar.setAnimState('neutral', 1)
            if raceBoard.isEmpty():
                task.avatar.setPosHpr(0, 0, 0, 0, 0, 0)
            else:
                task.avatar.setPosHpr(raceBoard, posH[0], posH[1], posH[2], posH[3], 0, 0)
            return Task.done

        stopWalkTask = Task(stopWalk, 'stopWalk-' + str(lane))
        stopWalkTask.avatar = avatar
        walkTask = Task.sequence(startWalkTask, avatar.lerpPosHpr(posH[0], posH[1], posH[2], posH[3], 0, 0, time, other=self.raceBoard), stopWalkTask)
        taskMgr.add(walkTask, 'walkAvatar-' + str(lane))
コード例 #6
0
    def runInPlace(self, avatar, lane, currentPlace, newPlace, time):
        # Put the avatar in lane and place specified
        # Clamp the place to the length of the lane
        place = min(newPlace, len(self.posHprArray[lane]) - 1)

        # we need to approximate the curve of the track
        # better by using more sample points
        step = (place - currentPlace) / 3
        pos1 = self.posHprArray[lane][currentPlace + step]
        pos2 = self.posHprArray[lane][currentPlace + 2 * step]
        pos3 = self.posHprArray[lane][place]

        def startRun(task):
            task.avatar.setAnimState("run", 1)
            return Task.done

        startRunTask = Task(startRun, "startRun-" + str(lane))
        startRunTask.avatar = avatar

        def stopRun(task, raceBoard=self.raceBoard, pos3=pos3):
            task.avatar.setAnimState("neutral", 1)
            task.avatar.setPosHpr(raceBoard, pos3[0], pos3[1], pos3[2],
                                  pos3[3], 0, 0)
            return Task.done

        stopRunTask = Task(stopRun, "stopRun-" + str(lane))
        stopRunTask.avatar = avatar

        runTask = Task.sequence(
            startRunTask,
            avatar.lerpPosHpr(
                pos1[0],
                pos1[1],
                pos1[2],
                pos1[3],
                0,
                0,
                time / 3.,  # seconds
                other=self.raceBoard),
            avatar.lerpPosHpr(
                pos2[0],
                pos2[1],
                pos2[2],
                pos2[3],
                0,
                0,
                time / 3.,  # seconds
                other=self.raceBoard),
            avatar.lerpPosHpr(
                pos3[0],
                pos3[1],
                pos3[2],
                pos3[3],
                0,
                0,
                time / 3.,  # seconds
                other=self.raceBoard),
            stopRunTask,
        )

        taskMgr.add(runTask, "runAvatar-" + str(lane))