Poodletooth-iLand/toontown/toon/DistributedNPCGlove.py

77 lines
2.7 KiB
Python
Raw Normal View History

2015-05-25 06:29:48 -05:00
from toontown.chat.ChatGlobals import CFSpeech, CFTimeout
2015-03-08 08:01:05 -05:00
from toontown.toonbase import TTLocalizer, ToontownGlobals
2015-05-25 06:29:48 -05:00
from toontown.toon import NPCToons
from DistributedNPCToonBase import DistributedNPCToonBase
import GloveNPCGlobals, GloveShopGui, time
class DistributedNPCGlove(DistributedNPCToonBase):
2015-05-25 06:29:48 -05:00
def __init__(self, cr):
DistributedNPCToonBase.__init__(self, cr)
2015-05-25 06:29:48 -05:00
self.lastCollision = 0
self.gloveDialog = None
def disable(self):
self.ignoreAll()
2015-05-25 06:29:48 -05:00
self.destroyDialog()
DistributedNPCToonBase.disable(self)
2015-05-11 14:05:59 -05:00
2015-05-25 06:29:48 -05:00
def destroyDialog(self):
self.clearChat()
2015-05-11 14:05:59 -05:00
2015-05-25 06:29:48 -05:00
if self.gloveDialog:
self.gloveDialog.destroy()
self.gloveDialog = None
def initToonState(self):
2015-05-25 06:29:48 -05:00
self.setAnimState('neutral', 0.9, None, None)
if self.name in NPCToons.GlovePositions:
pos = NPCToons.GlovePositions[self.name]
self.setPos(*pos[0])
self.setH(pos[1])
def getCollSphereRadius(self):
2015-05-25 06:29:48 -05:00
return 1.25
def handleCollisionSphereEnter(self, collEntry):
2015-05-25 06:29:48 -05:00
if self.lastCollision > time.time():
return
self.lastCollision = time.time() + ToontownGlobals.NPCCollisionDelay
2015-05-11 14:05:59 -05:00
if base.localAvatar.getTotalMoney() < ToontownGlobals.GloveCost:
2015-05-25 06:29:48 -05:00
self.setChatAbsolute(TTLocalizer.GloveMoreMoneyMessage % ToontownGlobals.GloveCost, CFSpeech|CFTimeout)
return
2015-05-25 06:29:48 -05:00
base.cr.playGame.getPlace().fsm.request('stopped')
base.setCellsActive(base.bottomCells, 0)
self.setChatAbsolute(TTLocalizer.GlovePickColorMessage, CFSpeech|CFTimeout)
self.acceptOnce('gloveShopDone', self.__gloveShopDone)
self.gloveDialog = GloveShopGui.GloveShopGui()
def freeAvatar(self):
base.cr.playGame.getPlace().fsm.request('walk')
base.setCellsActive(base.bottomCells, 1)
2015-05-25 06:29:48 -05:00
def __gloveShopDone(self, state, glove):
self.freeAvatar()
2015-05-25 06:29:48 -05:00
if state == GloveNPCGlobals.TIMER_END:
self.setChatAbsolute(TTLocalizer.STOREOWNER_TOOKTOOLONG, CFSpeech|CFTimeout)
return
elif state == GloveNPCGlobals.USER_CANCEL:
self.setChatAbsolute(TTLocalizer.STOREOWNER_GOODBYE, CFSpeech|CFTimeout)
return
elif state == GloveNPCGlobals.CHANGE:
self.sendUpdate('changeGlove', [glove])
def changeGloveResult(self, avId, state):
if state in GloveNPCGlobals.ChangeMessages:
self.setChatAbsolute(GloveNPCGlobals.ChangeMessages[state], CFSpeech|CFTimeout)
if state == GloveNPCGlobals.CHANGE_SUCCESSFUL:
av = self.cr.doId2do.get(avId)
if av:
av.getDustCloud().start()