Esempio n. 1
0
def manager3d():
    root = core.NodePath("root")
    manager = core.AudioManager.create_AudioManager()
    manager3d = Audio3DManager(manager, root=root)
    yield manager3d
    del manager3d
    manager.shutdown()
Esempio n. 2
0
    def __init__(self, render=None, render2d=None, audio3d=None, *a, **k):
        super(PandaEntityManager, self).__init__(*a, **k)

        if render:
            self.render = render
        else:
            node = NodePath(PandaNode('entities'))
            node.reparentTo(base.render)
            self.render = node
            self._owns_render = True

        if render2d:
            self.render = render2d
        else:
            node = NodePath(PandaNode('entities'))
            node.reparentTo(base.render2d)
            self.render2d = node
            self._owns_render2d = True

        if audio3d:
            self.audio3d = audio3d
        else:
            self.audio3d = Audio3DManager(base.sfxManagerList[0], camera)
            self.audio3d.setListenerVelocityAuto()
            self._owns_audio3d = True
Esempio n. 3
0
    def __init__(self, scene, pos):
        self.scene = scene
        self.pos = pos

        # Set up some AI variables
        self.modelNodePath = scene.addObject(
            'chicken.egg',
            pos=pos,
            scale=(0.7, 0.7, 0.7),
            isActor=True,
            isGeneric=True,
            anims={'walk': 'resources/generic/chicken-walk'})
        self.modelNodePath.loop('walk')
        self.aiChar = AICharacter("chicken", self.modelNodePath, 300, 0.05, 1)
        self.aiBehaviour = self.aiChar.getAiBehaviors()

        # Set up the 3D sound handler
        self.audio3d = Audio3DManager(scene.app.sfxManagerList[0],
                                      scene.app.camera)
        self.chickenSound = self.audio3d.loadSfx(
            'resources/generic/sounds/chicken_cluck.ogg')
        self.audio3d.attachSoundToObject(self.chickenSound, self.modelNodePath)

        # Add the collision Traverser to the app object
        self.scene.app.cTrav = CollisionTraverser()
        # Setup automatic sound velocity determination
        self.audio3d.setSoundVelocityAuto(self.chickenSound)
        self.audio3d.setListenerVelocityAuto()

        # Initialise the distance checking variables
        self.distance = self.modelNodePath.getDistance(self.scene.app.camera)
        self.lastDistance = 12
        self.framesOfEscape = 0
Esempio n. 4
0
    def postInit(self):
        #
        # initialize game content
        #
        base.cTrav = CollisionTraverser("base collision traverser")
        base.pusher = CollisionHandlerPusher()
        self.menu = Menu()
        self.credits = Credits()
        self.charSelection = CharacterSelection()
        self.levelSelection = LevelSelection()
        self.koScreen = KoScreen()
        self.hud = Hud()
        self.menuMusic = loader.loadMusic("assets/audio/menuMusic.ogg")
        self.menuMusic.setLoop(True)
        self.fightMusic = loader.loadMusic("assets/audio/fightMusic.ogg")
        self.fightMusic.setLoop(True)
        base.audio3d = Audio3DManager(base.sfxManagerList[0], camera)

        #
        # Event handling
        #
        self.accept("escape", self.__escape)

        #
        # Start with the menu
        #
        self.request("Menu")
Esempio n. 5
0
    def __init__(self):
        """initialise the engine"""
        ShowBase.__init__(self)
        base.camLens.setNearFar(1.0, 10000)
        base.camLens.setFov(75)
        
        a = 33
        base.camera.setPos(0,-a,a+3)#80)
        # collision
        base.cTrav = CollisionTraverser("base collision traverser")
        base.cHandler = CollisionHandlerEvent()
        base.cPusher = CollisionHandlerPusher()
        base.cQueue = CollisionHandlerQueue()
        base.globalClock=ClockObject.getGlobalClock()
        base.cHandler.addInPattern('%fn-into-%in')
        base.cHandler.addOutPattern('%fn-out-%in')
        base.cHandler.addAgainPattern('%fn-again-%in')
        # ai init
        base.AIworld = AIWorld(render)
        # 3d manager
        base.audio3d = Audio3DManager(base.sfxManagerList[0], camera)
        self.monsters = []
        self.accept('c',self._create)

        base.enableParticles()
Esempio n. 6
0
    def postInit(self):
        #
        # initialize game content
        #
        # camera
        base.camLens.setNearFar(1.0, 10000)
        base.camLens.setFov(75)

        a = 33
        base.camera.setPos(0, -a, a + 3)  #80)
        # collision
        base.cTrav = CollisionTraverser("base collision traverser")
        base.cHandler = CollisionHandlerEvent()
        base.cPusher = CollisionHandlerPusher()
        base.cQueue = CollisionHandlerQueue()
        base.globalClock = ClockObject.getGlobalClock()
        base.cHandler.addInPattern('%fn-into-%in')
        base.cHandler.addOutPattern('%fn-out-%in')
        base.cHandler.addAgainPattern('%fn-again-%in')
        # ai init
        base.AIworld = AIWorld(render)
        # 3d manager
        base.audio3d = Audio3DManager(base.sfxManagerList[0], camera)
        # manager
        self.archiveManager = ArchiveManager()
        self.mapManager = MapManager()
        self.initHeroInfo = None
        # Lock
        self.lock = threading.Lock()
        self.gameThread = None

        self.filters = CommonFilters(base.win, base.cam)
        # UI
        self.menu = Menu()
        self.option = Option()
        self.archive = Archive()
        self.death = Death()
        # self.oobe()
        #self.Archive_status = 0
        # self.menuMusic = loader.loadMusic("assets/audio/menuMusic.ogg")
        # self.menuMusic.setLoop(True)
        # self.fightMusic = loader.loadMusic("assets/audio/fightMusic.ogg")
        # self.fightMusic.setLoop(True)
        # base.audio3d = Audio3DManager(base.sfxManagerList[0], camera)

        self.titleVideo, self.titleCard = loadVideo('title.mp4')

        self.isInited = False
        self.isSkip = False
        self.isRenew = False
        #
        # Event handling
        #
        self.accept("escape", self.__escape)

        #
        # Start with the menu
        #
        self.request("Menu")
