fix more crashes
This commit is contained in:
parent
25e353e290
commit
72c6316f6e
4 changed files with 123 additions and 92 deletions
|
@ -1,19 +1,24 @@
|
||||||
from toontown.toonbase.ToonBaseGlobal import *
|
from panda3d.core import ModelNode, NodePath, TextNode
|
||||||
from panda3d.core import *
|
from panda3d.toontown import DNADoor
|
||||||
from panda3d.toontown import *
|
|
||||||
from toontown.toonbase.ToontownGlobals import *
|
|
||||||
import random
|
|
||||||
from direct.task.Task import Task
|
|
||||||
from direct.distributed import DistributedObject
|
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
|
||||||
from . import ToonInteriorColors
|
|
||||||
import pickle
|
|
||||||
from toontown.toonbase import TTLocalizer
|
|
||||||
|
|
||||||
class DistributedHQInterior(DistributedObject.DistributedObject):
|
from direct.directnotify.DirectNotifyGlobal import directNotify
|
||||||
|
from direct.distributed.DistributedObject import DistributedObject
|
||||||
|
from direct.task.TaskManagerGlobal import taskMgr
|
||||||
|
|
||||||
|
from toontown.building import ToonInteriorColors
|
||||||
|
from toontown.toonbase import ToontownGlobals
|
||||||
|
from toontown.toonbase import TTLocalizer
|
||||||
|
from toontown.toonbase.ToonBaseGlobal import base
|
||||||
|
|
||||||
|
import pickle
|
||||||
|
from random import Random
|
||||||
|
|
||||||
|
|
||||||
|
class DistributedHQInterior(DistributedObject):
|
||||||
|
notify = directNotify.newCategory('DistributedHQInterior')
|
||||||
|
|
||||||
def __init__(self, cr):
|
def __init__(self, cr):
|
||||||
DistributedObject.DistributedObject.__init__(self, cr)
|
DistributedObject.__init__(self, cr)
|
||||||
self.dnaStore = cr.playGame.dnaStore
|
self.dnaStore = cr.playGame.dnaStore
|
||||||
self.leaderAvIds = []
|
self.leaderAvIds = []
|
||||||
self.leaderNames = []
|
self.leaderNames = []
|
||||||
|
@ -22,15 +27,15 @@ class DistributedHQInterior(DistributedObject.DistributedObject):
|
||||||
self.tutorial = 0
|
self.tutorial = 0
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
DistributedObject.DistributedObject.generate(self)
|
DistributedObject.generate(self)
|
||||||
self.interior = loader.loadModel('phase_3.5/models/modules/HQ_interior')
|
self.interior = base.loader.loadModel('phase_3.5/models/modules/HQ_interior')
|
||||||
self.interior.reparentTo(render)
|
self.interior.reparentTo(base.render)
|
||||||
self.interior.find('**/cream').hide()
|
self.interior.find('**/cream').hide()
|
||||||
self.interior.find('**/crashed_piano').hide()
|
self.interior.find('**/crashed_piano').hide()
|
||||||
self.buildLeaderBoard()
|
self.buildLeaderBoard()
|
||||||
|
|
||||||
def announceGenerate(self):
|
def announceGenerate(self):
|
||||||
DistributedObject.DistributedObject.announceGenerate(self)
|
DistributedObject.announceGenerate(self)
|
||||||
self.setupDoors()
|
self.setupDoors()
|
||||||
self.interior.flattenMedium()
|
self.interior.flattenMedium()
|
||||||
emptyBoard = self.interior.find('**/empty_board')
|
emptyBoard = self.interior.find('**/empty_board')
|
||||||
|
@ -41,6 +46,7 @@ class DistributedHQInterior(DistributedObject.DistributedObject):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.tutorial = flag
|
self.tutorial = flag
|
||||||
|
|
||||||
if self.tutorial:
|
if self.tutorial:
|
||||||
self.interior.find('**/periscope').hide()
|
self.interior.find('**/periscope').hide()
|
||||||
self.interior.find('**/speakers').hide()
|
self.interior.find('**/speakers').hide()
|
||||||
|
@ -53,7 +59,7 @@ class DistributedHQInterior(DistributedObject.DistributedObject):
|
||||||
self.block = block
|
self.block = block
|
||||||
|
|
||||||
def buildLeaderBoard(self):
|
def buildLeaderBoard(self):
|
||||||
self.leaderBoard = hidden.attachNewNode('leaderBoard')
|
self.leaderBoard = base.hidden.attachNewNode('leaderBoard')
|
||||||
self.leaderBoard.setPosHprScale(0.1, 0, 4.5, 90, 0, 0, 0.9, 0.9, 0.9)
|
self.leaderBoard.setPosHprScale(0.1, 0, 4.5, 90, 0, 0, 0.9, 0.9, 0.9)
|
||||||
z = 0
|
z = 0
|
||||||
row = self.buildTitleRow()
|
row = self.buildTitleRow()
|
||||||
|
@ -63,7 +69,7 @@ class DistributedHQInterior(DistributedObject.DistributedObject):
|
||||||
self.nameTextNodes = []
|
self.nameTextNodes = []
|
||||||
self.scoreTextNodes = []
|
self.scoreTextNodes = []
|
||||||
self.trophyStars = []
|
self.trophyStars = []
|
||||||
for i in range(self.numLeaders):
|
for _ in range(self.numLeaders):
|
||||||
row, nameText, scoreText, trophyStar = self.buildLeaderRow()
|
row, nameText, scoreText, trophyStar = self.buildLeaderRow()
|
||||||
self.nameTextNodes.append(nameText)
|
self.nameTextNodes.append(nameText)
|
||||||
self.scoreTextNodes.append(scoreText)
|
self.scoreTextNodes.append(scoreText)
|
||||||
|
@ -87,7 +93,7 @@ class DistributedHQInterior(DistributedObject.DistributedObject):
|
||||||
self.trophyStars[i].hide()
|
self.trophyStars[i].hide()
|
||||||
|
|
||||||
def buildTitleRow(self):
|
def buildTitleRow(self):
|
||||||
row = hidden.attachNewNode('leaderRow')
|
row = base.hidden.attachNewNode('leaderRow')
|
||||||
nameText = TextNode('titleRow')
|
nameText = TextNode('titleRow')
|
||||||
nameText.setFont(ToontownGlobals.getSignFont())
|
nameText.setFont(ToontownGlobals.getSignFont())
|
||||||
nameText.setAlign(TextNode.ACenter)
|
nameText.setAlign(TextNode.ACenter)
|
||||||
|
@ -98,7 +104,7 @@ class DistributedHQInterior(DistributedObject.DistributedObject):
|
||||||
return row
|
return row
|
||||||
|
|
||||||
def buildLeaderRow(self):
|
def buildLeaderRow(self):
|
||||||
row = hidden.attachNewNode('leaderRow')
|
row = base.hidden.attachNewNode('leaderRow')
|
||||||
nameText = TextNode('nameText')
|
nameText = TextNode('nameText')
|
||||||
nameText.setFont(ToontownGlobals.getToonFont())
|
nameText.setFont(ToontownGlobals.getToonFont())
|
||||||
nameText.setAlign(TextNode.ALeft)
|
nameText.setAlign(TextNode.ALeft)
|
||||||
|
@ -135,15 +141,16 @@ class DistributedHQInterior(DistributedObject.DistributedObject):
|
||||||
doorModelName = doorModelName[:-1] + 'l'
|
doorModelName = doorModelName[:-1] + 'l'
|
||||||
else:
|
else:
|
||||||
doorModelName = doorModelName[:-1] + 'r'
|
doorModelName = doorModelName[:-1] + 'r'
|
||||||
|
|
||||||
door = self.dnaStore.findNode(doorModelName)
|
door = self.dnaStore.findNode(doorModelName)
|
||||||
return door
|
return door
|
||||||
|
|
||||||
def setupDoors(self):
|
def setupDoors(self):
|
||||||
self.randomGenerator = random.Random()
|
self.randomGenerator = Random()
|
||||||
self.randomGenerator.seed(self.zoneId)
|
self.randomGenerator.seed(self.zoneId)
|
||||||
self.colors = ToonInteriorColors.colors[ToontownCentral]
|
self.colors = ToonInteriorColors.colors[ToontownGlobals.ToontownCentral]
|
||||||
door = self.chooseDoor()
|
door = self.chooseDoor()
|
||||||
doorOrigins = render.findAllMatches('**/door_origin*')
|
doorOrigins = base.render.findAllMatches('**/door_origin*')
|
||||||
numDoorOrigins = doorOrigins.getNumPaths()
|
numDoorOrigins = doorOrigins.getNumPaths()
|
||||||
for npIndex in range(numDoorOrigins):
|
for npIndex in range(numDoorOrigins):
|
||||||
doorOrigin = doorOrigins[npIndex]
|
doorOrigin = doorOrigins[npIndex]
|
||||||
|
@ -173,10 +180,10 @@ class DistributedHQInterior(DistributedObject.DistributedObject):
|
||||||
del self.scoreTextNodes
|
del self.scoreTextNodes
|
||||||
del self.trophyStars
|
del self.trophyStars
|
||||||
taskMgr.remove(self.uniqueName('starSpinHQ'))
|
taskMgr.remove(self.uniqueName('starSpinHQ'))
|
||||||
DistributedObject.DistributedObject.disable(self)
|
DistributedObject.disable(self)
|
||||||
|
|
||||||
def buildTrophyStar(self):
|
def buildTrophyStar(self):
|
||||||
trophyStar = loader.loadModel('phase_3.5/models/gui/name_star')
|
trophyStar = base.loader.loadModel('phase_3.5/models/gui/name_star')
|
||||||
trophyStar.hide()
|
trophyStar.hide()
|
||||||
trophyStar.setPos(*TTLocalizer.DHQItrophyStarPos)
|
trophyStar.setPos(*TTLocalizer.DHQItrophyStarPos)
|
||||||
return trophyStar
|
return trophyStar
|
||||||
|
@ -211,7 +218,7 @@ class DistributedHQInterior(DistributedObject.DistributedObject):
|
||||||
trophyStar.hide()
|
trophyStar.hide()
|
||||||
|
|
||||||
def __starSpin(self, task):
|
def __starSpin(self, task):
|
||||||
now = globalClock.getFrameTime()
|
now = base.clock.getFrameTime()
|
||||||
r = now * task.trophyStarSpeed % 360.0
|
r = now * task.trophyStarSpeed % 360.0
|
||||||
task.trophyStar.setR(r)
|
task.trophyStar.setR(r)
|
||||||
return Task.cont
|
return task.cont
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
from panda3d.core import *
|
from panda3d.core import CardMaker, CollisionNode, CollisionPlane, NodePath, Plane, Point3, Vec3
|
||||||
|
|
||||||
|
from direct.directnotify.DirectNotifyGlobal import directNotify
|
||||||
from direct.showbase.DirectObject import DirectObject
|
from direct.showbase.DirectObject import DirectObject
|
||||||
from toontown.toonbase.ToonBaseGlobal import *
|
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from toontown.minigame import ToonBlitzGlobals
|
||||||
from toontown.minigame import ToonBlitzGlobals, TwoDBlock
|
from toontown.toonbase import ToontownGlobals
|
||||||
from panda3d.core import CardMaker
|
from toontown.toonbase.ToonBaseGlobal import base
|
||||||
|
|
||||||
|
|
||||||
class ToonBlitzAssetMgr(DirectObject):
|
class ToonBlitzAssetMgr(DirectObject):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedToonBlitzAssets')
|
notify = directNotify.newCategory('DistributedToonBlitzAssets')
|
||||||
|
|
||||||
def __init__(self, game):
|
def __init__(self, game):
|
||||||
self.__defineConstants()
|
self.__defineConstants()
|
||||||
|
@ -18,47 +21,47 @@ class ToonBlitzAssetMgr(DirectObject):
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
self.world = NodePath('ToonBlitzWorld')
|
self.world = NodePath('ToonBlitzWorld')
|
||||||
self.background = loader.loadModel('phase_4/models/minigames/toonblitz_game')
|
self.background = base.loader.loadModel('phase_4/models/minigames/toonblitz_game')
|
||||||
self.background.reparentTo(self.world)
|
self.background.reparentTo(self.world)
|
||||||
self.startingWall = loader.loadModel('phase_4/models/minigames/toonblitz_game_wall')
|
self.startingWall = base.loader.loadModel('phase_4/models/minigames/toonblitz_game_wall')
|
||||||
self.startingPipe = loader.loadModel('phase_4/models/minigames/toonblitz_game_start')
|
self.startingPipe = base.loader.loadModel('phase_4/models/minigames/toonblitz_game_start')
|
||||||
self.exitElevator = loader.loadModel('phase_4/models/minigames/toonblitz_game_elevator')
|
self.exitElevator = base.loader.loadModel('phase_4/models/minigames/toonblitz_game_elevator')
|
||||||
self.arrow = loader.loadModel('phase_4/models/minigames/toonblitz_game_arrow')
|
self.arrow = base.loader.loadModel('phase_4/models/minigames/toonblitz_game_arrow')
|
||||||
self.sprayProp = loader.loadModel('phase_4/models/minigames/prop_waterspray')
|
self.sprayProp = base.loader.loadModel('phase_4/models/minigames/prop_waterspray')
|
||||||
self.treasureModelList = []
|
self.treasureModelList = []
|
||||||
salesIcon = loader.loadModel('phase_4/models/minigames/salesIcon')
|
salesIcon = base.loader.loadModel('phase_4/models/minigames/salesIcon')
|
||||||
self.treasureModelList.append(salesIcon)
|
self.treasureModelList.append(salesIcon)
|
||||||
moneyIcon = loader.loadModel('phase_4/models/minigames/moneyIcon')
|
moneyIcon = base.loader.loadModel('phase_4/models/minigames/moneyIcon')
|
||||||
self.treasureModelList.append(moneyIcon)
|
self.treasureModelList.append(moneyIcon)
|
||||||
legalIcon = loader.loadModel('phase_4/models/minigames/legalIcon')
|
legalIcon = base.loader.loadModel('phase_4/models/minigames/legalIcon')
|
||||||
self.treasureModelList.append(legalIcon)
|
self.treasureModelList.append(legalIcon)
|
||||||
corpIcon = loader.loadModel('phase_4/models/minigames/corpIcon')
|
corpIcon = base.loader.loadModel('phase_4/models/minigames/corpIcon')
|
||||||
self.treasureModelList.append(corpIcon)
|
self.treasureModelList.append(corpIcon)
|
||||||
self.particleGlow = loader.loadModel('phase_4/models/minigames/particleGlow')
|
self.particleGlow = base.loader.loadModel('phase_4/models/minigames/particleGlow')
|
||||||
self.blockTypes = []
|
self.blockTypes = []
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
blockType = loader.loadModel('phase_4/models/minigames/toonblitz_game_block0' + str(i))
|
blockType = base.loader.loadModel('phase_4/models/minigames/toonblitz_game_block0' + str(i))
|
||||||
self.blockTypes.append(blockType)
|
self.blockTypes.append(blockType)
|
||||||
|
|
||||||
self.stomper = loader.loadModel('phase_4/models/minigames/toonblitz_game_stomper')
|
self.stomper = base.loader.loadModel('phase_4/models/minigames/toonblitz_game_stomper')
|
||||||
plane = CollisionPlane(Plane(Vec3(0, 0, 1), Point3(0, 0, -50)))
|
plane = CollisionPlane(Plane(Vec3(0, 0, 1), Point3(0, 0, -50)))
|
||||||
dropPlane = CollisionNode('dropPlane')
|
dropPlane = CollisionNode('dropPlane')
|
||||||
dropPlane.addSolid(plane)
|
dropPlane.addSolid(plane)
|
||||||
dropPlane.setCollideMask(ToontownGlobals.FloorBitmask)
|
dropPlane.setCollideMask(ToontownGlobals.FloorBitmask)
|
||||||
self.world.attachNewNode(dropPlane)
|
self.world.attachNewNode(dropPlane)
|
||||||
self.gameMusic = base.loader.loadMusic('phase_4/audio/bgm/MG_TwoDGame.ogg')
|
self.gameMusic = base.loader.loadMusic('phase_4/audio/bgm/MG_TwoDGame.ogg')
|
||||||
self.treasureGrabSound = loader.loadSfx('phase_4/audio/sfx/SZ_DD_treasure.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.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.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.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.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.splashSound = base.loader.loadSfx('phase_4/audio/sfx/Seltzer_squirt_2dgame_hit.ogg')
|
||||||
self.threeSparkles = loader.loadSfx('phase_4/audio/sfx/threeSparkles.ogg')
|
self.threeSparkles = base.loader.loadSfx('phase_4/audio/sfx/threeSparkles.ogg')
|
||||||
self.sparkleSound = loader.loadSfx('phase_4/audio/sfx/sparkly.ogg')
|
self.sparkleSound = base.loader.loadSfx('phase_4/audio/sfx/sparkly.ogg')
|
||||||
self.headCollideSound = loader.loadSfx('phase_3.5/audio/sfx/AV_collision.ogg')
|
self.headCollideSound = base.loader.loadSfx('phase_3.5/audio/sfx/AV_collision.ogg')
|
||||||
self.faceStartPos = Vec3(-0.8, 0, -0.87)
|
self.faceStartPos = Vec3(-0.8, 0, -0.87)
|
||||||
self.faceEndPos = Vec3(0.8, 0, -0.87)
|
self.faceEndPos = Vec3(0.8, 0, -0.87)
|
||||||
self.aspect2dRoot = aspect2d.attachNewNode('TwoDGuiAspect2dRoot')
|
self.aspect2dRoot = base.aspect2d.attachNewNode('TwoDGuiAspect2dRoot')
|
||||||
self.aspect2dRoot.setDepthWrite(1)
|
self.aspect2dRoot.setDepthWrite(1)
|
||||||
self.cardMaker = CardMaker('card')
|
self.cardMaker = CardMaker('card')
|
||||||
self.cardMaker.reset()
|
self.cardMaker.reset()
|
||||||
|
@ -114,10 +117,9 @@ class ToonBlitzAssetMgr(DirectObject):
|
||||||
del self.sparkleSound
|
del self.sparkleSound
|
||||||
del self.headCollideSound
|
del self.headCollideSound
|
||||||
self.game = None
|
self.game = None
|
||||||
return
|
|
||||||
|
|
||||||
def onstage(self):
|
def onstage(self):
|
||||||
self.world.reparentTo(render)
|
self.world.reparentTo(base.render)
|
||||||
base.playMusic(self.gameMusic, looping=1, volume=0.9)
|
base.playMusic(self.gameMusic, looping=1, volume=0.9)
|
||||||
|
|
||||||
def offstage(self):
|
def offstage(self):
|
||||||
|
|
|
@ -1,14 +1,29 @@
|
||||||
from panda3d.core import *
|
from panda3d.core import CollisionHandlerEvent, CollisionNode, CollisionSphere, Point3, Point4, VBase3, Vec3
|
||||||
|
|
||||||
|
from direct.directnotify.DirectNotifyGlobal import directNotify
|
||||||
|
from direct.interval.IntervalGlobal import (
|
||||||
|
ActorInterval,
|
||||||
|
Func,
|
||||||
|
LerpPosInterval,
|
||||||
|
LerpScaleInterval,
|
||||||
|
Parallel,
|
||||||
|
Sequence,
|
||||||
|
Wait
|
||||||
|
)
|
||||||
|
|
||||||
from direct.showbase.DirectObject import DirectObject
|
from direct.showbase.DirectObject import DirectObject
|
||||||
from toontown.toonbase.ToonBaseGlobal import *
|
from direct.showbase.MessengerGlobal import messenger
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
|
||||||
from direct.interval.IntervalGlobal import *
|
|
||||||
from toontown.battle.BattleProps import *
|
|
||||||
from toontown.battle import MovieUtil
|
from toontown.battle import MovieUtil
|
||||||
import math
|
from toontown.battle.BattleProps import globalPropPool
|
||||||
|
from toontown.toonbase import ToontownGlobals
|
||||||
|
from toontown.toonbase.ToonBaseGlobal import base
|
||||||
|
|
||||||
|
from math import sin
|
||||||
|
|
||||||
|
|
||||||
class TwoDBattleMgr(DirectObject):
|
class TwoDBattleMgr(DirectObject):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('TwoDBattleMgr')
|
notify = directNotify.newCategory('TwoDBattleMgr')
|
||||||
|
|
||||||
def __init__(self, game, toon):
|
def __init__(self, game, toon):
|
||||||
self.game = game
|
self.game = game
|
||||||
|
@ -26,7 +41,6 @@ class TwoDBattleMgr(DirectObject):
|
||||||
self.setupPistol()
|
self.setupPistol()
|
||||||
if self.toon == base.localAvatar:
|
if self.toon == base.localAvatar:
|
||||||
self.createShootCollision()
|
self.createShootCollision()
|
||||||
return
|
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
if self.toon == base.localAvatar:
|
if self.toon == base.localAvatar:
|
||||||
|
@ -34,18 +48,20 @@ class TwoDBattleMgr(DirectObject):
|
||||||
self.waterBulletIval.finish()
|
self.waterBulletIval.finish()
|
||||||
del self.waterBulletIval
|
del self.waterBulletIval
|
||||||
self.waterBulletIval = None
|
self.waterBulletIval = None
|
||||||
|
|
||||||
self.ignore('enter' + self.collSphereName)
|
self.ignore('enter' + self.collSphereName)
|
||||||
base.localAvatar.controlManager.currentControls.cTrav.removeCollider(self.waterBullet)
|
base.localAvatar.controlManager.currentControls.cTrav.removeCollider(self.waterBullet)
|
||||||
self.waterBullet.removeNode()
|
self.waterBullet.removeNode()
|
||||||
del self.waterBullet
|
del self.waterBullet
|
||||||
|
|
||||||
self.hand_jointpath0.removeNode()
|
self.hand_jointpath0.removeNode()
|
||||||
MovieUtil.removeProp(self.pistol)
|
MovieUtil.removeProp(self.pistol)
|
||||||
if self.shootTrack != None:
|
if self.shootTrack != None:
|
||||||
self.shootTrack.finish()
|
self.shootTrack.finish()
|
||||||
self.shootTrack = None
|
self.shootTrack = None
|
||||||
|
|
||||||
self.game = None
|
self.game = None
|
||||||
self.toon = None
|
self.toon = None
|
||||||
return
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
pass
|
pass
|
||||||
|
@ -67,6 +83,7 @@ class TwoDBattleMgr(DirectObject):
|
||||||
if self.toon == base.localAvatar:
|
if self.toon == base.localAvatar:
|
||||||
self.shootTrack.append(Func(self.game.assetMgr.playWatergunSound))
|
self.shootTrack.append(Func(self.game.assetMgr.playWatergunSound))
|
||||||
self.shootTrack.append(self.getWaterBulletIval())
|
self.shootTrack.append(self.getWaterBulletIval())
|
||||||
|
|
||||||
self.shootTrack.start()
|
self.shootTrack.start()
|
||||||
return
|
return
|
||||||
elif self.shootTrack.isStopped():
|
elif self.shootTrack.isStopped():
|
||||||
|
@ -74,6 +91,7 @@ class TwoDBattleMgr(DirectObject):
|
||||||
if self.toon == base.localAvatar:
|
if self.toon == base.localAvatar:
|
||||||
self.shootTrack.append(Func(self.game.assetMgr.playWatergunSound))
|
self.shootTrack.append(Func(self.game.assetMgr.playWatergunSound))
|
||||||
self.shootTrack.append(self.getWaterBulletIval())
|
self.shootTrack.append(self.getWaterBulletIval())
|
||||||
|
|
||||||
self.shootTrack.start()
|
self.shootTrack.start()
|
||||||
|
|
||||||
def createShootCollision(self):
|
def createShootCollision(self):
|
||||||
|
@ -90,6 +108,7 @@ class TwoDBattleMgr(DirectObject):
|
||||||
self.waterBullet.hide()
|
self.waterBullet.hide()
|
||||||
if self.showCollSpheres:
|
if self.showCollSpheres:
|
||||||
self.waterBullet.show()
|
self.waterBullet.show()
|
||||||
|
|
||||||
bulletEvent = CollisionHandlerEvent()
|
bulletEvent = CollisionHandlerEvent()
|
||||||
bulletEvent.addInPattern('enter%fn')
|
bulletEvent.addInPattern('enter%fn')
|
||||||
bulletEvent.addOutPattern('exit%fn')
|
bulletEvent.addOutPattern('exit%fn')
|
||||||
|
@ -108,22 +127,23 @@ class TwoDBattleMgr(DirectObject):
|
||||||
else:
|
else:
|
||||||
toon.loop('neutral')
|
toon.loop('neutral')
|
||||||
|
|
||||||
torso = self.toon.getPart('torso', '1000')
|
|
||||||
toonTrack = Sequence(ActorInterval(self.toon, 'water-gun', startFrame=48, endFrame=58, partName='torso'), ActorInterval(self.toon, 'water-gun', startFrame=107, endFrame=126, playRate=2, partName='torso'), Func(returnToLastAnim, self.toon))
|
toonTrack = Sequence(ActorInterval(self.toon, 'water-gun', startFrame=48, endFrame=58, partName='torso'), ActorInterval(self.toon, 'water-gun', startFrame=107, endFrame=126, playRate=2, partName='torso'), Func(returnToLastAnim, self.toon))
|
||||||
return toonTrack
|
return toonTrack
|
||||||
|
|
||||||
def calcSprayStartPos(self):
|
def calcSprayStartPos(self):
|
||||||
if self.toon:
|
if self.toon:
|
||||||
self.toon.update(0)
|
self.toon.update(0)
|
||||||
|
|
||||||
joint = self.pistol.find('**/joint_nozzle')
|
joint = self.pistol.find('**/joint_nozzle')
|
||||||
p = joint.getPos(render)
|
p = joint.getPos(base.render)
|
||||||
self.origin = p
|
self.origin = p
|
||||||
|
|
||||||
def calcSprayEndPos(self):
|
def calcSprayEndPos(self):
|
||||||
if self.toon:
|
if self.toon:
|
||||||
xDirection = -math.sin(self.toon.getH())
|
xDirection = -sin(self.toon.getH())
|
||||||
else:
|
else:
|
||||||
xDirection = -math.sin(-90)
|
xDirection = -sin(-90)
|
||||||
|
|
||||||
endPos = Point3(self.origin.getX() + self.SHOOT_DISTANCE * xDirection, self.origin.getY(), self.origin.getZ())
|
endPos = Point3(self.origin.getX() + self.SHOOT_DISTANCE * xDirection, self.origin.getY(), self.origin.getZ())
|
||||||
self.target = endPos
|
self.target = endPos
|
||||||
|
|
||||||
|
@ -131,7 +151,7 @@ class TwoDBattleMgr(DirectObject):
|
||||||
dSprayScale = 0.15
|
dSprayScale = 0.15
|
||||||
dSprayHold = 0.035
|
dSprayHold = 0.035
|
||||||
color = self.WATER_SPRAY_COLOR
|
color = self.WATER_SPRAY_COLOR
|
||||||
parent = render
|
parent = base.render
|
||||||
horizScale = 1.0
|
horizScale = 1.0
|
||||||
vertScale = 1.0
|
vertScale = 1.0
|
||||||
|
|
||||||
|
@ -161,12 +181,13 @@ class TwoDBattleMgr(DirectObject):
|
||||||
sprayScale.removeNode()
|
sprayScale.removeNode()
|
||||||
|
|
||||||
sprayProp = self.sprayProp
|
sprayProp = self.sprayProp
|
||||||
sprayScale = hidden.attachNewNode('spray-parent')
|
sprayScale = base.hidden.attachNewNode('spray-parent')
|
||||||
sprayRot = hidden.attachNewNode('spray-rotate')
|
sprayRot = base.hidden.attachNewNode('spray-rotate')
|
||||||
spray = sprayRot
|
spray = sprayRot
|
||||||
spray.setColor(color)
|
spray.setColor(color)
|
||||||
if color[3] < 1.0:
|
if color[3] < 1.0:
|
||||||
spray.setTransparency(1)
|
spray.setTransparency(1)
|
||||||
|
|
||||||
track = Sequence(Wait(0.1), Func(self.calcSprayStartPos), Func(self.calcSprayEndPos), Func(showSpray, sprayScale, sprayRot, sprayProp, parent), LerpScaleInterval(sprayScale, dSprayScale, calcTargetScale, startScale=MovieUtil.PNT3_NEARZERO), Wait(dSprayHold), Func(prepareToShrinkSpray, spray, sprayProp), LerpScaleInterval(sprayScale, dSprayScale, MovieUtil.PNT3_NEARZERO), Func(hideSpray, spray, sprayScale, sprayRot, sprayProp, globalPropPool))
|
track = Sequence(Wait(0.1), Func(self.calcSprayStartPos), Func(self.calcSprayEndPos), Func(showSpray, sprayScale, sprayRot, sprayProp, parent), LerpScaleInterval(sprayScale, dSprayScale, calcTargetScale, startScale=MovieUtil.PNT3_NEARZERO), Wait(dSprayHold), Func(prepareToShrinkSpray, spray, sprayProp), LerpScaleInterval(sprayScale, dSprayScale, MovieUtil.PNT3_NEARZERO), Func(hideSpray, spray, sprayScale, sprayRot, sprayProp, globalPropPool))
|
||||||
return track
|
return track
|
||||||
|
|
||||||
|
@ -180,8 +201,8 @@ class TwoDBattleMgr(DirectObject):
|
||||||
if self.waterBulletIval:
|
if self.waterBulletIval:
|
||||||
self.waterBulletIval.finish()
|
self.waterBulletIval.finish()
|
||||||
del self.waterBulletIval
|
del self.waterBulletIval
|
||||||
|
|
||||||
self.waterBulletIval = None
|
self.waterBulletIval = None
|
||||||
return
|
|
||||||
|
|
||||||
def getWaterBulletIval(self):
|
def getWaterBulletIval(self):
|
||||||
if not self.waterBulletIval.isPlaying():
|
if not self.waterBulletIval.isPlaying():
|
||||||
|
|
|
@ -1,39 +1,39 @@
|
||||||
from direct.distributed import DistributedObject
|
from panda3d.core import NodePath, TextNode
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
|
||||||
from otp.otpbase import OTPTimer
|
from direct.directnotify.DirectNotifyGlobal import directNotify
|
||||||
|
from direct.distributed.DistributedObject import DistributedObject
|
||||||
|
|
||||||
|
from toontown.toonbase import ToontownGlobals
|
||||||
from toontown.toonbase import TTLocalizer
|
from toontown.toonbase import TTLocalizer
|
||||||
from toontown.racing import KartShopGlobals
|
from toontown.toonbase.ToonBaseGlobal import base
|
||||||
from toontown.toonbase.ToonBaseGlobal import *
|
|
||||||
from panda3d.core import *
|
|
||||||
from toontown.toonbase.ToontownGlobals import *
|
|
||||||
import random
|
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
class DistributedLeaderBoard(DistributedObject.DistributedObject):
|
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('DisributedLeaderBoard')
|
class DistributedLeaderBoard(DistributedObject):
|
||||||
|
notify = directNotify.newCategory('DisributedLeaderBoard')
|
||||||
|
|
||||||
def __init__(self, cr):
|
def __init__(self, cr):
|
||||||
self.notify.debug('__init__: initialization of local leaderboard')
|
self.notify.debug('__init__: initialization of local leaderboard')
|
||||||
DistributedObject.DistributedObject.__init__(self, cr)
|
DistributedObject.__init__(self, cr)
|
||||||
self.corner = 0
|
self.corner = 0
|
||||||
self.length = 0
|
self.length = 0
|
||||||
self.width = 0
|
self.width = 0
|
||||||
self.updateCount = 0
|
self.updateCount = 0
|
||||||
self.board = None
|
self.board = None
|
||||||
self.surface = None
|
self.surface = None
|
||||||
return
|
|
||||||
|
|
||||||
def generateInit(self):
|
def generateInit(self):
|
||||||
DistributedObject.DistributedObject.generateInit(self)
|
DistributedObject.generateInit(self)
|
||||||
self.board = NodePath(self.uniqueName('LeaderBoard'))
|
self.board = NodePath(self.uniqueName('LeaderBoard'))
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
DistributedObject.DistributedObject.generate(self)
|
DistributedObject.generate(self)
|
||||||
self.buildListParts()
|
self.buildListParts()
|
||||||
|
|
||||||
def announceGenerate(self):
|
def announceGenerate(self):
|
||||||
DistributedObject.DistributedObject.announceGenerate(self)
|
DistributedObject.announceGenerate(self)
|
||||||
self.board.reparentTo(render)
|
self.board.reparentTo(base.render)
|
||||||
self.accept('decorator-holiday-%d-ending' % ToontownGlobals.CRASHED_LEADERBOARD, self.showLists)
|
self.accept('decorator-holiday-%d-ending' % ToontownGlobals.CRASHED_LEADERBOARD, self.showLists)
|
||||||
self.accept('decorator-holiday-%d-starting' % ToontownGlobals.CRASHED_LEADERBOARD, self.hideLists)
|
self.accept('decorator-holiday-%d-starting' % ToontownGlobals.CRASHED_LEADERBOARD, self.hideLists)
|
||||||
newsManager = base.cr.newsManager
|
newsManager = base.cr.newsManager
|
||||||
|
@ -72,7 +72,7 @@ class DistributedLeaderBoard(DistributedObject.DistributedObject):
|
||||||
z = zListTop
|
z = zListTop
|
||||||
self.nameTextNodes = []
|
self.nameTextNodes = []
|
||||||
self.timeTextNodes = []
|
self.timeTextNodes = []
|
||||||
for i in range(10):
|
for _ in range(10):
|
||||||
row, nameText, timeText, placeText = self.buildLeaderRow()
|
row, nameText, timeText, placeText = self.buildLeaderRow()
|
||||||
self.nameTextNodes.append(nameText)
|
self.nameTextNodes.append(nameText)
|
||||||
placeText.setText(str(len(self.nameTextNodes)) + '.')
|
placeText.setText(str(len(self.nameTextNodes)) + '.')
|
||||||
|
@ -81,6 +81,7 @@ class DistributedLeaderBoard(DistributedObject.DistributedObject):
|
||||||
if len(self.nameTextNodes) == 6:
|
if len(self.nameTextNodes) == 6:
|
||||||
z = zListTop
|
z = zListTop
|
||||||
x = 0.35
|
x = 0.35
|
||||||
|
|
||||||
row.setX(x)
|
row.setX(x)
|
||||||
row.setZ(z)
|
row.setZ(z)
|
||||||
row.setY(1.6)
|
row.setY(1.6)
|
||||||
|
@ -105,7 +106,7 @@ class DistributedLeaderBoard(DistributedObject.DistributedObject):
|
||||||
self.timeTextNodes[i].setText('%02d:%02d:%02d' % (min, sec, hundredths * 100))
|
self.timeTextNodes[i].setText('%02d:%02d:%02d' % (min, sec, hundredths * 100))
|
||||||
|
|
||||||
def buildTitleRow(self):
|
def buildTitleRow(self):
|
||||||
row = hidden.attachNewNode('TitleRow')
|
row = base.hidden.attachNewNode('TitleRow')
|
||||||
nameText = TextNode('titleRow')
|
nameText = TextNode('titleRow')
|
||||||
nameText.setFont(ToontownGlobals.getSignFont())
|
nameText.setFont(ToontownGlobals.getSignFont())
|
||||||
nameText.setAlign(TextNode.ACenter)
|
nameText.setAlign(TextNode.ACenter)
|
||||||
|
@ -117,7 +118,7 @@ class DistributedLeaderBoard(DistributedObject.DistributedObject):
|
||||||
return (row, nameText)
|
return (row, nameText)
|
||||||
|
|
||||||
def buildTrackRow(self):
|
def buildTrackRow(self):
|
||||||
row = hidden.attachNewNode('trackRow')
|
row = base.hidden.attachNewNode('trackRow')
|
||||||
nameText = TextNode('trackRow')
|
nameText = TextNode('trackRow')
|
||||||
nameText.setFont(ToontownGlobals.getSignFont())
|
nameText.setFont(ToontownGlobals.getSignFont())
|
||||||
nameText.setAlign(TextNode.ACenter)
|
nameText.setAlign(TextNode.ACenter)
|
||||||
|
@ -129,7 +130,7 @@ class DistributedLeaderBoard(DistributedObject.DistributedObject):
|
||||||
return (row, nameText)
|
return (row, nameText)
|
||||||
|
|
||||||
def buildLeaderRow(self):
|
def buildLeaderRow(self):
|
||||||
row = hidden.attachNewNode('leaderRow')
|
row = base.hidden.attachNewNode('leaderRow')
|
||||||
nameText = TextNode('nameText')
|
nameText = TextNode('nameText')
|
||||||
nameText.setFont(ToontownGlobals.getToonFont())
|
nameText.setFont(ToontownGlobals.getToonFont())
|
||||||
nameText.setAlign(TextNode.ALeft)
|
nameText.setAlign(TextNode.ALeft)
|
||||||
|
@ -166,4 +167,4 @@ class DistributedLeaderBoard(DistributedObject.DistributedObject):
|
||||||
self.notify.debug('delete: deleting local leaderboard')
|
self.notify.debug('delete: deleting local leaderboard')
|
||||||
self.ignoreAll()
|
self.ignoreAll()
|
||||||
self.board.removeNode()
|
self.board.removeNode()
|
||||||
DistributedObject.DistributedObject.delete(self)
|
DistributedObject.delete(self)
|
||||||
|
|
Loading…
Reference in a new issue