def removeAmmoSkill(self, skillId, useDefaultAmmo = False): index = -1 for i in range(len(PiratesGlobals.CANNON_DEFENSE_SKILLS)): if PiratesGlobals.CANNON_DEFENSE_SKILLS[i] == skillId: index = i break continue if index < 0: return False PiratesGlobals.CANNON_DEFENSE_SKILLS.remove(skillId) PiratesGlobals.CANNON_DEFENSE_SKILLS.insert(index, InventoryType.DefenseCannonEmpty) button = self.buttons[skillId] modifier = max(0, self.ammoQuantities[skillId] / float(CannonDefenseGlobals.getDefenseCannonAmmoAmount(skillId))) self._bankNotes += int(button.cost * modifier) self.updateBankNoteText() button.enablePurchase() base.localAvatar.guiMgr.combatTray.skillTray.updateSkillTray(InventoryType.DefenseCannonRep, WeaponGlobals.DEFENSE_CANNON, hideFirst = False) self.updateQuantities() if useDefaultAmmo and not self.hasAmmo(): self.onAmmoClick(InventoryType.DefenseCannonRoundShot) elif skillId == base.localAvatar.guiMgr.combatTray.getLastAmmoSkillId(): self.cannon.cgui.hideCannonControls() self.cannon.cgui.skillTray.show() if self.state == CLOSED and not self.hasAmmo(): self.onTabClick() self.ammoQuantities[skillId] = 0 return True
def __init__(self, callback, skillId, skillRank): if not AmmoPanelButton.SkillIcons: AmmoPanelButton.SkillIcons = loader.loadModel('models/textureCards/skillIcons') AmmoPanelButton.Image = (AmmoPanelButton.SkillIcons.find('**/base'), AmmoPanelButton.SkillIcons.find('**/base_down'), AmmoPanelButton.SkillIcons.find('**/base_over')) self.locked = True self.purchaseable = True self.cost = CannonDefenseGlobals.getDefenseCannonAmmoCost(skillId) self.amount = CannonDefenseGlobals.getDefenseCannonAmmoAmount(skillId) if self.amount == -1: self.amount = PLocalizer.Unlimited self.skillId = skillId self.skillRank = skillRank self.infoBox = None self.flashIval = None asset = RadialMenu.getSkillIconName(skillId, 0) geom = AmmoPanelButton.SkillIcons.find('**/%s' % asset) self.geom = geom if self.locked: asset = None geom = None DirectButton.__init__(self, relief = None, pos = (0, 0, 0), text = '?', text_scale = 0.10000000000000001, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_pos = (0.0050000000000000001, -0.035000000000000003), text_align = TextNode.ACenter, image = AmmoPanelButton.Image, image_scale = 0.12, geom = geom, geom_scale = 0.12, command = callback, textMayChange = 1, sortOrder = 70, extraArgs = [ skillId]) self.initialiseoptions(AmmoPanelButton) gui = loader.loadModel('models/gui/toplevel_gui') self.lockIcon = gui.find('**/pir_t_gui_gen_key_subscriber') if not Freebooter.getPaidStatus(base.localAvatar.doId) and skillId > CannonDefenseGlobals.FREEBOOTER_LAST_AMMO_AVAILABLE: self.lock = DirectFrame(parent = self, relief = None, image = self.lockIcon, image_scale = 0.14000000000000001, image_pos = (0.050000000000000003, 0, -0.025000000000000001), sortOrder = 99) self.bind(DGG.ENTER, self.showDetails) self.bind(DGG.EXIT, self.hideDetails)
def __init__(self, callback, skillId, skillRank): if not AmmoPanelButton.SkillIcons: AmmoPanelButton.SkillIcons = loader.loadModel( 'models/textureCards/skillIcons') AmmoPanelButton.Image = ( AmmoPanelButton.SkillIcons.find('**/base'), AmmoPanelButton.SkillIcons.find('**/base_down'), AmmoPanelButton.SkillIcons.find('**/base_over')) self.locked = True self.purchaseable = True self.cost = CannonDefenseGlobals.getDefenseCannonAmmoCost(skillId) self.amount = CannonDefenseGlobals.getDefenseCannonAmmoAmount(skillId) if self.amount == -1: self.amount = PLocalizer.Unlimited self.skillId = skillId self.skillRank = skillRank self.infoBox = None self.flashIval = None asset = RadialMenu.getSkillIconName(skillId, 0) geom = AmmoPanelButton.SkillIcons.find('**/%s' % asset) self.geom = geom if self.locked: asset = None geom = None DirectButton.__init__(self, relief=None, pos=(0, 0, 0), text='?', text_scale=0.1, text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, text_pos=(0.005, -0.035), text_align=TextNode.ACenter, image=AmmoPanelButton.Image, image_scale=0.12, geom=geom, geom_scale=0.12, command=callback, textMayChange=1, sortOrder=70, extraArgs=[skillId]) self.initialiseoptions(AmmoPanelButton) gui = loader.loadModel('models/gui/toplevel_gui') self.lockIcon = gui.find('**/pir_t_gui_gen_key_subscriber') if not Freebooter.getPaidStatus( base.localAvatar.doId ) and skillId > CannonDefenseGlobals.FREEBOOTER_LAST_AMMO_AVAILABLE: self.lock = DirectFrame(parent=self, relief=None, image=self.lockIcon, image_scale=0.14, image_pos=(0.05, 0, -0.025), sortOrder=99) self.bind(DGG.ENTER, self.showDetails) self.bind(DGG.EXIT, self.hideDetails) return
def addAmmoSkill(self, skillId): index = -1 for i in range(len(PiratesGlobals.CANNON_DEFENSE_SKILLS)): if PiratesGlobals.CANNON_DEFENSE_SKILLS[i] == InventoryType.DefenseCannonEmpty: index = i break if index < 0 or not Freebooter.getPaidStatus(base.localAvatar.doId) and index >= CannonDefenseGlobals.FREEBOOTER_MAX_AMMO_SLOTS: return False PiratesGlobals.CANNON_DEFENSE_SKILLS.remove(InventoryType.DefenseCannonEmpty) PiratesGlobals.CANNON_DEFENSE_SKILLS.insert(index, skillId) self.ammoQuantities[skillId] = CannonDefenseGlobals.getDefenseCannonAmmoAmount(skillId) return True
def addAmmoSkill(self, skillId): index = -1 for i in range(len(PiratesGlobals.CANNON_DEFENSE_SKILLS)): if PiratesGlobals.CANNON_DEFENSE_SKILLS[i] == InventoryType.DefenseCannonEmpty: index = i break continue if (index < 0 or not Freebooter.getPaidStatus(base.localAvatar.doId)) and index >= CannonDefenseGlobals.FREEBOOTER_MAX_AMMO_SLOTS: return False PiratesGlobals.CANNON_DEFENSE_SKILLS.remove(InventoryType.DefenseCannonEmpty) PiratesGlobals.CANNON_DEFENSE_SKILLS.insert(index, skillId) self.ammoQuantities[skillId] = CannonDefenseGlobals.getDefenseCannonAmmoAmount(skillId) return True
def addDefaultAmmo(self): default = InventoryType.DefenseCannonRoundShot PiratesGlobals.CANNON_DEFENSE_SKILLS.append(default) self.ammoQuantities[default] = CannonDefenseGlobals.getDefenseCannonAmmoAmount(default) base.localAvatar.guiMgr.combatTray.triggerSkillTraySkill(default)