Esempio n. 7
0
def init(dropOffFactor, distanceFactor, dopplerFactor):
    "Loads all common sounds and initializes the Panda3D Audio3DManager."
    global manager, physicsManager
    # Setup audio
    manager = Audio3DManager(base.sfxManagerList[0], camera)
    manager.setDropOffFactor(dropOffFactor)
    manager.setDistanceFactor(distanceFactor)
    addSoundGroup(SoundGroup("chaingun", ["sounds/chaingun.ogg"], volume=0.5))
    addSoundGroup(SoundGroup("shotgun", ["sounds/shotgun.ogg"], volume=1.0))
    addSoundGroup(
        SoundGroup("large-explosion", [
            "sounds/large-explosion.ogg", "sounds/large-explosion2.ogg",
            "sounds/large-explosion3.ogg", "sounds/large-explosion4.ogg",
            "sounds/large-explosion5.ogg"
        ],
                   volume=1.0))
    addSoundGroup(
        SoundGroup("sniper-rifle", ["sounds/sniper-rifle.ogg"], volume=1.0))
    addSoundGroup(
        SoundGroup("grenade", ["sounds/grenade.ogg", "sounds/grenade2.ogg"],
                   volume=0.5))
    addSoundGroup(
        SoundGroup("grenade-launch", ["sounds/grenade-launch.ogg"],
                   volume=0.3))
    addSoundGroup(
        SoundGroup("ricochet", [
            "sounds/ricochet1.ogg", "sounds/ricochet2.ogg",
            "sounds/ricochet3.ogg", "sounds/ricochet4.ogg",
            "sounds/ricochet5.ogg"
        ],
                   volume=0.15))
    addSoundGroup(
        SoundGroup("grenade-bounce", ["sounds/grenade-bounce.ogg"],
                   volume=0.2))
    addSoundGroup(SoundGroup("claw", ["sounds/claw.ogg"], volume=1.0))
    addSoundGroup(SoundGroup("claw-fail", ["sounds/claw-fail.ogg"],
                             volume=1.0))
    addSoundGroup(
        SoundGroup("claw-retract", ["sounds/claw-retract.ogg"], volume=1.0))
    addSoundGroup(SoundGroup("spawn", ["sounds/spawn.ogg"], volume=1.0))
    addSoundGroup(SoundGroup("shield", ["sounds/shield.ogg"], volume=1.0))
    addSoundGroup(
        SoundGroup("kamikaze-special", ["sounds/kamikaze-special.ogg"],
                   volume=1.0))
    addSoundGroup(SoundGroup("rocket", ["sounds/rocket.ogg"], volume=1.0))
    addSoundGroup(SoundGroup("reload", ["sounds/reload.ogg"], volume=0.3))
    addSoundGroup(SoundGroup("alarm", ["sounds/alarm.ogg"], volume=0.25))
    addSoundGroup(
        SoundGroup("glass-shatter", [
            "sounds/glass-shatter1.ogg", "sounds/glass-shatter2.ogg",
            "sounds/glass-shatter3.ogg"
        ],
                   volume=1.0))
    addSoundGroup(SoundGroup("pistol", ["sounds/pistol.ogg"], volume=1.0))
    addSoundGroup(
        SoundGroup("pod-landing", ["sounds/pod-landing.ogg"], volume=1.0))
    addSoundGroup(
        SoundGroup("change-weapon", ["sounds/change-weapon.ogg"], volume=0.1))
Esempio n. 8
0
    def __init__(self, table=None, mask=None):
        """
        @keyword table: filename of a table texture. See table_template.psd. Either
                        paint anywhere inside the mask for a complete background
                        or turn off the pads and spinner and paint in the table circle
                        for just a table texture that will have spinners and pads
                        put on top of it.
        @type mask: str
        @keyword mask: filename of a mask texture of the non-Jam-o-Drum area. probably
                       jod_mask.png that comes with the Jam-o-Drum library.
        @type mask: str
        """
        NodePath.__init__(self, "JamoDrum")

        totalHeight = max(1.0, math.sqrt(2) / 4.0 + SPINNER_RADIUS) * 2

        cm = CardMaker("card")
        cm.setFrame(-1, 1, -1, 1)
        self.tableCard = self.attachNewNode(cm.generate())
        self.tableCard.setP(-90)
        self.tableCard.setScale(4.0 / 3.0)
        self.tableCard.setLightOff()
        self.tableCard.setBin("background", 0)
        self.tableCard.setDepthTest(0)
        self.tableCard.setDepthWrite(0)
        self.tableCard.hide()

        if (table):
            self.setTableTexture(loader.loadTexture(table))

        if (mask):
            cm = CardMaker("JOD Mask")
            cm.setFrame(-4.0 / 3.0, 4.0 / 3.0, -4.0 / 3.0, 4.0 / 3.0)
            self.mask = aspect2d.attachNewNode(cm.generate())
            #self.mask.setP(-90)
            self.mask.setTexture(loader.loadTexture(mask), 1)
            self.mask.setTransparency(1)
            self.mask.setDepthTest(0)
        else:
            self.mask = None

        self.stations = []
        for i in range(4):
            station = Station(self, i)
            station.reparentTo(self)
            self.stations.append(station)

        self.reparentTo(render)
        base.disableMouse()
        self.lens = OrthographicLens()
        self.lens.setFilmSize(totalHeight * base.getAspectRatio(), totalHeight)
        base.cam.node().setLens(self.lens)
        camera.setPosHpr(0, 0, 10.0, 0, -90, 0)
        base.setBackgroundColor(0, 0, 0)

        self.audio3d = Audio3DManager(base.sfxManagerList[0], self)
        self.audio3d.setDropOffFactor(0)
Esempio n. 9
0
    def __init__(self):
        System.__init__(self)

        self.audio3d = Audio3DManager(base.sfxManagerList[0], None)
        #self.audio3d.set_distance_factor(1.0)
        #self.audio3d.set_drop_off_factor(0.0)

        # We need cross fading.
        base.musicManager.set_concurrent_sound_limit(2)
Esempio n. 10
0
    def __init__(self):
        ShowBase.__init__(self)
        self.smiley = loader.loadModel("smiley")
        self.smiley.reparentTo(render)

        self.audio = Audio3DManager(self.sfxManagerList[0])
        self.audio.attachListener(self.cam)

        self.loop = self.audio.loadSfx("loop.wav")
        self.loop.setLoop(True)
        self.audio.attachSoundToObject(self.loop, self.smiley)
        self.loop.play()
        
        self.cam.setPos(0, -40, 0)
Esempio n. 11
0
    def start(self, title):
        cfg = GlobalConf().child('panda')

        self.set_defaults(cfg)
        self.base = ShowBase()
        self.base.disableMouse()
        self.audio = self.base.sfxManagerList[0]
        self.audio3d = Audio3DManager(self.audio, camera)
        self.audio3d.setListenerVelocityAuto()
        self.audio3d.setDropOffFactor(0.1)  # HACK

        self.create_properties(title)
        self.update_properties(cfg)
        self.listen_conf(cfg)

        loadPrcFileData("", "interpolate-frames 1")
        loadPrcFileData("", "support-threads #f")
        path = getModelPath()
        path.prependPath('./data')

        self.base.enableParticles()
Esempio n. 12
0
 def setup3DAudio(self):
     """ Initializes the 3D audio manager """
     self.audio3d = Audio3DManager(base.sfxManagerList[0], base.cam)
