oldschool-toontown/toontown/minigame/ToonBlitzAssetMgr.py

156 lines
6.5 KiB
Python
Raw Normal View History

2023-04-28 23:23:47 -05:00
from panda3d.core import CardMaker, CollisionNode, CollisionPlane, NodePath, Plane, Point3, Vec3
from direct.directnotify.DirectNotifyGlobal import directNotify
2019-11-02 17:27:54 -05:00
from direct.showbase.DirectObject import DirectObject
2023-04-28 23:23:47 -05:00
from toontown.minigame import ToonBlitzGlobals
from toontown.toonbase import ToontownGlobals
from toontown.toonbase.ToonBaseGlobal import base
2019-11-02 17:27:54 -05:00
class ToonBlitzAssetMgr(DirectObject):
2023-04-28 23:23:47 -05:00
notify = directNotify.newCategory('DistributedToonBlitzAssets')
2019-11-02 17:27:54 -05:00
def __init__(self, game):
self.__defineConstants()
self.game = game
self.load()
def __defineConstants(self):
pass
def load(self):
self.world = NodePath('ToonBlitzWorld')
2023-04-28 23:23:47 -05:00
self.background = base.loader.loadModel('phase_4/models/minigames/toonblitz_game')
2019-11-02 17:27:54 -05:00
self.background.reparentTo(self.world)
2023-04-28 23:23:47 -05:00
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')
2019-11-02 17:27:54 -05:00
self.treasureModelList = []
2023-04-28 23:23:47 -05:00
salesIcon = base.loader.loadModel('phase_4/models/minigames/salesIcon')
2019-11-02 17:27:54 -05:00
self.treasureModelList.append(salesIcon)
2023-04-28 23:23:47 -05:00
moneyIcon = base.loader.loadModel('phase_4/models/minigames/moneyIcon')
2019-11-02 17:27:54 -05:00
self.treasureModelList.append(moneyIcon)
2023-04-28 23:23:47 -05:00
legalIcon = base.loader.loadModel('phase_4/models/minigames/legalIcon')
2019-11-02 17:27:54 -05:00
self.treasureModelList.append(legalIcon)
2023-04-28 23:23:47 -05:00
corpIcon = base.loader.loadModel('phase_4/models/minigames/corpIcon')
2019-11-02 17:27:54 -05:00
self.treasureModelList.append(corpIcon)
2023-04-28 23:23:47 -05:00
self.particleGlow = base.loader.loadModel('phase_4/models/minigames/particleGlow')
2019-11-02 17:27:54 -05:00
self.blockTypes = []
for i in range(4):
2023-04-28 23:23:47 -05:00
blockType = base.loader.loadModel('phase_4/models/minigames/toonblitz_game_block0' + str(i))
2019-11-02 17:27:54 -05:00
self.blockTypes.append(blockType)
2023-04-28 23:23:47 -05:00
self.stomper = base.loader.loadModel('phase_4/models/minigames/toonblitz_game_stomper')
2019-11-02 17:27:54 -05:00
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)
2020-01-14 13:28:52 -06:00
self.gameMusic = base.loader.loadMusic('phase_4/audio/bgm/MG_TwoDGame.ogg')
2023-04-28 23:23:47 -05:00
self.treasureGrabSound = base.loader.loadSfx('phase_4/audio/sfx/SZ_DD_treasure.ogg')
2020-01-14 13:28:52 -06:00
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')
2023-04-28 23:23:47 -05:00
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')
2019-11-02 17:27:54 -05:00
self.faceStartPos = Vec3(-0.8, 0, -0.87)
self.faceEndPos = Vec3(0.8, 0, -0.87)
2023-04-28 23:23:47 -05:00
self.aspect2dRoot = base.aspect2d.attachNewNode('TwoDGuiAspect2dRoot')
2019-11-02 17:27:54 -05:00
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):
2019-11-02 17:27:54 -05:00
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):
2023-04-28 23:23:47 -05:00
self.world.reparentTo(base.render)
2019-11-02 17:27:54 -05:00
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)