Fireworks

This commit is contained in:
John 2015-06-25 21:20:15 +03:00
parent 144856d30a
commit 721a28d9cf
8 changed files with 85 additions and 29 deletions

View file

@ -65,10 +65,10 @@ Holidays = {
'effectDelay': 10 'effectDelay': 10
}, },
ToontownGlobals.CHRISTMAS: { ToontownGlobals.CHRISTMAS: {
"""'startMonth': 12, 'startMonth': 12,
'startDay': 14, 'startDay': 14,
'endMonth': 1, 'endMonth': 1,
'endDay': 4,""" 'endDay': 4,
'startMessage': TTLocalizer.WinterCarolingStart, 'startMessage': TTLocalizer.WinterCarolingStart,
'ongoingMessage': TTLocalizer.WinterCarolingStart, 'ongoingMessage': TTLocalizer.WinterCarolingStart,
'endMessage': TTLocalizer.WinterCarolingEnd, 'endMessage': TTLocalizer.WinterCarolingEnd,
@ -87,6 +87,24 @@ Holidays = {
'speedchatIndexes': [10003], 'speedchatIndexes': [10003],
'effectDelay': 15, 'effectDelay': 15,
'scavengerHunt': TRICK_OR_TREAT 'scavengerHunt': TRICK_OR_TREAT
},
ToontownGlobals.SUMMER_FIREWORKS: {
'startMonth': 6,
'startDay': 30,
'endMonth': 7,
'endDay': 15,
'startMessage': TTLocalizer.SummerFireworksStart,
'ongoingMessage': TTLocalizer.SummerFireworksStart,
'endMessage': TTLocalizer.SummerFireworksEnd
},
ToontownGlobals.NEW_YEAR_FIREWORKS: {
'startMonth': 12,
'startDay': 31,
'endMonth': 1,
'endDay': 7,
'startMessage': TTLocalizer.NewYearFireworksStart,
'ongoingMessage': TTLocalizer.NewYearFireworksStart,
'endMessage': TTLocalizer.NewYearFireworksEnd
} }
} }

View file

@ -1,14 +1,19 @@
from direct.distributed.DistributedObjectAI import DistributedObjectAI from direct.distributed.DistributedObjectAI import DistributedObjectAI
from direct.distributed.ClockDelta import globalClockDelta
from direct.task import Task from direct.task import Task
from datetime import datetime from toontown.effects.DistributedFireworkShowAI import DistributedFireworkShowAI
from toontown.effects import FireworkShows
from toontown.toonbase import ToontownGlobals from toontown.toonbase import ToontownGlobals
from toontown.parties import PartyGlobals
import HolidayGlobals import HolidayGlobals
import datetime, random
class NewsManagerAI(DistributedObjectAI): class NewsManagerAI(DistributedObjectAI):
def __init__(self, air): def __init__(self, air):
DistributedObjectAI.__init__(self, air) DistributedObjectAI.__init__(self, air)
self.activeHolidays = [] self.activeHolidays = []
self.fireworkTask = None
def announceGenerate(self): def announceGenerate(self):
DistributedObjectAI.announceGenerate(self) DistributedObjectAI.announceGenerate(self)
@ -19,27 +24,39 @@ class NewsManagerAI(DistributedObjectAI):
def delete(self): def delete(self):
DistributedObjectAI.delete(self) DistributedObjectAI.delete(self)
taskMgr.remove(self.checkTask) taskMgr.remove(self.checkTask)
self.deleteFireworkTask()
def deleteFireworkTask(self):
if self.fireworkTask:
taskMgr.remove(self.fireworkTask)
self.fireworkTask = None
def __handleAvatarEntered(self, av): def __handleAvatarEntered(self, av):
self.sendUpdateToAvatarId(av.getDoId(), 'setActiveHolidays', [self.activeHolidays]) self.sendUpdateToAvatarId(av.getDoId(), 'setActiveHolidays', [self.activeHolidays])
def getActiveHolidays(self): def getActiveHolidays(self):
return self.activeHolidays return self.activeHolidays
def __checkHolidays(self, task=None): def __checkHolidays(self, task=None):
date = datetime.now() date = datetime.datetime.utcnow().replace(tzinfo=HolidayGlobals.TIME_ZONE)
for id in HolidayGlobals.Holidays: for id in HolidayGlobals.Holidays:
holiday = HolidayGlobals.Holidays[id] holiday = HolidayGlobals.Holidays[id]
running = self.isHolidayRunning(id) running = self.isHolidayRunning(id)
if ('weekDay' not in holiday or date.weekday() == holiday['weekDay']) and ('startMonth' not in holiday or holiday['startMonth'] <= date.month <= holiday['endMonth']) and ('startDay' not in holiday or holiday['startDay'] <= date.day <= holiday['endDay']): if self.isHolidayInRange(holiday, date):
if not running: if not running:
self.startHoliday(id) self.startHoliday(id)
elif running: elif running:
self.endHoliday(id) self.endHoliday(id)
return Task.again return Task.again
def isHolidayInRange(self, holiday, date):
if 'weekDay' in holiday:
return holiday['weekDay'] == date.weekday()
else:
return HolidayGlobals.getStartDate(holiday) <= date <= HolidayGlobals.getEndDate(holiday)
def isHolidayRunning(self, id): def isHolidayRunning(self, id):
return id in self.activeHolidays return id in self.activeHolidays
@ -63,7 +80,26 @@ class NewsManagerAI(DistributedObjectAI):
def startSpecialHoliday(self, id): def startSpecialHoliday(self, id):
if id == ToontownGlobals.FISH_BINGO or id == ToontownGlobals.SILLY_SATURDAY: if id == ToontownGlobals.FISH_BINGO or id == ToontownGlobals.SILLY_SATURDAY:
messenger.send('checkBingoState') messenger.send('checkBingoState')
elif id in [ToontownGlobals.SUMMER_FIREWORKS, ToontownGlobals.NEW_YEAR_FIREWORKS]:
if not self.fireworkTask:
self.fireworkTask = taskMgr.doMethodLater(3600, self.startFireworks, 'newsFireworkTask', extraArgs=[id, Task.again])
taskMgr.doMethodLater(10, self.startFireworks, 'newsFireworkTask-initial', extraArgs=[id, Task.done])
def endSpecialHoliday(self, id): def endSpecialHoliday(self, id):
if id == ToontownGlobals.FISH_BINGO or id == ToontownGlobals.SILLY_SATURDAY: if id == ToontownGlobals.FISH_BINGO or id == ToontownGlobals.SILLY_SATURDAY:
messenger.send('checkBingoState') messenger.send('checkBingoState')
elif id in [ToontownGlobals.SUMMER_FIREWORKS, ToontownGlobals.NEW_YEAR_FIREWORKS]:
self.deleteFireworkTask()
def startFireworks(self, type, again, task=None):
maxShow = len(FireworkShows.shows.get(type, [])) - 1
for hood in self.air.hoods:
if hood.zoneId == ToontownGlobals.GolfZone:
continue
fireworkShow = DistributedFireworkShowAI(self.air)
fireworkShow.generateWithRequired(hood.zoneId)
fireworkShow.b_startShow(type, random.randint(0, maxShow), globalClockDelta.getRealNetworkTime())
return again