Esempio n. 13
0
    def __init__(self):
        """initialise the engine"""
        ShowBase.__init__(self)
        base.notify.info("Version {}".format(versionstring))
        FSM.__init__(self, "FSM-Game")

        #
        # BASIC APPLICATION CONFIGURATIONS
        #
        # disable pandas default camera driver
        self.disableMouse()
        # set antialias for the complete sceen to automatic
        self.render.setAntialias(AntialiasAttrib.MAuto)
        # shader generator
        render.setShaderAuto()
        # Enhance font readability
        DGG.getDefaultFont().setPixelsPerUnit(100)
        # get the displays width and height for later usage
        self.dispWidth = self.pipe.getDisplayWidth()
        self.dispHeight = self.pipe.getDisplayHeight()

        #
        # CONFIGURATION LOADING
        #
        # load given variables or set defaults
        # check if particles should be enabled
        # NOTE: If you use the internal physics engine, this always has
        #       to be enabled!
        particles = ConfigVariableBool("particles-enabled", True).getValue()
        if particles:
            self.enableParticles()

        def setFullscreen():
            """Helper function to set the window fullscreen
            with width and height set to the screens size"""
            # set window properties
            # clear all properties not previously set
            base.win.clearRejectedProperties()
            # setup new window properties
            props = WindowProperties()
            # Fullscreen
            props.setFullscreen(True)
            # set the window size to the screen resolution
            props.setSize(self.dispWidth, self.dispHeight)
            # request the new properties
            base.win.requestProperties(props)
            # Set the config variables so we correctly store the
            # new size and fullscreen setting later
            winSize = ConfigVariableString("win-size")
            winSize.setValue("{} {}".format(self.dispWidth, self.dispHeight))
            fullscreen = ConfigVariableBool("fullscreen")
            fullscreen.setValue(True)
            # Render a frame to make sure the fullscreen is applied
            # before we do anything else
            self.taskMgr.step()
            # make sure to propagate the new aspect ratio properly so
            # the GUI and other things will be scaled appropriately
            aspectRatio = self.dispWidth / self.dispHeight
            self.adjustWindowAspectRatio(aspectRatio)

        # check if the config file hasn't been created
        if not os.path.exists(prcFile):
            setFullscreen()
        # automatically safe configuration at application exit
        #base.exitFunc = self.__writeConfig

        #
        # INITIALIZE GAME CONTENT
        #
        base.cTrav = CollisionTraverser("base collision traverser")
        base.pusher = CollisionHandlerPusher()
        self.menu = Menu()
        self.credits = Credits()
        self.charSelection = CharacterSelection()
        self.levelSelection = LevelSelection()
        self.koScreen = KoScreen()
        self.hud = Hud()
        self.menuMusic = loader.loadMusic("assets/audio/menuMusic.ogg")
        self.menuMusic.setLoop(True)
        self.fightMusic = loader.loadMusic("assets/audio/fightMusic.ogg")
        self.fightMusic.setLoop(True)
        base.audio3d = Audio3DManager(base.sfxManagerList[0], camera)

        #
        # EVENT HANDLING
        #
        # By default we accept the escape key
        self.accept("escape", self.__escape)

        #
        # ENTER GAMES INITIAL FSM STATE
        #
        self.request("Menu")
 def enterSetup(self):
     ropes = loader.loadModel('phase_4/models/modules/tt_m_ara_int_ropes')
     ropes.reparentTo(self.interior)
     self.sillyMeter = Actor.Actor('phase_4/models/props/tt_a_ara_ttc_sillyMeter_default', {'arrowTube': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_arrowFluid',
      'phaseOne': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseOne',
      'phaseTwo': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseTwo',
      'phaseThree': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseThree',
      'phaseFour': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFour',
      'phaseFourToFive': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFourToFive',
      'phaseFive': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFive'})
     self.sillyMeter.reparentTo(self.interior)
     self.flatSillyMeter = loader.loadModel('phase_3.5/models/modules/tt_m_ara_int_sillyMeterFlat')
     self.flatSillyMeter.reparentTo(self.interior)
     self.flatSillyMeter.hide()
     self.flatDuck = loader.loadModel('phase_3.5/models/modules/tt_m_ara_int_scientistDuckFlat')
     loc1 = self.interior.find('**/npc_origin_1')
     if loc1:
         self.flatDuck.reparentTo(loc1)
     self.flatDuck.hide()
     self.flatMonkey = loader.loadModel('phase_3.5/models/modules/tt_m_ara_int_scientistMonkeyFlat')
     loc1 = self.interior.find('**/npc_origin_2')
     if loc1:
         self.flatMonkey.reparentTo(loc1)
     self.flatMonkey.hide()
     self.flatHorse = loader.loadModel('phase_3.5/models/modules/tt_m_ara_int_scientistHorseFlat')
     loc1 = self.interior.find('**/npc_origin_3')
     if loc1:
         self.flatHorse.reparentTo(loc1)
     self.flatHorse.hide()
     self.smPhase1 = self.sillyMeter.find('**/stage1')
     self.smPhase2 = self.sillyMeter.find('**/stage2')
     self.smPhase3 = self.sillyMeter.find('**/stage3')
     self.smPhase4 = self.sillyMeter.find('**/stage4')
     self.smPhase2.hide()
     self.smPhase3.hide()
     self.smPhase4.hide()
     thermometerLocator = self.sillyMeter.findAllMatches('**/uvj_progressBar')[1]
     thermometerMesh = self.sillyMeter.find('**/tube')
     thermometerMesh.setTexProjector(thermometerMesh.findTextureStage('default'), thermometerLocator, self.sillyMeter)
     self.sillyMeter.flattenMedium()
     self.sillyMeter.makeSubpart('arrow', ['uvj_progressBar*', 'def_springA'])
     self.sillyMeter.makeSubpart('meter', ['def_pivot'], ['uvj_progressBar*', 'def_springA'])
     self.audio3d = Audio3DManager(base.sfxManagerList[0], camera)
     self.phase1Sfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseOne.ogg')
     self.phase1Sfx.setLoop(True)
     self.phase2Sfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseTwo.ogg')
     self.phase2Sfx.setLoop(True)
     self.phase3Sfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseThree.ogg')
     self.phase3Sfx.setLoop(True)
     self.phase4Sfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseFour.ogg')
     self.phase4Sfx.setLoop(True)
     self.phase4To5Sfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseFourToFive.ogg')
     self.phase4To5Sfx.setLoop(False)
     self.phase5Sfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseFive.ogg')
     self.phase5Sfx.setLoop(True)
     self.arrowSfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterArrow.ogg')
     self.arrowSfx.setLoop(False)
     self.audio3d.setDropOffFactor(0.1)
     self.accept('SillyMeterPhase', self.selectPhase)
     self.accept('SillyMeterIsRunning', self.sillyMeterIsRunning)
     self.startIfNeeded()
from lib.coginvasion.cog.Suit import Suit
from direct.interval.IntervalGlobal import *
from lib.coginvasion.cog.DistributedSuit import DistributedSuit
from direct.distributed.ClientRepository import ClientRepository
from lib.coginvasion.toon.Toon import Toon
from lib.coginvasion.toon import NameTag, ToonDNA, ToonHead
from direct.directutil import Mopath
from direct.showbase.Audio3DManager import Audio3DManager
from direct.showutil.Rope import Rope
import glob

base.enableParticles()

base.cr = ClientRepository([])
base.cr.isShowingPlayerIds = False
base.audio3d = Audio3DManager(base.sfxManagerList[0], camera)

vfs = VirtualFileSystem.getGlobalPtr()
vfs.mount(Filename("phase_0.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_3.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_3.5.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_4.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_5.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_5.5.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_6.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_7.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_8.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_9.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_10.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_11.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_12.mf"), ".", VirtualFileSystem.MFReadOnly)
class Suit(Avatar):
    notify = directNotify.newCategory('Suit')
    audio3d = Audio3DManager(base.sfxManagerList[0], camera)
    audio3d.setDistanceFactor(25)
    audio3d.setDropOffFactor(audio3d.getDistanceFactor() / 1000)

    def __init__(self):
        Avatar.__init__(self)
        self.dept = None
        self.suit = None
        self.head = None
        self.headModel = None
        self.variant = None
        self.handColor = None
        self.voice = None
        self.chat = None
        self.chatDial = None
        self.shadow = None
        self.propeller = None
        self.smallExp = None
        self.largeExp = None
        self.explosion = None
        self.hasSpawned = False
        self.suitTrack = None
        self.timestampAnimTrack = None
        self.propellerSounds = {}
        self.healthBar = None
        self.healthBarGlow = None
        self.condition = 0
        self.avatarType = CIGlobals.Suit
        self.suitPlan = None
        self.animFSM = ClassicFSM('Suit', [
            State('off', self.enterOff, self.exitOff),
            State('neutral', self.enterNeutral, self.exitNeutral),
            State('walk', self.enterWalk, self.exitWalk),
            State('die', self.enterDie, self.exitDie),
            State('win', self.enterWin, self.exitWin),
            State('attack', self.enterAttack, self.exitAttack),
            State('flail', self.enterFlail, self.exitFlail),
            State('flyDown', self.enterFlyDown, self.exitFlyDown),
            State('flyAway', self.enterFlyAway, self.exitFlyAway),
            State('flyNeutral', self.enterFlyNeutral, self.exitFlyNeutral),
            State('trayWalk', self.enterTrayWalk, self.exitTrayWalk),
            State('trayNeutral', self.enterTrayNeutral, self.exitTrayNeutral)
        ], 'off', 'off')
        self.animFSM.enterInitialState()
        self.initializeBodyCollisions()

    def getNametagJoints(self):
        return []

    # BEGIN STATES

    def enterOff(self, ts=0):
        self.anim = None
        return

    def exitOff(self):
        pass

    def exitGeneral(self):
        self.stop()

    def enterTrayWalk(self, ts=0):
        self.show()
        self.loop('tray-walk')

    def exitTrayWalk(self):
        self.exitGeneral()

    def enterTrayNeutral(self, ts=0):
        self.loop('tray-neutral')

    def exitTrayNeutral(self):
        self.stop()

    def enterNeutral(self, ts=0):
        self.show()
        self.loop("neutral")

    def exitNeutral(self):
        self.exitTimestampAnimTrack()
        self.exitGeneral()

    def enterWalk(self, ts=0):
        self.show()
        self.loop("walk")
        self.disableShadowRay()

    def exitWalk(self):
        self.exitTimestampAnimTrack()
        self.exitGeneral()
        self.enableShadowRay()

    def enterFlail(self, ts=0):
        self.pingpong('flail', fromFrame=30, toFrame=35)

    def exitFlail(self):
        self.stop()

    def exitTimestampAnimTrack(self):
        if self.timestampAnimTrack:
            self.timestampAnimTrack.pause()
            self.timestampAnimTrack = None

    def enterAttack(self, attack, target, ts=0):
        self.show()

        if hasattr(self, 'uniqueName'):
            doneEvent = self.uniqueName('suitAttackDone')
        else:
            doneEvent = 'suitAttackDone'
        self.suitAttackState = SuitAttacks(doneEvent, self, target)
        self.suitAttackState.load(attack)
        self.suitAttackState.enter(ts)
        self.headsUp(target)
        self.acceptOnce(doneEvent, self.handleSuitAttackDone)

    def handleSuitAttackDone(self):
        self.exitAttack()

    def exitAttack(self):
        if hasattr(self, 'uniqueName'):
            self.ignore(self.uniqueName('suitAttackDone'))
        else:
            self.ignore('suitAttackDone')
        if hasattr(self, 'suitAttackState'):
            self.suitAttackState.exit()
        if hasattr(self, 'suitAttackState'):
            self.suitAttackState.unload()
        if hasattr(self, 'suitAttackState'):
            del self.suitAttackState

    def interruptAttack(self):
        if hasattr(self, 'suitAttackState'):
            self.suitAttackState.currentAttack.interruptAttack()
            self.clearChatbox()

    def handleWeaponTouch(self):
        if hasattr(self, 'suitAttackState'):
            currentAttack = self.suitAttackState.currentAttack
            if hasattr(currentAttack, 'handleWeaponTouch'):
                currentAttack.handleWeaponTouch()

    def enterFlyNeutral(self, ts=0):
        self.disableRay()
        if not self.propeller:
            self.generatePropeller()
        sfx = self.propellerSounds['neutral']
        sfx.setLoop(True)
        base.playSfx(sfx, node=self)
        self.propeller.loop('chan', fromFrame=0, toFrame=3)
        self.setPlayRate(0.8, 'land')
        self.pingpong('land', fromFrame=0, toFrame=10)

    def exitFlyNeutral(self):
        self.cleanupPropeller()

    def enterFlyDown(self, ts=0):
        self.disableRay()
        if not self.propeller:
            self.generatePropeller()
        sfx = self.propellerSounds['in']
        base.playSfx(sfx, node=self)
        groundF = 28
        dur = self.getDuration('land')
        fr = self.getFrameRate('land')
        if fr:
            animTimeInAir = groundF / fr
        else:
            animTimeInAir = groundF
        impactLength = dur - animTimeInAir
        timeTillLanding = 6.5 - impactLength
        waitTime = timeTillLanding - animTimeInAir
        lastSpinFrame = 8
        propDur = self.propeller.getDuration('chan')
        fr = self.propeller.getFrameRate('chan')
        spinTime = lastSpinFrame / fr
        openTime = (lastSpinFrame + 1) / fr
        if hasattr(self, 'uniqueName'):
            name = self.uniqueName('enterFlyDown')
        else:
            name = 'enterFlyDown'
        animTrack = Sequence(Func(self.pose, 'land', 0), Wait(waitTime),
                             ActorInterval(self, 'land', duration=dur))
        propTrack = Parallel(
            SoundInterval(sfx, duration=waitTime + dur, node=self),
            Sequence(
                ActorInterval(self.propeller,
                              'chan',
                              constrainedLoop=1,
                              duration=waitTime + spinTime,
                              startTime=0.0,
                              endTime=spinTime),
                ActorInterval(self.propeller,
                              'chan',
                              duration=propDur - openTime,
                              startTime=openTime)))
        self.suitTrack = Parallel(animTrack,
                                  propTrack,
                                  name=self.taskName('flyDown'))
        if not self.hasSpawned:
            self.show()
            fadeInTrack = Sequence(
                Func(self.setTransparency, 1),
                self.colorScaleInterval(1,
                                        colorScale=VBase4(1, 1, 1, 1),
                                        startColorScale=VBase4(1, 1, 1, 0)),
                Func(self.clearColorScale), Func(self.clearTransparency))
            self.hasSpawned = True
            self.suitTrack.append(fadeInTrack)
        self.suitTrack.setDoneEvent(self.suitTrack.getName())
        self.acceptOnce(self.suitTrack.getDoneEvent(), self.exitFlyDown)
        self.suitTrack.delayDelete = DelayDelete.DelayDelete(self, name)
        self.suitTrack.start(ts)

    def exitFlyDown(self):
        self.initializeRay(self.avatarType, 2)
        if self.suitTrack != None:
            self.ignore(self.suitTrack.getDoneEvent())
            self.suitTrack.finish()
            DelayDelete.cleanupDelayDeletes(self.suitTrack)
            self.suitTrack = None
        self.exitGeneral()
        self.cleanupPropeller()

    def enterFlyAway(self, ts=0, doFadeOut=0):
        self.show()
        if not self.propeller:
            self.generatePropeller()
        sfx = self.propellerSounds['out']
        if hasattr(self, 'uniqueName'):
            name = self.uniqueName('enterFlyAway')
        else:
            name = 'enterFlyAway'
        dur = self.getDuration('land')
        actInt = ActorInterval(self,
                               'land',
                               loop=0,
                               startTime=dur,
                               endTime=0.0)
        lastSpinFrame = 8
        propDur = self.propeller.getDuration('chan')
        fr = self.propeller.getFrameRate('chan')
        spinTime = lastSpinFrame / fr
        openTime = (lastSpinFrame + 1) / fr
        propTrack = Parallel(
            SoundInterval(sfx, node=self),
            Sequence(
                Func(self.propeller.show),
                ActorInterval(self.propeller,
                              'chan',
                              endTime=openTime,
                              startTime=propDur),
                ActorInterval(self.propeller,
                              'chan',
                              constrainedLoop=1,
                              duration=propDur - openTime,
                              startTime=spinTime,
                              endTime=0.0)))
        self.suitTrack = Parallel(actInt,
                                  propTrack,
                                  name=self.taskName('trackName'))
        if doFadeOut:
            fadeOut = Sequence(
                Wait(4.0), Func(self.setTransparency, 1),
                self.colorScaleInterval(1,
                                        colorScale=VBase4(1, 1, 1, 0),
                                        startColorScale=VBase4(1, 1, 1, 1)),
                Func(self.clearColorScale), Func(self.clearTransparency),
                Func(self.reparentTo, hidden))
            self.suitTrack.append(fadeOut)
        self.suitTrack.setDoneEvent(self.suitTrack.getName())
        self.acceptOnce(self.suitTrack.getDoneEvent(), self.exitFlyAway)
        self.suitTrack.delayDelete = DelayDelete.DelayDelete(self, name)
        self.suitTrack.start(ts)
        self.disableRay()

    def exitFlyAway(self):
        if self.suitTrack:
            self.ignore(self.suitTrack.getDoneEvent())
            self.suitTrack.finish()
            DelayDelete.cleanupDelayDeletes(self.suitTrack)
            self.suitTrack = None
        self.cleanupPropeller()
        self.exitGeneral()

    def enterDie(self, ts=0):
        self.show()
        self.generateCog(isLose=1)
        self.nametag.clearChatText()
        self.deleteNameTag()
        deathSound = base.audio3d.loadSfx(
            "phase_3.5/audio/sfx/Cog_Death_Full.ogg")
        base.audio3d.attachSoundToObject(deathSound, self)
        trackName = self.uniqueName('enterDie')

        smallGears = ParticleLoader.loadParticleEffect(
            'phase_3.5/etc/gearExplosionSmall.ptf')
        smallGears.getParticlesNamed('particles-1').setPoolSize(30)

        singleGear = ParticleLoader.loadParticleEffect(
            'phase_3.5/etc/gearExplosion.ptf')
        singleGear.getParticlesNamed('particles-1').setPoolSize(1)

        smallGearExplosion = ParticleLoader.loadParticleEffect(
            'phase_3.5/etc/gearExplosion.ptf')
        smallGearExplosion.getParticlesNamed('particles-1').setPoolSize(10)

        bigGearExplosion = ParticleLoader.loadParticleEffect(
            'phase_3.5/etc/gearExplosionBig.ptf')
        bigGearExplosion.getParticlesNamed('particles-1').setPoolSize(30)

        smallGears.setDepthWrite(False)
        singleGear.setDepthWrite(False)
        smallGearExplosion.setDepthWrite(False)
        bigGearExplosion.setDepthWrite(False)

        self.smallGears = smallGears
        self.smallGears.setPos(self.find('**/joint_head').getPos() + (0, 0, 2))
        self.singleGear = singleGear
        self.smallGearExp = smallGearExplosion
        self.bigGearExp = bigGearExplosion

        gearTrack = Sequence(Wait(0.7), Func(self.doSingleGear), Wait(1.5),
                             Func(self.doSmallGears), Wait(3.0),
                             Func(self.doBigExp))
        self.suitTrack = Parallel(Sequence(
            Wait(0.8),
            SoundInterval(deathSound,
                          node=self,
                          duration=deathSound.length() / 2)),
                                  Sequence(Wait(0.7), Func(self.doSingleGear),
                                           Wait(4.3), Func(self.suitExplode),
                                           Wait(1.0),
                                           Func(self.disableBodyCollisions),
                                           Func(self.__cleanupExplosion)),
                                  gearTrack,
                                  Sequence(
                                      ActorInterval(self, 'lose', duration=6),
                                      Func(self.getGeomNode().hide)),
                                  name=trackName)
        self.suitTrack.setDoneEvent(self.suitTrack.getName())
        self.acceptOnce(self.suitTrack.getName(), self.exitDie)
        self.suitTrack.delayDelete = DelayDelete.DelayDelete(self, trackName)
        self.suitTrack.start(ts)
        del deathSound

    def doSingleGear(self):
        self.singleGear.start(self.getGeomNode())

    def doSmallGears(self):
        self.smallGears.start(self.getGeomNode())

    def doSmallExp(self):
        self.smallGearExp.start(self.getGeomNode())

    def doBigExp(self):
        self.bigGearExp.start(self.getGeomNode())

    def suitExplode(self):
        self.explosion = loader.loadModel(
            'phase_3.5/models/props/explosion.bam')
        self.explosion.setScale(0.5)
        self.explosion.reparentTo(render)
        self.explosion.setBillboardPointEye()
        if self.variant == Variant.SKELETON:
            self.explosion.setPos(
                self.getPart('body').find('**/joint_head').getPos(render) +
                (0, 0, 2))
        else:
            self.explosion.setPos(self.headModel.getPos(render) + (0, 0, 2))

    def __cleanupExplosion(self):
        if self.explosion:
            self.explosion.removeNode()
            self.explosion = None

    def exitDie(self):
        if self.suitTrack != None:
            self.ignore(self.suitTrack.getName())
            self.suitTrack.finish()
            DelayDelete.cleanupDelayDeletes(self.suitTrack)
            self.suitTrack = None
        if hasattr(self, 'singleGear'):
            self.singleGear.cleanup()
            del self.singleGear
        if hasattr(self, 'smallGears'):
            self.smallGears.cleanup()
            del self.smallGears
        if hasattr(self, 'smallGearExp'):
            self.smallGearExp.cleanup()
            del self.smallGearExp
        if hasattr(self, 'bigGearExp'):
            self.bigGearExp.cleanup()
            del self.bigGearExp
        self.__cleanupExplosion()

    def enterWin(self, ts=0):
        self.play('win')

    def exitWin(self):
        self.exitGeneral()

    # END STATES

    def generate(self, suitPlan, variant, voice=None, hideFirst=True):
        self.suitPlan = suitPlan
        self.suit = suitPlan.getSuitType()
        self.head = suitPlan.getHead()
        self.dept = suitPlan.getDept()
        self.handColor = suitPlan.getHandColor()
        self.variant = variant
        self.setVoice(voice)
        self.generateCog()
        if hideFirst:
            self.hide()

    def __blinkRed(self, task):
        self.healthBar.setColor(SuitGlobals.healthColors[3], 1)
        self.healthBarGlow.setColor(SuitGlobals.healthGlowColors[3], 1)
        if self.condition == 5:
            self.healthBar.setScale(1.17)
        return Task.done

    def __blinkGray(self, task):
        if not self.healthBar:
            return
        self.healthBar.setColor(SuitGlobals.healthColors[4], 1)
        self.healthBarGlow.setColor(SuitGlobals.healthGlowColors[4], 1)
        if self.condition == 5:
            self.healthBar.setScale(1.0)
        return Task.done

    def generateHealthBar(self):
        self.removeHealthBar()
        button = loader.loadModel('phase_3.5/models/gui/matching_game_gui.bam'
                                  ).find('**/minnieCircle')
        button.setScale(3.0)
        button.setH(180)
        button.setColor(SuitGlobals.healthColors[0])
        chestNull = self.find('**/def_joint_attachMeter')
        if chestNull.isEmpty():
            chestNull = self.find('**/joint_attachMeter')
        button.reparentTo(chestNull)
        self.healthBar = button
        self.healthBarGlow = loader.loadModel(
            'phase_3.5/models/props/glow.bam')
        self.healthBarGlow.reparentTo(self.healthBar)
        self.healthBarGlow.setScale(0.28)
        self.healthBarGlow.setPos(-0.005, 0.01, 0.015)
        self.healthBarGlow.setColor(SuitGlobals.healthGlowColors[0])
        button.flattenLight()
        self.condition = 0
        if hasattr(self, 'getHealth'):
            self.updateHealthBar(self.getHealth())

    def updateHealthBar(self, hp):
        if not self.healthBar:
            return
        if hp > self.health:
            self.health = hp
        health = 0.0
        try:
            health = float(hp) / float(self.maxHealth)
        except:
            pass
        if health > 0.95:
            condition = 0
        elif health > 0.7:
            condition = 1
        elif health > 0.3:
            condition = 2
        elif health > 0.05:
            condition = 3
        elif health > 0.0:
            condition = 4
        else:
            condition = 5
        if self.condition != condition:
            if condition == 4:
                blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75),
                                      Task(self.__blinkGray), Task.pause(0.1))
                taskMgr.add(blinkTask, self.taskName('blink-task'))
            elif condition == 5:
                if self.condition == 4:
                    taskMgr.remove(self.taskName('blink-task'))
                blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.25),
                                      Task(self.__blinkGray), Task.pause(0.1))
                taskMgr.add(blinkTask, self.taskName('blink-task'))
            else:
                self.healthBar.setColor(SuitGlobals.healthColors[condition], 1)
                self.healthBarGlow.setColor(
                    SuitGlobals.healthGlowColors[condition], 1)
            self.condition = condition

    def removeHealthBar(self):
        if self.healthBar:
            self.healthBar.removeNode()
            self.healthBar = None
        if self.condition == 4 or self.condition == 5:
            taskMgr.remove(self.taskName('blink-task'))
        self.healthCondition = 0
        return

    def initializeLocalCollisions(self, name):
        self.notify.info('Initializing Local Collisions!')
        Avatar.initializeLocalCollisions(self, 1, 3, name)

    def initializeBodyCollisions(self):
        self.notify.info('Initializing Body Collisions!')
        Avatar.initializeBodyCollisions(self, self.avatarType, 6, 2)
        self.initializeRay(self.avatarType, 2)

    def hideSuit(self):
        self.hide()

    def showSuit(self):
        self.show()
        fadeIn = Sequence(
            Func(self.setTransparency, 1),
            self.colorScaleInterval(0.6,
                                    colorScale=Vec4(1, 1, 1, 1),
                                    startColorScale=Vec4(1, 1, 1, 0)),
            Func(self.clearColorScale), Func(self.clearTransparency),
            Func(self.reparentTo, render))
        fadeIn.start()

    def generateCog(self, isLose=0):
        self.cleanup()
        if not isLose:
            if self.variant == Variant.SKELETON or self.variant == Variant.ZOMBIE:
                self.loadModel(
                    'phase_5/models/char/cog%s_robot-zero.bam' %
                    (str(self.suit)), 'body')
            else:
                self.loadModel(
                    'phase_3.5/models/char/suit%s-mod.bam' % (str(self.suit)),
                    'body')
            animations = SuitGlobals.animations
            anims = {}
            for anim in animations:
                if not self.suit in anim.getSuitTypes():
                    continue
                path = 'phase_%s/models/char/suit%s-%s.bam' % (
                    anim.getPhase(), self.suit, anim.getFile())
                anims[anim.getName()] = path
            self.loadAnims(anims, 'body')
            self.generateHealthBar()
            self.generatePropeller()
        else:
            if self.variant == Variant.SKELETON or self.variant == Variant.ZOMBIE:
                self.loadModel(
                    'phase_5/models/char/cog%s_robot-lose-mod.bam' %
                    (str(self.suit)), 'body')
            else:
                self.loadModel(
                    'phase_4/models/char/suit%s-lose-mod.bam' %
                    (str(self.suit)), 'body')
            self.loadAnims(
                {
                    'lose':
                    'phase_4/models/char/suit%s-lose.bam' % (str(self.suit))
                }, 'body')
        if self.variant != Variant.SKELETON:
            self.headModel = self.head.generate()
            self.headModel.reparentTo(self.find('**/joint_head'))
        if self.suitPlan.getName() == SuitGlobals.VicePresident:
            self.headModel.setScale(0.35)
            self.headModel.setHpr(270, 0, 270)
            self.headModel.setZ(-0.10)
            self.headModel.loop('neutral')
        self.setClothes()
        self.setAvatarScale(self.suitPlan.getScale() /
                            SuitGlobals.scaleFactors[self.suit])
        self.setHeight(self.suitPlan.getHeight())
        self.setupNameTag()
        Avatar.initShadow(self)

    def cleanup(self):
        self.cleanupPropeller()
        self.clearChatbox()
        if self.shadow:
            self.deleteShadow()
        if self.getPart('body'):
            self.removePart('body')
        if self.headModel:
            self.headModel.removeNode()
            self.headModel = None
        self.timestampAnimTrack = None

    def generatePropeller(self):
        self.cleanupPropeller()
        self.propeller = Actor(
            'phase_4/models/props/propeller-mod.bam',
            {'chan': 'phase_4/models/props/propeller-chan.bam'})
        self.propeller.reparentTo(self.find('**/joint_head'))
        self.propellerSounds['in'] = self.audio3d.loadSfx(
            SuitGlobals.propellerInSfx)
        self.propellerSounds['out'] = self.audio3d.loadSfx(
            SuitGlobals.propellerOutSfx)
        self.propellerSounds['neutral'] = self.audio3d.loadSfx(
            SuitGlobals.propellerNeutSfx)
        for sound in self.propellerSounds.values():
            self.audio3d.attachSoundToObject(sound, self.propeller)

    def cleanupPropeller(self):
        for sound in self.propellerSounds.values():
            self.audio3d.detachSound(sound)
            sound.stop()
        self.propellerSounds = {}
        if self.propeller:
            self.propeller.cleanup()
            self.propeller = None

    def setVoice(self, voice):
        if not voice:
            if self.variant == Variant.SKELETON or self.variant == Variant.ZOMBIE:
                self.voice = Voice.SKELETON
            else:
                self.voice = Voice.NORMAL
        else:
            self.voice = voice

    def setClothes(self):
        if self.variant == Variant.SKELETON:
            parts = self.findAllMatches('**/pPlane*')
            for partNum in range(0, parts.getNumPaths()):
                bb = parts.getPath(partNum)
                bb.setTwoSided(1)
            tie = loader.loadTexture('phase_5/maps/cog_robot_tie_%s.jpg' %
                                     self.dept.getTie())
            tie.setMinfilter(Texture.FTLinearMipmapLinear)
            tie.setMagfilter(Texture.FTLinear)
            self.find('**/tie').setTexture(tie, 1)
        else:
            prefix = 'phase_3.5/maps/' + self.dept.getClothingPrefix(
            ) + '_%s.jpg'
            if self.variant == Variant.WAITER:
                prefix = 'phase_3.5/maps/waiter_m_%s.jpg'
            self.find('**/legs').setTexture(loader.loadTexture(prefix % 'leg'),
                                            1)
            self.find('**/arms').setTexture(
                loader.loadTexture(prefix % 'sleeve'), 1)
            self.find('**/torso').setTexture(
                loader.loadTexture(prefix % 'blazer'), 1)
            self.find('**/hands').setColor(self.handColor)

    def setName(self, nameString, charName):
        Avatar.setName(self,
                       nameString,
                       avatarType=self.avatarType,
                       charName=charName,
                       createNow=1)

    def setupNameTag(self, tempName=None):
        Avatar.setupNameTag(self, tempName=tempName)
        if self.nametag:
            if self.level > 0:
                self.nametag.setText(self.nametag.getText() +
                                     '\n%s\nLevel %s' %
                                     (self.dept.getName(), self.level))
            else:
                self.nametag.setText(self.nametag.getText() + '\n%s' %
                                     (self.dept.getName()))

    def setChat(self, chat):
        self.clearChatbox()
        Avatar.setChat(self, chat)
        self.chat = chat
        chatDial = None
        questionDial = self.voice.getSoundFile('question')
        question02Dial = None
        gruntDial = self.voice.getSoundFile('grunt')
        statementDial = self.voice.getSoundFile('statement')
        if self.voice == Voice.NORMAL:
            question02Dial = self.voice.getSoundFile('question_2')

        if '!' in self.chat:
            chatDial = self.audio3d.loadSfx(gruntDial)
        elif '?' in self.chat:
            questionDials = [questionDial]
            if self.voice == Voice.NORMAL:
                questionDials.append(question02Dial)
            chatDial = self.audio3d.loadSfx(random.choice(questionDials))
        else:
            chatDial = self.audio3d.loadSfx(statementDial)
        self.chatDial = chatDial

        if self.variant == Variant.SKELETON:
            self.audio3d.attachSoundToObject(self.chatDial, self)
        else:
            self.audio3d.attachSoundToObject(self.chatDial, self.headModel)
        base.playSfx(self.chatDial, node=self)

    def clearChatbox(self):
        self.clearChat()
        self.chat = None
        if self.chatDial:
            self.chatDial.stop()
            self.chatDial = None

    def getDept(self):
        return self.dept

    def getVariant(self):
        return self.variant

    def disable(self):
        if self.suitTrack:
            self.suitTrack.finish()
            DelayDelete.cleanupDelayDeletes(self.suitTrack)
            self.suitTrack = None
        self.animFSM.requestFinalState()
        self.cleanup()
        Avatar.disable(self)

    def delete(self):
        Avatar.delete(self)
        self.cleanup()
