DANIEL: Tag game

This commit is contained in:
John 2015-05-25 12:31:46 +03:00 committed by Loudrob
parent 65808d27a9
commit a1b996ea49
7 changed files with 155 additions and 50 deletions

View file

@ -4,12 +4,11 @@ from DistributedMinigame import *
from direct.interval.IntervalGlobal import *
from direct.fsm import ClassicFSM, State
from direct.fsm import State
from toontown.safezone import Walk
from toontown.safezone import Walk, SnowUtil
from toontown.toonbase import ToontownTimer
from direct.gui import OnscreenText
import MinigameAvatarScorePanel
from direct.distributed import DistributedSmoothNode
import random
from toontown.toonbase import ToontownGlobals
from toontown.toonbase import TTLocalizer
from otp.otpbase import OTPGlobals
@ -27,10 +26,6 @@ class DistributedTagGame(DistributedMinigame):
self.addChildGameFSM(self.gameFSM)
self.walkStateData = Walk.Walk('walkDone')
self.scorePanels = []
self.initialPositions = ((0, 10, 0, 180, 0, 0),
(10, 0, 0, 90, 0, 0),
(0, -10, 0, 0, 0, 0),
(-10, 0, 0, -90, 0, 0))
base.localAvatar.isIt = 0
self.modelCount = 4
@ -48,15 +43,19 @@ class DistributedTagGame(DistributedMinigame):
DistributedMinigame.load(self)
self.itText = OnscreenText.OnscreenText('itText', fg=(0.95, 0.95, 0.65, 1), scale=0.14, font=ToontownGlobals.getSignFont(), pos=(0.0, -0.8), wordwrap=15, mayChange=1)
self.itText.hide()
self.sky = loader.loadModel('phase_3.5/models/props/TT_sky')
self.groundList = ['phase_4/models/minigames/tag_arena', 'phase_6/models/neighborhoods/minnies_melody_land', 'phase_8/models/neighborhoods/the_burrrgh' 'phase_8/models/neighborhoods/daisys_garden']
self.groundRandom = random.choice(self.groundList)
self.ground = self.groundRandom
safezoneId = self.getSafezoneId()
self.sky = loader.loadModel(TagGameGlobals.getSky(safezoneId))
self.ground = loader.loadModel(TagGameGlobals.getGround(safezoneId))
self.music = base.loadMusic('phase_4/audio/bgm/MG_toontag.ogg')
self.tagSfx = base.loadSfx('phase_4/audio/sfx/MG_Tag_C.ogg')
self.itPointer = loader.loadModel('phase_4/models/minigames/bboard-pointer')
self.tracks = []
self.initialPositions = TagGameGlobals.getDropPoints(safezoneId)
self.IT = None
if TagGameGlobals.isSnowHood(safezoneId):
self.snow, self.snowRender = SnowUtil.createSnow(self.ground)
return
def unload(self):
@ -77,6 +76,14 @@ class DistributedTagGame(DistributedMinigame):
del self.itText
self.removeChildGameFSM(self.gameFSM)
del self.gameFSM
self.destroySnow()
def destroySnow(self):
if hasattr(self, 'snow'):
self.snow.cleanup()
self.snowRender.removeNode()
del self.snow
del self.snowRender
def onstage(self):
self.notify.debug('onstage')
@ -94,6 +101,10 @@ class DistributedTagGame(DistributedMinigame):
NametagGlobals.setWant2dNametags(True)
DistributedSmoothNode.activateSmoothing(1, 1)
self.IT = None
if hasattr(self, 'snow'):
self.snow.start(camera, self.snowRender)
return
def offstage(self):

View file