View file

@ -43,9 +43,9 @@ def fireworks(showName='july4'):
""" """
showName = showName.lower() showName = showName.lower()
if showName == 'july4': if showName == 'july4':
showType = ToontownGlobals.JULY4_FIREWORKS showType = ToontownGlobals.SUMMER_FIREWORKS
elif showName == 'newyears': elif showName == 'newyears':
showType = ToontownGlobals.NEWYEARS_FIREWORKS showType = ToontownGlobals.NEW_YEAR_FIREWORKS
elif showName == 'summer': elif showName == 'summer':
showType = PartyGlobals.FireworkShows.Summer showType = PartyGlobals.FireworkShows.Summer
else: else:

View file

@ -15,9 +15,9 @@ colors = [Vec4(1, 1, 1, 1),
Vec4(1, 0.1, 1, 1), Vec4(1, 0.1, 1, 1),
Vec4(0.1, 1, 1, 1), Vec4(0.1, 1, 1, 1),
Vec4(0.1, 0.5, 1, 1)] Vec4(0.1, 0.5, 1, 1)]
fireworkShowTypes = [ToontownGlobals.JULY4_FIREWORKS, fireworkShowTypes = [ToontownGlobals.SUMMER_FIREWORKS,
PartyGlobals.FireworkShows.Summer, PartyGlobals.FireworkShows.Summer,
ToontownGlobals.NEWYEARS_FIREWORKS, ToontownGlobals.NEW_YEAR_FIREWORKS,
ToontownGlobals.COMBO_FIREWORKS] ToontownGlobals.COMBO_FIREWORKS]
class FireworkShow(NodePath): class FireworkShow(NodePath):
@ -43,7 +43,7 @@ class FireworkShow(NodePath):
def rD(): def rD():
return random.randint(1, 20) / 10.0 return random.randint(1, 20) / 10.0
showData = {ToontownGlobals.JULY4_FIREWORKS: [[FireworkType.GlowFlare, showData = {ToontownGlobals.SUMMER_FIREWORKS: [[FireworkType.GlowFlare,
Vec3(-90, 0, 80), Vec3(-90, 0, 80),
Vec3(120, 0, 0), Vec3(120, 0, 0),
rS(), rS(),
@ -739,7 +739,7 @@ class FireworkShow(NodePath):
Vec4(1, 1, 1, 1), Vec4(1, 1, 1, 1),
1.5, 1.5,
10.0]], 10.0]],
ToontownGlobals.NEWYEARS_FIREWORKS: [[FireworkType.GlowFlare, ToontownGlobals.NEW_YEAR_FIREWORKS: [[FireworkType.GlowFlare,
Vec3(0, 0, 180), Vec3(0, 0, 180),
Vec3(-120, 0, 0), Vec3(-120, 0, 0),
rS(), rS(),
@ -1075,10 +1075,10 @@ class FireworkShow(NodePath):
rC(), rC(),
2.0, 2.0,
10.0]]} 10.0]]}
showData[ToontownGlobals.COMBO_FIREWORKS] = showData[ToontownGlobals.NEWYEARS_FIREWORKS] showData[ToontownGlobals.COMBO_FIREWORKS] = showData[ToontownGlobals.NEW_YEAR_FIREWORKS]
sectionData = {ToontownGlobals.JULY4_FIREWORKS: [(0, 24), (24, len(showData[ToontownGlobals.JULY4_FIREWORKS]))], sectionData = {ToontownGlobals.SUMMER_FIREWORKS: [(0, 24), (24, len(showData[ToontownGlobals.SUMMER_FIREWORKS]))],
PartyGlobals.FireworkShows.Summer: [(0, 24), (24, len(showData[PartyGlobals.FireworkShows.Summer]))], PartyGlobals.FireworkShows.Summer: [(0, 24), (24, len(showData[PartyGlobals.FireworkShows.Summer]))],
ToontownGlobals.NEWYEARS_FIREWORKS: [(0, len(showData[PartyGlobals.FireworkShows.Summer]))], ToontownGlobals.NEW_YEAR_FIREWORKS: [(0, len(showData[PartyGlobals.FireworkShows.Summer]))],
ToontownGlobals.COMBO_FIREWORKS: [(0, len(showData[PartyGlobals.FireworkShows.Summer]))]} ToontownGlobals.COMBO_FIREWORKS: [(0, len(showData[PartyGlobals.FireworkShows.Summer]))]}
showMusic = {} showMusic = {}
@ -1089,7 +1089,7 @@ class FireworkShow(NodePath):
else: else:
return False return False
def __init__(self, showType = ToontownGlobals.NEWYEARS_FIREWORKS): def __init__(self, showType = ToontownGlobals.NEW_YEAR_FIREWORKS):
NodePath.__init__(self, 'FireworkShow') NodePath.__init__(self, 'FireworkShow')
self.showType = showType self.showType = showType
self.sectionIvals = [] self.sectionIvals = []