Esempio n. 17
0
    def __init__(self, root_node, mode):
        self.root_node = root_node.attachNewNode('Game')
        self.mode = mode

        base.audio3d = Audio3DManager(base.sfxManagerList[0], camera)
Esempio n. 18
0
 def __init__(self, music, serverVersion):
     self.music = music
     self.serverVersion = serverVersion
     AstronClientRepository.__init__(self, ['phase_3/etc/direct.dc', 'phase_3/etc/toon.dc'])
     self.loginFSM = ClassicFSM('login', [State('off', self.enterOff, self.exitOff),
      State('connect', self.enterConnect, self.exitConnect),
      State('disconnect', self.enterDisconnect, self.exitDisconnect),
      State('avChoose', self.enterAvChoose, self.exitAvChoose),
      State('playingGame', self.enterPlayingGame, self.exitPlayingGame),
      State('serverUnavailable', self.enterServerUnavailable, self.exitServerUnavailable),
      State('makeAToon', self.enterMakeAToon, self.exitMakeAToon),
      State('submitNewToon', self.enterSubmitNewToon, self.exitSubmitNewToon),
      State('noShards', self.enterNoShards, self.exitNoShards),
      State('waitForSetAvatarResponse', self.enterWaitForSetAvatarResponse, self.exitWaitForSetAvatarResponse),
      State('waitForShardList', self.enterWaitForShardList, self.exitWaitForShardList),
      State('ejected', self.enterEjected, self.exitEjected),
      State('districtReset', self.enterDistrictReset, self.exitDistrictReset),
      State('died', self.enterDied, self.exitDied),
      State('betaInform', self.enterBetaInform, self.exitBetaInform)], 'off', 'off')
     self.loginFSM.enterInitialState()
     self.gameFSM = ClassicFSM('game', [State('off', self.enterGameOff, self.exitGameOff),
      State('waitForGameEnterResponse', self.enterWaitForGameEnterResponse, self.exitWaitForGameEnterResponse),
      State('playGame', self.enterPlayGame, self.exitPlayGame),
      State('closeShard', self.enterCloseShard, self.exitCloseShard),
      State('switchShards', self.enterSwitchShards, self.exitSwitchShards)], 'off', 'off')
     self.gameFSM.enterInitialState()
     self.avChooser = AvChooser(self.loginFSM)
     self.playGame = PlayGame(self.gameFSM, 'playGameDone')
     self.hoodMgr = HoodMgr()
     self.makeAToon = MakeAToon()
     self.loginToken = os.environ.get('LOGIN_TOKEN')
     self.serverAddress = os.environ.get('GAME_SERVER')
     self.serverURL = URLSpec('http://%s' % self.serverAddress)
     self.parentMgr.registerParent(CIGlobals.SPRender, render)
     self.parentMgr.registerParent(CIGlobals.SPHidden, hidden)
     self.adminAccess = False
     self.localAvChoice = None
     self.SuitsActive = 0
     self.BossActive = 0
     self.accServerTimesNA = 0
     self.maxAccServerTimesNA = 10
     self.setZonesEmulated = 0
     self.old_setzone_interest_handle = None
     self.setZoneQueue = Queue()
     self.accept(self.SetZoneDoneEvent, self._handleEmuSetZoneDone)
     self.handler = None
     self.__currentAvId = 0
     self.myDistrict = None
     self.activeDistricts = {}
     self.shardListHandle = None
     self.uberZoneInterest = None
     self.isShowingPlayerIds = False
     self.doBetaInform = True
     self.dTutorial = None
     self.requestedName = None
     self.whisperNoise = base.loadSfx('phase_3.5/audio/sfx/GUI_whisper_3.ogg')
     self.checkHttp()
     base.audio3d = Audio3DManager(base.sfxManagerList[0], camera)
     base.audio3d.setDropOffFactor(0)
     base.audio3d.setDopplerFactor(3.0)
     base.lifter = CollisionHandlerFloor()
     base.pusher = CollisionHandlerPusher()
     base.queue = CollisionHandlerQueue()
     base.minigame = None
     base.finalExitCallbacks.insert(0, self.__handleExit)
     self.csm = self.generateGlobalObject(DO_ID_CLIENT_SERVICES_MANAGER, 'ClientServicesManager')
     self.friendsManager = self.generateGlobalObject(DO_ID_FRIENDS_MANAGER, 'FriendsManager')
     SpeedHackChecker.startChecking()
     self.loginFSM.request('connect')
     return
