def __init__(self): __metaclass__ = ABCMeta DirectObject.__init__(self) BaseAttack.__init__(self) self.avatar = None self.gag = None self.target = None self.splat = None self.splatPos = None self.state = GagState.LOADED self.woosh = None self.handJoint = None self.equipped = False self.index = None self.id = GagGlobals.getIDByName(self.name) self.timeout = 5 self.animTrack = None self.holdGag = True # Handles the new recharging for certain gags. # The time it takes (in seconds) to recharge this gag. self.rechargeTime = 0 # The elapsed time of the current recharge. Should be a float self.rechargeElapsedTime = 0 if metadata.PROCESS == 'client': if self.gagType == GagType.THROW: self.woosh = base.audio3d.loadSfx(GagGlobals.PIE_WOOSH_SFX) self.hitSfx = base.audio3d.loadSfx(self.hitSfxPath) self.drawSfx = base.audio3d.loadSfx(GagGlobals.DEFAULT_DRAW_SFX)
def onHit(self, pos, intoNP): BaseProjectile.onHit(self, pos, intoNP) WATER_SPRAY_COLOR = Point4(0.3, 0.7, 0.9, 0.7) CIGlobals.makeSplat(pos, WATER_SPRAY_COLOR, 0.3) if self.local: avNP = intoNP.getParent() for obj in base.avatars: if CIGlobals.isAvatar(obj) and obj.getKey() == avNP.getKey(): gid = GagGlobals.getIDByName(GagGlobals.WaterGun) obj.handleHitByToon(base.localAvatar, gid, (self.getPos(render) - self.initialPos).length()) self.removeNode()
def __makeGagButton(self, gagName, trackName): gui = loader.loadModel('phase_3.5/models/gui/inventory_gui.bam') icons = loader.loadModel('phase_3.5/models/gui/inventory_icons.bam') icon = icons.find(GagGlobals.InventoryIconByName[gagName]) index = GagGlobals.TrackGagNamesByTrackName[trackName].index(gagName) xValue = GagButtonXValues[index] gagId = GagGlobals.getIDByName(gagName) button = DirectButton( relief=None, image=(gui.find('**/InventoryButtonUp'), gui.find('**/InventoryButtonDown'), gui.find('**/InventoryButtonRollover'), gui.find('**/InventoryButtonFlat')), geom=icon, geom_scale=0.6, parent=self.trackByName[trackName], text=str(base.localAvatar.getBackpack().getSupply(gagId)), text_align=TextNode.ARight, text_scale=0.04, text_fg=Vec4(1, 1, 1, 1), text_pos=(0.07, -0.04)) button.setX(xValue) self.gagButtonByName[gagName] = button