View file

@ -19,7 +19,7 @@ class FireworkShowMixin:
self.startDelay = startDelay self.startDelay = startDelay
self.timestamp = None self.timestamp = None
self.fireworkShow = None self.fireworkShow = None
self.eventId = JULY4_FIREWORKS self.eventId = SUMMER_FIREWORKS
self.accept('MusicEnabled', self.startMusic) self.accept('MusicEnabled', self.startMusic)
return return
@ -77,13 +77,13 @@ class FireworkShowMixin:
return return
def preShow(self, eventId, songId, startT): def preShow(self, eventId, songId, startT):
if eventId == JULY4_FIREWORKS: if eventId == SUMMER_FIREWORKS:
instructionMessage = TTLocalizer.FireworksInstructions instructionMessage = TTLocalizer.FireworksInstructions
startMessage = TTLocalizer.FireworksJuly4Beginning startMessage = TTLocalizer.FireworksJuly4Beginning
endMessage = TTLocalizer.FireworksJuly4Ending endMessage = TTLocalizer.FireworksJuly4Ending
songs = ['tt_summer', 'firework_music'] songs = ['tt_summer', 'firework_music']
musicFile = 'phase_4/audio/bgm/%s.ogg' % songs[songId] musicFile = 'phase_4/audio/bgm/%s.ogg' % songs[songId]
elif eventId == NEWYEARS_FIREWORKS: elif eventId == NEW_YEAR_FIREWORKS:
instructionMessage = TTLocalizer.FireworksInstructions instructionMessage = TTLocalizer.FireworksInstructions
startMessage = TTLocalizer.FireworksNewYearsEveBeginning startMessage = TTLocalizer.FireworksNewYearsEveBeginning
endMessage = TTLocalizer.FireworksNewYearsEveEnding endMessage = TTLocalizer.FireworksNewYearsEveEnding
@ -146,9 +146,9 @@ class FireworkShowMixin:
base.camLens.setFar(DefaultCameraFar) base.camLens.setFar(DefaultCameraFar)
def postShow(self, eventId): def postShow(self, eventId):
if eventId == JULY4_FIREWORKS: if eventId == SUMMER_FIREWORKS:
endMessage = TTLocalizer.FireworksJuly4Ending endMessage = TTLocalizer.FireworksJuly4Ending
elif eventId == NEWYEARS_FIREWORKS: elif eventId == NEW_YEAR_FIREWORKS:
endMessage = TTLocalizer.FireworksNewYearsEveEnding endMessage = TTLocalizer.FireworksNewYearsEveEnding
elif eventId == PartyGlobals.FireworkShows.Summer: elif eventId == PartyGlobals.FireworkShows.Summer:
endMessage = TTLocalizer.FireworksActivityEnding endMessage = TTLocalizer.FireworksActivityEnding