Esempio n. 19
0
    def __init__(self, map="lab"):
        ShowBase.__init__(self)
        pman.shim.init(self)

        self.audio3d = Audio3DManager(
            base.sfxManagerList[0],
            base.cam,
        )

        self.accept('escape', sys.exit)
        #self.render.setShaderAuto()
        self.set_frame_rate_meter(True)
        self.accept('f12', self.debug)

        self.environment = Environment(self, map)
        self.bullet_debug()
        self.accept("f1", self.toggle_bullet_debug)

        self.vehicles = []
        vehicle_files = [
            'Ricardeaut_Magnesium',
            'Ricardeaut_Himony',
            #'Psyoni_Culture',
            #'Texopec_Nako',
            #'Texopec_Reaal',
            # 'Doby_Phalix',
        ]

        for vehicle_file in vehicle_files:
            vehicle = Vehicle(
                self,
                vehicle_file,
            )
            self.vehicles.append(vehicle)

        spawn_points = self.environment.get_spawn_points()
        for vehicle, spawn_point in zip(self.vehicles, spawn_points):
            vehicle.place(spawn_point)

        self.controller_listener = DeviceListener()

        self.player_vehicle_idx = 0
        self.player_controller = VehicleController(
            self,
            self.vehicles[self.player_vehicle_idx],
            self.controller_listener,
        )
        self.player_camera = CameraController(
            base.cam,
            self.vehicles[self.player_vehicle_idx],
            self.player_controller,
        )

        base.task_mgr.add(
            self.game_loop_pre_render,
            "game_loop_pre_render",
            sort=45,
        )
        base.task_mgr.add(
            self.game_loop_post_render,
            "game_loop_post_render",
            sort=55,
        )