@ -3,6 +3,7 @@ from TagTreasurePlannerAI import *
from direct.fsm import ClassicFSM, State
from direct.fsm import State
from direct.task import Task
from toontown.safezone import TreasureGlobals
import random
import TagGameGlobals
@ -19,6 +20,7 @@ class DistributedTagGameAI(DistributedMinigameAI):
self.addChildGameFSM(self.gameFSM)
self.treasureScores = {}
self.itAvId = None
self.healAmount = 3
self.tagBack = 1
return
@ -60,11 +62,15 @@ class DistributedTagGameAI(DistributedMinigameAI):
self.notify.debug('enterPlay')
self.b_setIt(random.choice(self.avIdList))
taskMgr.doMethodLater(self.DURATION, self.timerExpired, self.taskName('gameTimer'))
self.tagTreasurePlanner = TagTreasurePlannerAI(self.zoneId, self, self.treasureGrabCallback)
self.tagTreasurePlanner.placeRandomTreasure()
self.tagTreasurePlanner.placeRandomTreasure()
self.tagTreasurePlanner.placeRandomTreasure()
self.tagTreasurePlanner.placeRandomTreasure()
safezoneId = self.getSafezoneId()
if safezoneId in TreasureGlobals.SafeZoneTreasureSpawns:
treasureType, self.healAmount, spawnPoints, spawnRate, maxTreasures = TreasureGlobals.SafeZoneTreasureSpawns[safezoneId]
else:
treasureType, self.healAmount = TreasureGlobals.TreasureTT, 3
self.tagTreasurePlanner = TagTreasurePlannerAI(self.zoneId, self, self.treasureGrabCallback, treasureType, TagGameGlobals.getTreasurePoints(safezoneId))
self.tagTreasurePlanner.start()
def timerExpired(self, task):
@ -91,7 +97,7 @@ class DistributedTagGameAI(DistributedMinigameAI):
if avId not in self.avIdList:
self.air.writeServerEvent('suspicious', avId, 'TagGameAI.treasureGrabCallback non-player avId')
return
self.treasureScores[avId] += 2
self.treasureScores[avId] += self.healAmount
self.notify.debug('treasureGrabCallback: ' + str(avId) + ' grabbed a treasure, new score: ' + str(self.treasureScores[avId]))
self.scoreDict[avId] = self.treasureScores[avId]
treasureScoreParams = []
@ -129,4 +135,4 @@ class DistributedTagGameAI(DistributedMinigameAI):
self.sendUpdate('setIt', [avId])
def setIt(self, avId):
self.itAvId = avId
self.itAvId = avId

View file

@ -1 +1,104 @@
DURATION = 60
from toontown.toonbase import ToontownGlobals
DURATION = 90
DEFAULT_SKY = 'phase_3.5/models/props/TT_sky'
DEFAULT_GROUND = 'phase_4/models/minigames/tag_arena'
DEFAULT_TREASURE_POINTS = [
(0, 0, 0.1),
(5, 20, 0.1),
(0, 40, 0.1),
(-5, -20, 0.1),
(0, -40, 0.1),
(20, 0, 0.1),
(40, 5, 0.1),
(-20, -5, 0.1),
(-40, 0, 0.1),
(22, 20, 0.1),
(-20, 22, 0.1),
(20, -20, 0.1),
(-25, -20, 0.1),
(20, 40, 0.1),
(20, -44, 0.1),
(-24, 40, 0.1),
(-20, -40, 0.1)]
DEFAULT_DROP_POINTS = (
(0, 10, 0.25, 180, 0, 0),
(10, 0, 0.25, 90, 0, 0),
(0, -10, 0.25, 0, 0, 0),
(-10, 0, 0.25, -90, 0, 0)
)
SKY = {
ToontownGlobals.TheBrrrgh: 'phase_3.5/models/props/BR_sky'
}
GROUND = {
ToontownGlobals.TheBrrrgh: 'phase_8/models/minigames/tag_arena_BR',
ToontownGlobals.DaisyGardens: 'phase_8/models/minigames/tag_arena_DG'
}
TREASURE_POINTS = {
ToontownGlobals.TheBrrrgh: [
(-27, -30.7, 10.4),
(0.2, -33.6, 2.5),
(-60.9, -36.6, 2.7),
(-59.3, -9.04, 0.31),
(-78.4, 2.7, 4.2),
(-37.8, 2.1, 3.7),
(-28.6, 35.8, 11.6),
(7.7, 5.8, 2.4),
(41.5, -30.1, 14.2),
(37.8, 32.1, 11.7),
(2.8, 51.1, 3),
(-16.8, 0.6, 2.2),
(-72.4, 37.7, 5)
],
ToontownGlobals.DaisyGardens: [
(21.3, 27.6, 0.025),
(30.4, -8.4, 0.025),
(0.5, -36.3, 0.025),
(-34.9, -10.4, 0.025),
(-35.3, -34.3, 0.025),
(-33.3, -54, 0.025),
(41.6, -39.4, 0.025),
(19.0, -41.2, 0.025),
(0.5, 61.3, 0.025),
(-24.4, 52.1, 0.025),
(-49.9, 24.2, 0.025),
(-43.8, 8.4, 0.025)
]
}
DROP_POINTS = {
ToontownGlobals.TheBrrrgh: (
(-30.4, 37.5, 11.1, 2006, 0, 0),
(34.7, -21.5, 12.5, 1875, 0, 0),
(-31.9, -29.4, 10, 1774),
(-74.1, -30.5, 5.3, 1720)
),
ToontownGlobals.DaisyGardens: (
(38.6, -55.1, 0.025, 396, 0, 0),
(3.1, 54, 0.025, 898, 0, 0),
(-37.8, -49.4, 0.025, 685, 0, 0),
(-55.9, 21, 0.025, 608, 0, 0)
)
}
SNOW_HOODS = [ToontownGlobals.TheBrrrgh]
def getSky(safezoneId):
return SKY.get(safezoneId, DEFAULT_SKY)
def getGround(safezoneId):
return GROUND.get(safezoneId, DEFAULT_GROUND)
def getTreasurePoints(safezoneId):
return TREASURE_POINTS.get(safezoneId, DEFAULT_TREASURE_POINTS)
def getDropPoints(safezoneId):
return DROP_POINTS.get(safezoneId, DEFAULT_DROP_POINTS)
def isSnowHood(safezoneId):
return safezoneId in SNOW_HOODS