View file

@ -1,7 +1,7 @@
from FireworkGlobals import * from FireworkGlobals import *
from toontown.toonbase import ToontownGlobals from toontown.toonbase import ToontownGlobals
from toontown.parties import PartyGlobals from toontown.parties import PartyGlobals
shows = {ToontownGlobals.JULY4_FIREWORKS: [((2, shows = {ToontownGlobals.SUMMER_FIREWORKS: [((2,
ROCKET, ROCKET,
RED, RED,
RED, RED,
@ -5065,7 +5065,7 @@ shows = {ToontownGlobals.JULY4_FIREWORKS: [((2,
-23, -23,
3, 3,
100))], 100))],
ToontownGlobals.NEWYEARS_FIREWORKS: [((0.5, ToontownGlobals.NEW_YEAR_FIREWORKS: [((0.5,
ROCKET, ROCKET,
WHITE, WHITE,
WHITE, WHITE,

View file

@ -6879,7 +6879,6 @@ PetTrait2descriptions = {'hungerThreshold': ('Always Hungry',
'Often Affectionate', 'Often Affectionate',
'Always Affectionate')} 'Always Affectionate')}
FireworksInstructions = lToonHQ + ': Hit the "Page Up" key to see the show!' FireworksInstructions = lToonHQ + ': Hit the "Page Up" key to see the show!'
startFireworksResponse = "Usage: startFireworksShow ['num']\n 'num' = %s - New Years\n %s - Party Summer \n %s - 4th of July"
FireworksJuly4Beginning = lToonHQ + ': Welcome to summer fireworks! Enjoy the show!' FireworksJuly4Beginning = lToonHQ + ': Welcome to summer fireworks! Enjoy the show!'
FireworksJuly4Ending = lToonHQ + ': Hope you enjoyed the show! Have a great summer!' FireworksJuly4Ending = lToonHQ + ': Hope you enjoyed the show! Have a great summer!'
FireworksNewYearsEveBeginning = lToonHQ + ': Happy New Year! Enjoy the fireworks show, sponsored by Flippy!' FireworksNewYearsEveBeginning = lToonHQ + ': Happy New Year! Enjoy the fireworks show, sponsored by Flippy!'
@ -8222,6 +8221,10 @@ DayNamesAbbrev = ('MON',
'FRI', 'FRI',
'SAT', 'SAT',
'SUN') 'SUN')
SummerFireworksStart = 'Celebrate Summer with a fireworks show every hour in each playground!'
SummerFireworksEnd = 'Summer Fireworks are over. Hope you had fun.'
NewYearFireworksStart = 'Happy New Year! Enjoy a fireworks show every hour in each playground!'
NewYearFireworksEnd = 'New Year Fireworks are over. See you next year!'
HolidayNamesInCalendar = {1: ('Summer Fireworks', 'Celebrate Summer with a fireworks show every hour in each playground!'), HolidayNamesInCalendar = {1: ('Summer Fireworks', 'Celebrate Summer with a fireworks show every hour in each playground!'),
2: ('New Year Fireworks', 'Happy New Year! Enjoy a fireworks show every hour in each playground!'), 2: ('New Year Fireworks', 'Happy New Year! Enjoy a fireworks show every hour in each playground!'),
3: ('Halloween', 'Happy Halloween! Trick or treat throughout Toontown to get a nifty Halloween pumpkin head reward!'), 3: ('Halloween', 'Happy Halloween! Trick or treat throughout Toontown to get a nifty Halloween pumpkin head reward!'),

View file

@ -824,9 +824,8 @@ WaiterInvasionBulletin = 9
V2InvasionBegin = 10 V2InvasionBegin = 10
V2InvasionEnd = 11 V2InvasionEnd = 11
V2InvasionBulletin = 12 V2InvasionBulletin = 12
NO_HOLIDAY = 0 SUMMER_FIREWORKS = 1
JULY4_FIREWORKS = 1 NEW_YEAR_FIREWORKS = 2
NEWYEARS_FIREWORKS = 2
HALLOWEEN = 3 HALLOWEEN = 3
CHRISTMAS = 4 CHRISTMAS = 4
SKELECOG_INVASION = 5 SKELECOG_INVASION = 5