Esempio n. 20
0
    def __init__(self):
        # The basics
        ShowBase.__init__(self)
        base.disableMouse()
        self.accept("escape", sys.exit)

        # Audio listener gets attached to the camera
        self.audio3d = Audio3DManager(
            base.sfxManagerList[0],
            self.camera,
        )
        self.emitter = base.render.attach_new_node("repulsor_0")

        # One repulsor sound
        self.repulsor_sound = self.audio3d.load_sfx(
            'assets/audio/sound/repulsor.wav', )
        self.audio3d.attachSoundToObject(
            self.repulsor_sound,
            self.emitter,
        )
        self.repulsor_sound.set_loop(True)
        self.repulsor_sound.play()

        self.repulsor_power = 0.0
        self.repulsor_power_bar = DirectWaitBar(
            text="",
            value=0,
            pos=(0, 0, 0),
            scale=1,
        )

        self.accept("q", self.change_repulsor_power, [0.1])
        self.accept("a", self.change_repulsor_power, [-0.1])
        base.task_mgr.add(self.update_repulsor)

        # One gyro as well
        self.gyro_sound = self.audio3d.load_sfx(
            'assets/audio/sound/gyro.wav', )
        self.audio3d.attachSoundToObject(
            self.gyro_sound,
            self.emitter,
        )
        self.gyro_sound.set_loop(True)
        self.gyro_sound.play()
        self.gyro_duration = 0
        self.gyro_power = 0.0
        self.gyro_power_bar = DirectWaitBar(
            text="",
            value=0,
            pos=(0, 0, -0.2),
            scale=1,
        )
        base.task_mgr.add(self.update_gyro)

        # And one thruster.
        self.thruster_sound = self.audio3d.load_sfx(
            'assets/audio/sound/hairdryer.wav', )
        self.audio3d.attachSoundToObject(
            self.thruster_sound,
            self.emitter,
        )
        self.thruster_overheat_sound = self.audio3d.load_sfx(
            'assets/audio/sound/pop.wav', )
        self.audio3d.attachSoundToObject(
            self.thruster_overheat_sound,
            self.emitter,
        )
        self.thruster_sound.set_loop(True)
        self.thruster_sound.play()
        self.thruster_power = 0.0
        self.thruster_overheated = False
        self.thruster_heat = 0.0
        self.thruster_heat_bar = DirectWaitBar(
            text="",
            value=0,
            pos=(0, 0, -0.4),
            scale=1,
        )
        base.task_mgr.add(self.update_thruster)