from panda3d.core import CardMaker, CollisionNode, CollisionPlane, NodePath, Plane, Point3, Vec3 from direct.directnotify.DirectNotifyGlobal import directNotify from direct.showbase.DirectObject import DirectObject from toontown.minigame import ToonBlitzGlobals from toontown.toonbase import ToontownGlobals from toontown.toonbase.ToonBaseGlobal import base class ToonBlitzAssetMgr(DirectObject): notify = directNotify.newCategory('DistributedToonBlitzAssets') def __init__(self, game): self.__defineConstants() self.game = game self.load() def __defineConstants(self): pass def load(self): self.world = NodePath('ToonBlitzWorld') self.background = base.loader.loadModel('phase_4/models/minigames/toonblitz_game') self.background.reparentTo(self.world) self.startingWall = base.loader.loadModel('phase_4/models/minigames/toonblitz_game_wall') self.startingPipe = base.loader.loadModel('phase_4/models/minigames/toonblitz_game_start') self.exitElevator = base.loader.loadModel('phase_4/models/minigames/toonblitz_game_elevator') self.arrow = base.loader.loadModel('phase_4/models/minigames/toonblitz_game_arrow') self.sprayProp = base.loader.loadModel('phase_4/models/minigames/prop_waterspray') self.treasureModelList = [] salesIcon = base.loader.loadModel('phase_4/models/minigames/salesIcon') self.treasureModelList.append(salesIcon) moneyIcon = base.loader.loadModel('phase_4/models/minigames/moneyIcon') self.treasureModelList.append(moneyIcon) legalIcon = base.loader.loadModel('phase_4/models/minigames/legalIcon') self.treasureModelList.append(legalIcon) corpIcon = base.loader.loadModel('phase_4/models/minigames/corpIcon') self.treasureModelList.append(corpIcon) self.particleGlow = base.loader.loadModel('phase_4/models/minigames/particleGlow') self.blockTypes = [] for i in range(4): blockType = base.loader.loadModel('phase_4/models/minigames/toonblitz_game_block0' + str(i)) self.blockTypes.append(blockType) self.stomper = base.loader.loadModel('phase_4/models/minigames/toonblitz_game_stomper') plane = CollisionPlane(Plane(Vec3(0, 0, 1), Point3(0, 0, -50))) dropPlane = CollisionNode('dropPlane') dropPlane.addSolid(plane) dropPlane.setCollideMask(ToontownGlobals.FloorBitmask) self.world.attachNewNode(dropPlane) self.gameMusic = base.loader.loadMusic('phase_4/audio/bgm/MG_TwoDGame.ogg') self.treasureGrabSound = base.loader.loadSfx('phase_4/audio/sfx/SZ_DD_treasure.ogg') self.sndOof = base.loader.loadSfx('phase_4/audio/sfx/MG_cannon_hit_dirt.ogg') self.soundJump = base.loader.loadSfx('phase_4/audio/sfx/MG_sfx_vine_game_jump.ogg') self.fallSound = base.loader.loadSfx('phase_4/audio/sfx/MG_sfx_vine_game_fall.ogg') self.watergunSound = base.loader.loadSfx('phase_4/audio/sfx/AA_squirt_seltzer_miss.ogg') self.splashSound = base.loader.loadSfx('phase_4/audio/sfx/Seltzer_squirt_2dgame_hit.ogg') self.threeSparkles = base.loader.loadSfx('phase_4/audio/sfx/threeSparkles.ogg') self.sparkleSound = base.loader.loadSfx('phase_4/audio/sfx/sparkly.ogg') self.headCollideSound = base.loader.loadSfx('phase_3.5/audio/sfx/AV_collision.ogg') self.faceStartPos = Vec3(-0.8, 0, -0.87) self.faceEndPos = Vec3(0.8, 0, -0.87) self.aspect2dRoot = base.aspect2d.attachNewNode('TwoDGuiAspect2dRoot') self.aspect2dRoot.setDepthWrite(1) self.cardMaker = CardMaker('card') self.cardMaker.reset() self.cardMaker.setName('ProgressLine') self.cardMaker.setFrame(-0.5, 0.5, -0.5, 0.5) self.progressLine = self.aspect2dRoot.attachNewNode(self.cardMaker.generate()) self.progressLine.setScale(self.faceEndPos[0] - self.faceStartPos[0], 1, 0.01) self.progressLine.setPos(0, 0, self.faceStartPos[2]) self.cardMaker.setName('RaceProgressLineHash') for n in range(ToonBlitzGlobals.NumSections[self.game.getSafezoneId()] + 1): hash = self.aspect2dRoot.attachNewNode(self.cardMaker.generate()) hash.setScale(self.progressLine.getScale()[2], 1, self.progressLine.getScale()[2] * 5) t = float(n) / ToonBlitzGlobals.NumSections[self.game.getSafezoneId()] hash.setPos(self.faceStartPos[0] * (1 - t) + self.faceEndPos[0] * t, self.faceStartPos[1], self.faceStartPos[2]) def destroy(self): while len(self.blockTypes): blockType = self.blockTypes[0] self.blockTypes.remove(blockType) del blockType self.blockTypes = None while len(self.treasureModelList): treasureModel = self.treasureModelList[0] self.treasureModelList.remove(treasureModel) del treasureModel self.treasureModelList = None self.startingWall.removeNode() del self.startingWall self.startingPipe.removeNode() del self.startingPipe self.exitElevator.removeNode() del self.exitElevator self.stomper.removeNode() del self.stomper self.arrow.removeNode() del self.arrow self.sprayProp.removeNode() del self.sprayProp self.aspect2dRoot.removeNode() del self.aspect2dRoot self.world.removeNode() del self.world del self.gameMusic del self.treasureGrabSound del self.sndOof del self.soundJump del self.fallSound del self.watergunSound del self.splashSound del self.threeSparkles del self.sparkleSound del self.headCollideSound self.game = None def onstage(self): self.world.reparentTo(base.render) base.playMusic(self.gameMusic, looping=1, volume=0.9) def offstage(self): self.world.hide() self.gameMusic.stop() def enterPlay(self): pass def exitPlay(self): pass def enterPause(self): pass def exitPause(self): pass def playJumpSound(self): base.localAvatar.soundRun.stop() base.playSfx(self.soundJump, looping=0) def playWatergunSound(self): self.watergunSound.stop() base.playSfx(self.watergunSound, looping=0) def playSplashSound(self): self.splashSound.stop() base.playSfx(self.splashSound, looping=0) def playHeadCollideSound(self): self.headCollideSound.stop() base.playSfx(self.headCollideSound, looping=0)