View file

@ -1,36 +1,17 @@
from direct.directnotify import DirectNotifyGlobal
from toontown.toonbase.ToontownGlobals import *
from toontown.safezone import RegenTreasurePlannerAI
from toontown.safezone import TreasureGlobals
class TagTreasurePlannerAI(RegenTreasurePlannerAI.RegenTreasurePlannerAI):
notify = DirectNotifyGlobal.directNotify.newCategory('TagTreasurePlannerAI')
def __init__(self, zoneId, game, callback):
def __init__(self, zoneId, game, callback, treasureType, spawnPoints):
self.numPlayers = 0
self.game = game
RegenTreasurePlannerAI.RegenTreasurePlannerAI.__init__(self, zoneId, TreasureGlobals.TreasureTT, 'TagTreasurePlanner-' + str(zoneId), 3, 4, callback)
return None
self.spawnPoints = spawnPoints
RegenTreasurePlannerAI.RegenTreasurePlannerAI.__init__(self, zoneId, treasureType, 'TagTreasurePlanner-' + str(zoneId), 3, 6, callback)
def initSpawnPoints(self):
self.spawnPoints = [(0, 0, 0.1),
(5, 20, 0.1),
(0, 40, 0.1),
(-5, -20, 0.1),
(0, -40, 0.1),
(20, 0, 0.1),
(40, 5, 0.1),
(-20, -5, 0.1),
(-40, 0, 0.1),
(22, 20, 0.1),
(-20, 22, 0.1),
(20, -20, 0.1),
(-25, -20, 0.1),
(20, 40, 0.1),
(20, -44, 0.1),
(-24, 40, 0.1),
(-20, -40, 0.1)]
return self.spawnPoints
def validAvatar(self, treasure, av):
return av.doId != self.game.itAvId
return av.doId != self.game.itAvId

View file

@ -1,7 +1,6 @@
from toontown.battle import BattleParticles
from toontown.safezone import BRPlayground
from toontown.safezone import SafeZoneLoader
import SnowUtil
class BRSafeZoneLoader(SafeZoneLoader.SafeZoneLoader):
def __init__(self, hood, parentFSM, doneEvent):
@ -17,11 +16,7 @@ class BRSafeZoneLoader(SafeZoneLoader.SafeZoneLoader):
self.windSound = map(base.loadSfx, ['phase_8/audio/sfx/SZ_TB_wind_1.ogg',
'phase_8/audio/sfx/SZ_TB_wind_2.ogg',
'phase_8/audio/sfx/SZ_TB_wind_3.ogg'])
self.snow = BattleParticles.loadParticleFile('snowdisk.ptf')
self.snow.setPos(0, 0, 5)
self.snowRender = self.geom.attachNewNode('snowRender')
self.snowRender.setDepthWrite(0)
self.snowRender.setBin('fixed', 1)
self.snow, self.snowRender = SnowUtil.createSnow(self.geom)
def unload(self):
SafeZoneLoader.SafeZoneLoader.unload(self)

View file

@ -35,10 +35,9 @@ class RegenTreasurePlannerAI(TreasurePlannerAI.TreasurePlannerAI):
return Task.done
def placeRandomTreasure(self):
self.notify.debug('Placing a Treasure...')
spawnPointIndex = self.nthEmptyIndex(random.randrange(self.countEmptySpawnPoints()))
self.placeTreasure(spawnPointIndex)
def preSpawnTreasures(self):
for i in xrange(self.maxTreasures):
self.placeRandomTreasure()
self.placeRandomTreasure()

View file

@ -0,0 +1,10 @@
from toontown.battle import BattleParticles
def createSnow(geom):
snow = BattleParticles.loadParticleFile('snowdisk.ptf')
snow.setPos(0, 0, 5)
snowRender = geom.attachNewNode('snowRender')
snowRender.setDepthWrite(0)
snowRender.setBin('fixed', 1)
return snow, snowRender