def get_media(self, character: str) -> Dict[str, Any]: """Return the set of media used by this variant of spaz.""" char = ba.app.spaz_appearances[character] if character not in self.spaz_media: media = self.spaz_media[character] = { 'jump_sounds': [ba.getsound(s) for s in char.jump_sounds], 'attack_sounds': [ba.getsound(s) for s in char.attack_sounds], 'impact_sounds': [ba.getsound(s) for s in char.impact_sounds], 'death_sounds': [ba.getsound(s) for s in char.death_sounds], 'pickup_sounds': [ba.getsound(s) for s in char.pickup_sounds], 'fall_sounds': [ba.getsound(s) for s in char.fall_sounds], 'color_texture': ba.gettexture(char.color_texture), 'color_mask_texture': ba.gettexture(char.color_mask_texture), 'head_model': ba.getmodel(char.head_model), 'torso_model': ba.getmodel(char.torso_model), 'pelvis_model': ba.getmodel(char.pelvis_model), 'upper_arm_model': ba.getmodel(char.upper_arm_model), 'forearm_model': ba.getmodel(char.forearm_model), 'hand_model': ba.getmodel(char.hand_model), 'upper_leg_model': ba.getmodel(char.upper_leg_model), 'lower_leg_model': ba.getmodel(char.lower_leg_model), 'toes_model': ba.getmodel(char.toes_model) } else: media = self.spaz_media[character] return media
def _preload4() -> None: for tname in ['bar', 'meter', 'null', 'flagColor', 'achievementOutline']: ba.gettexture(tname) for mname in ['frameInset', 'meterTransparent', 'achievementOutline']: ba.getmodel(mname) for sname in ['metalHit', 'metalSkid', 'refWhistle', 'achievement']: ba.getsound(sname) from bastd.actor.flag import FlagFactory FlagFactory.get()
def do_box(player): if player.actor and isinstance(player.actor, PlayerSpaz) and player.actor.node: player.actor.node.torso_model = ba.getmodel('tnt') player.actor.node.color_mask_texture = ba.gettexture('tnt') player.actor.node.color_texture = ba.gettexture('tnt') player.actor.node.highlight = (1, 1, 1) player.actor.node.color = (1, 1, 1) player.actor.node.head_model = None player.actor.node.style = 'cyborg'
def _preload3() -> None: for mname in ["bomb", "bombSticky", "impactBomb"]: ba.getmodel(mname) for tname in [ "bombColor", "bombColorIce", "bombStickyColor", "impactBombColor", "impactBombColorLit" ]: ba.gettexture(tname) for sname in ["freeze", "fuse01", "activateBeep", "warnBeep"]: ba.getsound(sname) spaz.get_factory() ba.timer(0.2, _preload4)
def leaderBoard(self): if len(mystats.top3Name) >2: if setti["leaderboard"]["barsBehindName"]: self.ss1=ba.newnode('image',attrs={'scale':(300,30),'texture':ba.gettexture('bar'),'position':(0,-80),'attach':'topRight','opacity':0.5,'color':(0.7,0.1,0)}) self.ss1=ba.newnode('image',attrs={'scale':(300,30),'texture':ba.gettexture('bar'),'position':(0,-115),'attach':'topRight','opacity':0.5,'color':(0.6,0.6,0.6)}) self.ss1=ba.newnode('image',attrs={'scale':(300,30),'texture':ba.gettexture('bar'),'position':(0,-150),'attach':'topRight','opacity':0.5,'color':(0.1,0.3,0.1)}) self.ss1a=ba.newnode('text',attrs={'text':"#1 "+mystats.top3Name[0][:10]+"...",'flatness':1.0,'h_align':'left','h_attach':'right','v_attach':'top','v_align':'center','position':(-140,-80),'scale':0.7,'color':(0.7,0.4,0.3)}) self.ss1a=ba.newnode('text',attrs={'text':"#2 "+mystats.top3Name[1][:10]+"...",'flatness':1.0,'h_align':'left','h_attach':'right','v_attach':'top','v_align':'center','position':(-140,-115),'scale':0.7,'color':(0.8,0.8,0.8)}) self.ss1a=ba.newnode('text',attrs={'text':"#3 "+mystats.top3Name[2][:10]+"...",'flatness':1.0,'h_align':'left','h_attach':'right','v_attach':'top','v_align':'center','position':(-140,-150),'scale':0.7,'color':(0.2,0.6,0.2)})
def _preload3() -> None: for mname in ['bomb', 'bombSticky', 'impactBomb']: ba.getmodel(mname) for tname in [ 'bombColor', 'bombColorIce', 'bombStickyColor', 'impactBombColor', 'impactBombColorLit' ]: ba.gettexture(tname) for sname in ['freeze', 'fuse01', 'activateBeep', 'warnBeep']: ba.getsound(sname) spaz.get_factory() ba.timer(0.2, _preload4)
def refresh_characters(self) -> None: """Refresh available characters/icons.""" from bastd.actor import spazappearance self._spazzes = spazappearance.get_appearances() self._spazzes.sort() self._icon_textures = [ ba.gettexture(ba.app.spaz_appearances[s].icon_texture) for s in self._spazzes ] self._icon_tint_textures = [ ba.gettexture(ba.app.spaz_appearances[s].icon_mask_texture) for s in self._spazzes ]
def __init__(self) -> None: """Instantiate a PowerupBoxFactory. You shouldn't need to do this; call ba.Powerup.get_factory() to get a shared instance. """ from ba.internal import get_default_powerup_distribution shared = SharedObjects.get() self._lastpoweruptype: Optional[str] = None self.model = ba.getmodel('powerup') self.model_simple = ba.getmodel('powerupSimple') self.tex_bomb = ba.gettexture('powerupBomb') self.tex_punch = ba.gettexture('powerupPunch') self.tex_ice_bombs = ba.gettexture('powerupIceBombs') self.tex_sticky_bombs = ba.gettexture('powerupStickyBombs') self.tex_shield = ba.gettexture('powerupShield') self.tex_impact_bombs = ba.gettexture('powerupImpactBombs') self.tex_health = ba.gettexture('powerupHealth') self.tex_land_mines = ba.gettexture('powerupLandMines') self.tex_curse = ba.gettexture('powerupCurse') self.health_powerup_sound = ba.getsound('healthPowerup') self.powerup_sound = ba.getsound('powerup01') self.powerdown_sound = ba.getsound('powerdown01') self.drop_sound = ba.getsound('boxDrop') # Material for powerups. self.powerup_material = ba.Material() # Material for anyone wanting to accept powerups. self.powerup_accept_material = ba.Material() # Pass a powerup-touched message to applicable stuff. self.powerup_material.add_actions( conditions=('they_have_material', self.powerup_accept_material), actions=( ('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', False), ('message', 'our_node', 'at_connect', _TouchedMessage()), )) # We don't wanna be picked up. self.powerup_material.add_actions( conditions=('they_have_material', shared.pickup_material), actions=('modify_part_collision', 'collide', False), ) self.powerup_material.add_actions( conditions=('they_have_material', shared.footing_material), actions=('impact_sound', self.drop_sound, 0.5, 0.1), ) self._powerupdist: List[str] = [] for powerup, freq in get_default_powerup_distribution(): for _i in range(int(freq)): self._powerupdist.append(powerup)
def __init__(self, origin_widget: ba.Widget): uiscale = ba.app.ui.uiscale scale = (2.3 if uiscale is ba.UIScale.SMALL else 1.65 if uiscale is ba.UIScale.MEDIUM else 1.23) self._transitioning_out = False self._width = 570 self._height = 350 bg_color = (0.5, 0.4, 0.6) popup.PopupWindow.__init__( self, size=(self._width, self._height), toolbar_visibility='inherit', scale=scale, bg_color=bg_color, position=origin_widget.get_screen_space_center()) self._cancel_button = ba.buttonwidget( parent=self.root_widget, position=(50, self._height - 30), size=(50, 50), scale=0.5, label='', color=bg_color, on_activate_call=self._on_cancel_press, autoselect=True, icon=ba.gettexture('crossOut'), iconscale=1.2)
def __init__(self, settings: dict): self._race_started = False super().__init__(settings) self._scoreboard = Scoreboard() self._score_sound = ba.getsound('score') self._swipsound = ba.getsound('swip') self._last_team_time: Optional[float] = None self._front_race_region: Optional[int] = None self._nub_tex = ba.gettexture('nub') self._beep_1_sound = ba.getsound('raceBeep1') self._beep_2_sound = ba.getsound('raceBeep2') self.race_region_material: Optional[ba.Material] = None self._regions: List[RaceRegion] = [] self._team_finish_pts: Optional[int] = None self._time_text: Optional[ba.Actor] = None self._timer: Optional[OnScreenTimer] = None self._race_mines: Optional[List[RaceMine]] = None self._race_mine_timer: Optional[ba.Timer] = None self._scoreboard_timer: Optional[ba.Timer] = None self._player_order_update_timer: Optional[ba.Timer] = None self._start_lights: Optional[List[ba.Node]] = None self._bomb_spawn_timer: Optional[ba.Timer] = None self._laps = int(settings['Laps']) self._entire_team_must_finish = bool( settings.get('Entire Team Must Finish', False)) self._time_limit = float(settings['Time Limit']) self._mine_spawning = int(settings['Mine Spawning']) self._bomb_spawning = int(settings['Bomb Spawning']) self._epic_mode = bool(settings['Epic Mode']) # Base class overrides. self.slow_motion = self._epic_mode self.default_music = (ba.MusicType.EPIC_RACE if self._epic_mode else ba.MusicType.RACE)
def init(self, actor: stdbomb.Bomb, position: Sequence[Union[int, float]], velocity: Sequence[Union[int, float]], materials: Sequence[ba.Material]): factory = stdbomb.BombFactory.get() actor.node = ba.newnode('prop', delegate=actor, attrs={ 'body': 'landMine', 'model': factory.land_mine_model, 'light_model': factory.land_mine_model, 'color_texture': ba.gettexture('achievementCrossHair'), 'position': position, 'velocity': velocity, 'shadow_size': 0.44, 'reflection': 'powerup', 'reflection_scale': [1], 'materials': materials })
def __init__(self, m, random_col): super().__init__() shared = SharedObjects.get() if random_col: col = (random.uniform(0, 1.2), random.uniform(0, 1.2), random.uniform(0, 1.2)) else: col = (0.9, 0.7, 0.0) self.mat = ba.Material() self.mat.add_actions(actions=( ('modify_part_collision', 'collide', False), ('modify_part_collision', 'physical', False), )) self.node = ba.newnode('prop', delegate=self, attrs={ 'model': ba.getmodel('bomb'), 'position': (2, 4, 2), 'body': 'capsule', 'shadow_size': 0.0, 'color_texture': ba.gettexture('coin'), 'reflection': 'soft', 'reflection_scale': [1.5], 'materials': [shared.object_material, self.mat] }) ba.animate(self.node, 'model_scale', { 0: 0, 1: 0.19, 5: 0.10, 10: 0.0 }, loop=True) ba.animate_array(self.node, 'position', 3, self.generateKeys(m), loop=True) self.light = ba.newnode('light', owner=self.node, attrs={ 'intensity': 0.6, 'height_attenuated': True, 'radius': 0.2, 'color': col }) ba.animate(self.light, 'radius', { 0: 0.0, 20: 0.4, 70: 0.1, 100: 0.3, 150: 0 }, loop=True) self.node.connectattr('position', self.light, 'position')
def __init__(self, settings: Dict[str, Any]): from bastd.actor.scoreboard import Scoreboard self._race_started = False super().__init__(settings) self._scoreboard = Scoreboard() if self.settings['Epic Mode']: self.slow_motion = True self._score_sound = ba.getsound('score') self._swipsound = ba.getsound('swip') self._last_team_time: Optional[float] = None self._front_race_region: Optional[int] = None self._nub_tex = ba.gettexture('nub') self._beep_1_sound = ba.getsound('raceBeep1') self._beep_2_sound = ba.getsound('raceBeep2') self.race_region_material: Optional[ba.Material] = None self._regions: List[RaceRegion] = [] self._team_finish_pts: Optional[int] = None self._time_text: Optional[ba.Actor] = None self._timer: Optional[OnScreenTimer] = None self._race_mines: Optional[List[RaceMine]] = None self._race_mine_timer: Optional[ba.Timer] = None self._scoreboard_timer: Optional[ba.Timer] = None self._player_order_update_timer: Optional[ba.Timer] = None self._start_lights: Optional[List[ba.Node]] = None self._bomb_spawn_timer: Optional[ba.Timer] = None
def __init__(self, label: ba.Lstr = None, score_split: float = 0.7): """Instantiate a scoreboard. Label can be something like 'points' and will show up on boards if provided. """ self._flat_tex = ba.gettexture('null') self._entries: Dict[int, _Entry] = {} self._label = label self.score_split = score_split # For free-for-all we go simpler since we have one per player. self._pos: Sequence[float] if isinstance(ba.getsession(), ba.FreeForAllSession): self._do_cover = False self._spacing = 35.0 self._pos = (17.0, -65.0) self._scale = 0.8 self._flash_length = 0.5 else: self._do_cover = True self._spacing = 50.0 self._pos = (20.0, -70.0) self._scale = 1.0 self._flash_length = 1.0
def __init__(self, origin_widget: ba.Widget, qr_tex: ba.Texture): position = origin_widget.get_screen_space_center() uiscale = ba.app.uiscale scale = (2.3 if uiscale is ba.UIScale.SMALL else 1.65 if uiscale is ba.UIScale.MEDIUM else 1.23) self._transitioning_out = False self._width = 450 self._height = 400 bg_color = (0.5, 0.4, 0.6) popup.PopupWindow.__init__(self, position=position, size=(self._width, self._height), scale=scale, bg_color=bg_color) self._cancel_button = ba.buttonwidget( parent=self.root_widget, position=(50, self._height - 30), size=(50, 50), scale=0.5, label='', color=bg_color, on_activate_call=self._on_cancel_press, autoselect=True, icon=ba.gettexture('crossOut'), iconscale=1.2) ba.imagewidget(parent=self.root_widget, position=(self._width * 0.5 - 150, self._height * 0.5 - 150), size=(300, 300), texture=qr_tex)
def __init__(self, data: Dict[str, Any]): self._width = 350 self._height = 200 uiscale = ba.app.uiscale super().__init__(root_widget=ba.containerwidget( size=(self._width, self._height), color=(0.45, 0.63, 0.15), transition='in_scale', scale=(1.8 if uiscale is ba.UIScale.SMALL else 1.35 if uiscale is ba.UIScale.MEDIUM else 1.0))) self._data = copy.deepcopy(data) ba.playsound(ba.getsound('cashRegister')) ba.playsound(ba.getsound('swish')) self._cancel_button = ba.buttonwidget(parent=self._root_widget, scale=0.5, position=(40, self._height - 40), size=(50, 50), label='', on_activate_call=self.close, autoselect=True, color=(0.45, 0.63, 0.15), icon=ba.gettexture('crossOut'), iconscale=1.2) ba.containerwidget(edit=self._root_widget, cancel_button=self._cancel_button) ba.textwidget(parent=self._root_widget, position=(self._width * 0.5, self._height * 0.5), size=(0, 0), color=(1.0, 3.0, 1.0), scale=2.0, h_align='center', v_align='center', text=data['code'], maxwidth=self._width * 0.85)
def __init__(self, settings: dict): settings['map'] = 'Tower D' super().__init__(settings) shared = SharedObjects.get() self._preset = Preset(settings.get('preset', 'pro')) self._player_death_sound = ba.getsound('playerDeath') self._new_wave_sound = ba.getsound('scoreHit01') self._winsound = ba.getsound('score') self._cashregistersound = ba.getsound('cashRegister') self._bad_guy_score_sound = ba.getsound('shieldDown') self._heart_tex = ba.gettexture('heart') self._heart_model_opaque = ba.getmodel('heartOpaque') self._heart_model_transparent = ba.getmodel('heartTransparent') self._a_player_has_been_killed = False self._spawn_center = self._map_type.defs.points['spawn1'][0:3] self._tntspawnpos = self._map_type.defs.points['tnt_loc'][0:3] self._powerup_center = self._map_type.defs.boxes['powerup_region'][0:3] self._powerup_spread = ( self._map_type.defs.boxes['powerup_region'][6] * 0.5, self._map_type.defs.boxes['powerup_region'][8] * 0.5) self._score_region_material = ba.Material() self._score_region_material.add_actions( conditions=('they_have_material', shared.player_material), actions=( ('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', False), ('call', 'at_connect', self._handle_reached_end), )) self._last_wave_end_time = ba.time() self._player_has_picked_up_powerup = False self._scoreboard: Optional[Scoreboard] = None self._game_over = False self._wavenum = 0 self._can_end_wave = True self._score = 0 self._time_bonus = 0 self._score_region: Optional[ba.Actor] = None self._dingsound = ba.getsound('dingSmall') self._dingsoundhigh = ba.getsound('dingSmallHigh') self._exclude_powerups: Optional[List[str]] = None self._have_tnt: Optional[bool] = None self._waves: Optional[List[Wave]] = None self._bots = SpazBotSet() self._tntspawner: Optional[TNTSpawner] = None self._lives_bg: Optional[ba.NodeActor] = None self._start_lives = 10 self._lives = self._start_lives self._lives_text: Optional[ba.NodeActor] = None self._flawless = True self._time_bonus_timer: Optional[ba.Timer] = None self._time_bonus_text: Optional[ba.NodeActor] = None self._time_bonus_mult: Optional[float] = None self._wave_text: Optional[ba.NodeActor] = None self._flawless_bonus: Optional[int] = None self._wave_update_timer: Optional[ba.Timer] = None
def __init__(self) -> None: """Instantiate a PowerupBoxFactory. You shouldn't need to do this; call ba.Powerup.get_factory() to get a shared instance. """ from ba.internal import get_default_powerup_distribution self._lastpoweruptype: Optional[str] = None self.model = ba.getmodel("powerup") self.model_simple = ba.getmodel("powerupSimple") self.tex_bomb = ba.gettexture("powerupBomb") self.tex_punch = ba.gettexture("powerupPunch") self.tex_ice_bombs = ba.gettexture("powerupIceBombs") self.tex_sticky_bombs = ba.gettexture("powerupStickyBombs") self.tex_shield = ba.gettexture("powerupShield") self.tex_impact_bombs = ba.gettexture("powerupImpactBombs") self.tex_health = ba.gettexture("powerupHealth") self.tex_land_mines = ba.gettexture("powerupLandMines") self.tex_curse = ba.gettexture("powerupCurse") self.health_powerup_sound = ba.getsound("healthPowerup") self.powerup_sound = ba.getsound("powerup01") self.powerdown_sound = ba.getsound("powerdown01") self.drop_sound = ba.getsound("boxDrop") # Material for powerups. self.powerup_material = ba.Material() # Material for anyone wanting to accept powerups. self.powerup_accept_material = ba.Material() # Pass a powerup-touched message to applicable stuff. self.powerup_material.add_actions( conditions=("they_have_material", self.powerup_accept_material), actions=(("modify_part_collision", "collide", True), ("modify_part_collision", "physical", False), ("message", "our_node", "at_connect", _TouchedMessage()))) # We don't wanna be picked up. self.powerup_material.add_actions( conditions=("they_have_material", ba.sharedobj('pickup_material')), actions=("modify_part_collision", "collide", False)) self.powerup_material.add_actions( conditions=("they_have_material", ba.sharedobj('footing_material')), actions=("impact_sound", self.drop_sound, 0.5, 0.1)) self._powerupdist: List[str] = [] for powerup, freq in get_default_powerup_distribution(): for _i in range(int(freq)): self._powerupdist.append(powerup)
def dec_bomb_count(self, bomb_type): if not hasattr(self, 'exbomb_count'): self.exbomb_count = {} count = self.exbomb_count.get(bomb_type, 0) - 1 self.exbomb_count[bomb_type] = count if count > 0 else 0 if self.exbomb_count[bomb_type] != 0: # TODO: cleanup this self.node.counter_text = 'x' + str(self.exbomb_count[bomb_type]) self.node.counter_texture = ba.gettexture(_bombtextures[bomb_type]) else: self.node.counter_text = ''
def __init__(self, settings: dict): super().__init__(settings) shared = SharedObjects.get() self._scoreboard = Scoreboard() self._cheer_sound = ba.getsound('cheer') self._chant_sound = ba.getsound('crowdChant') self._foghorn_sound = ba.getsound('foghorn') self._swipsound = ba.getsound('swip') self._whistle_sound = ba.getsound('refWhistle') self.puck_model = ba.getmodel('puck') self.puck_tex = ba.gettexture('puckColor') self._puck_sound = ba.getsound('metalHit') self.puck_material = ba.Material() self.puck_material.add_actions(actions=(('modify_part_collision', 'friction', 0.5))) self.puck_material.add_actions(conditions=('they_have_material', shared.pickup_material), actions=('modify_part_collision', 'collide', False)) self.puck_material.add_actions( conditions=( ('we_are_younger_than', 100), 'and', ('they_have_material', shared.object_material), ), actions=('modify_node_collision', 'collide', False), ) self.puck_material.add_actions(conditions=('they_have_material', shared.footing_material), actions=('impact_sound', self._puck_sound, 0.2, 5)) # Keep track of which player last touched the puck self.puck_material.add_actions( conditions=('they_have_material', shared.player_material), actions=(('call', 'at_connect', self._handle_puck_player_collide), )) # We want the puck to kill powerups; not get stopped by them self.puck_material.add_actions( conditions=('they_have_material', PowerupBoxFactory.get().powerup_material), actions=(('modify_part_collision', 'physical', False), ('message', 'their_node', 'at_connect', ba.DieMessage()))) self._score_region_material = ba.Material() self._score_region_material.add_actions( conditions=('they_have_material', self.puck_material), actions=(('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', False), ('call', 'at_connect', self._handle_score))) self._puck_spawn_pos: Optional[Sequence[float]] = None self._score_regions: Optional[List[ba.NodeActor]] = None self._puck: Optional[Puck] = None self._score_to_win = int(settings['Score to Win']) self._time_limit = float(settings['Time Limit'])
def _preload2() -> None: # FIXME: Could integrate these loads with the classes that use them # so they don't have to redundantly call the load # (even if the actual result is cached). for mname in ["powerup", "powerupSimple"]: ba.getmodel(mname) for tname in [ "powerupBomb", "powerupSpeed", "powerupPunch", "powerupIceBombs", "powerupStickyBombs", "powerupShield", "powerupImpactBombs", "powerupHealth" ]: ba.gettexture(tname) for sname in [ "powerup01", "boxDrop", "boxingBell", "scoreHit01", "scoreHit02", "dripity", "spawn", "gong" ]: ba.getsound(sname) from bastd.actor import bomb bomb.get_factory() ba.timer(0.1, _preload3)
def _preload2() -> None: # FIXME: Could integrate these loads with the classes that use them # so they don't have to redundantly call the load # (even if the actual result is cached). for mname in ['powerup', 'powerupSimple']: ba.getmodel(mname) for tname in [ 'powerupBomb', 'powerupSpeed', 'powerupPunch', 'powerupIceBombs', 'powerupStickyBombs', 'powerupShield', 'powerupImpactBombs', 'powerupHealth' ]: ba.gettexture(tname) for sname in [ 'powerup01', 'boxDrop', 'boxingBell', 'scoreHit01', 'scoreHit02', 'dripity', 'spawn', 'gong' ]: ba.getsound(sname) from bastd.actor.bomb import BombFactory BombFactory.get() ba.timer(0.1, _preload3)
def __init__(self, settings: Dict[str, Any]): from bastd.actor.scoreboard import Scoreboard super().__init__(settings) self._last_player_death_time = None self._scoreboard = Scoreboard() self.egg_model = ba.getmodel('egg') self.egg_tex_1 = ba.gettexture('eggTex1') self.egg_tex_2 = ba.gettexture('eggTex2') self.egg_tex_3 = ba.gettexture('eggTex3') self._collect_sound = ba.getsound('powerup01') self._pro_mode = settings.get('Pro Mode', False) self._max_eggs = 1.0 self.egg_material = ba.Material() self.egg_material.add_actions( conditions=("they_have_material", ba.sharedobj('player_material')), actions=(("call", "at_connect", self._on_egg_player_collide), )) self._eggs: List[Egg] = [] self._update_timer: Optional[ba.Timer] = None self._countdown: Optional[OnScreenCountdown] = None self._bots: Optional[spazbot.BotSet] = None
def __init__(self) -> None: position = (0.0, 0.0) uiscale = ba.app.ui.uiscale scale = (2.3 if uiscale is ba.UIScale.SMALL else 1.65 if uiscale is ba.UIScale.MEDIUM else 1.23) self._transitioning_out = False self._width = 570 self._height = 350 bg_color = (0.5, 0.4, 0.6) popup.PopupWindow.__init__(self, position=position, size=(self._width, self._height), scale=scale, bg_color=bg_color) self._cancel_button = ba.buttonwidget( parent=self.root_widget, position=(50, self._height - 30), size=(50, 50), scale=0.5, label='', color=bg_color, on_activate_call=self._on_cancel_press, autoselect=True, icon=ba.gettexture('crossOut'), iconscale=1.2) ba.imagewidget(parent=self.root_widget, position=(self._width * 0.5 - 110, self._height * 0.67 - 110), size=(220, 220), texture=ba.gettexture('multiplayerExamples')) ba.textwidget(parent=self.root_widget, size=(0, 0), h_align='center', v_align='center', maxwidth=self._width * 0.9, position=(self._width * 0.5, 60), text=ba.Lstr( resource='remoteAppInfoShortText', subs=[('${APP_NAME}', ba.Lstr(resource='titleText')), ('${REMOTE_APP_NAME}', ba.Lstr(resource='remote_app.app_name'))]))
def init(self, actor: stdbomb.Bomb, position, velocity, materials): factory = stdbomb.BombFactory.get() actor.node = ba.newnode('prop', delegate=actor, attrs={ 'body': 'sphere', 'model': factory.impact_bomb_model, 'color_texture': ba.gettexture('ouyaAButton'), 'position': position, 'velocity': velocity, 'shadow_size': 0.3, 'reflection': 'powerup', 'reflection_scale': [1.5], 'materials': materials})
def __init__(self, settings: Dict[str, Any]): super().__init__(settings) self._last_player_death_time = None self._scoreboard = Scoreboard() self.egg_model = ba.getmodel('egg') self.egg_tex_1 = ba.gettexture('eggTex1') self.egg_tex_2 = ba.gettexture('eggTex2') self.egg_tex_3 = ba.gettexture('eggTex3') self._collect_sound = ba.getsound('powerup01') self._pro_mode = settings.get('Pro Mode', False) self._max_eggs = 1.0 self.egg_material = ba.Material() self.egg_material.add_actions( conditions=('they_have_material', ba.sharedobj('player_material')), actions=(('call', 'at_connect', self._on_egg_player_collide), )) self._eggs: List[Egg] = [] self._update_timer: Optional[ba.Timer] = None self._countdown: Optional[OnScreenCountdown] = None self._bots: Optional[BotSet] = None # Base class overrides self.default_music = ba.MusicType.FORWARD_MARCH
def arm(self, actor: stdbomb.Bomb): factory = stdbomb.BombFactory.get() elon_mine_lit_tex = ba.gettexture('circleNoAlpha') elon_mine_tex = ba.gettexture('achievementCrossHair') actor.texture_sequence = ba.newnode('texture_sequence', owner=actor.node, attrs={ 'rate': 30, 'input_textures': (elon_mine_lit_tex, elon_mine_tex) }) ba.timer(0.5, actor.texture_sequence.delete) ba.playsound(ba.getsound('activateBeep'), position=actor.node.position) actor.aim = AutoAim(actor.node, actor.owner) # we now make it explodable. ba.timer( 0.25, ba.WeakCall(actor._add_material, factory.land_mine_blast_material)) actor.texture_sequence.connectattr('output_texture', actor.node, 'color_texture')
def __init__(self, settings: Dict[str, Any]): from bastd.actor.scoreboard import Scoreboard from bastd.actor import powerupbox super().__init__(settings) self._scoreboard = Scoreboard() self._cheer_sound = ba.getsound("cheer") self._chant_sound = ba.getsound("crowdChant") self._foghorn_sound = ba.getsound("foghorn") self._swipsound = ba.getsound("swip") self._whistle_sound = ba.getsound("refWhistle") self.puck_model = ba.getmodel("puck") self.puck_tex = ba.gettexture("puckColor") self._puck_sound = ba.getsound("metalHit") self.puck_material = ba.Material() self.puck_material.add_actions(actions=(("modify_part_collision", "friction", 0.5))) self.puck_material.add_actions( conditions=("they_have_material", ba.sharedobj('pickup_material')), actions=("modify_part_collision", "collide", False)) self.puck_material.add_actions( conditions=(("we_are_younger_than", 100), 'and', ("they_have_material", ba.sharedobj('object_material'))), actions=("modify_node_collision", "collide", False)) self.puck_material.add_actions( conditions=("they_have_material", ba.sharedobj('footing_material')), actions=("impact_sound", self._puck_sound, 0.2, 5)) # Keep track of which player last touched the puck self.puck_material.add_actions( conditions=("they_have_material", ba.sharedobj('player_material')), actions=(("call", "at_connect", self._handle_puck_player_collide), )) # We want the puck to kill powerups; not get stopped by them self.puck_material.add_actions( conditions=("they_have_material", powerupbox.get_factory().powerup_material), actions=(("modify_part_collision", "physical", False), ("message", "their_node", "at_connect", ba.DieMessage()))) self._score_region_material = ba.Material() self._score_region_material.add_actions( conditions=("they_have_material", self.puck_material), actions=(("modify_part_collision", "collide", True), ("modify_part_collision", "physical", False), ("call", "at_connect", self._handle_score))) self._puck_spawn_pos: Optional[Sequence[float]] = None self._score_regions: Optional[List[ba.NodeActor]] = None self._puck: Optional[Puck] = None
def __init__(self, account_id: str, origin_widget: ba.Widget): self._width = 550 self._height = 220 self._account_id = account_id self._transition_out = 'out_scale' scale_origin = origin_widget.get_screen_space_center() overlay_stack = _ba.get_special_widget('overlay_stack') uiscale = ba.app.ui.uiscale super().__init__(root_widget=ba.containerwidget( size=(self._width, self._height), parent=overlay_stack, transition='in_scale', scale_origin_stack_offset=scale_origin, scale=(1.8 if uiscale is ba.UIScale.SMALL else 1.35 if uiscale is ba.UIScale.MEDIUM else 1.0))) self._cancel_button = ba.buttonwidget(parent=self._root_widget, scale=0.7, position=(40, self._height - 50), size=(50, 50), label='', on_activate_call=self.close, autoselect=True, color=(0.4, 0.4, 0.5), icon=ba.gettexture('crossOut'), iconscale=1.2) ba.containerwidget(edit=self._root_widget, cancel_button=self._cancel_button) ba.textwidget(parent=self._root_widget, position=(self._width * 0.5, self._height * 0.64), size=(0, 0), color=(1, 1, 1, 0.8), scale=1.2, h_align='center', v_align='center', text=ba.Lstr(resource='reportThisPlayerReasonText'), maxwidth=self._width * 0.85) ba.buttonwidget(parent=self._root_widget, size=(235, 60), position=(20, 30), label=ba.Lstr(resource='reportThisPlayerLanguageText'), on_activate_call=self._on_language_press, autoselect=True) ba.buttonwidget(parent=self._root_widget, size=(235, 60), position=(self._width - 255, 30), label=ba.Lstr(resource='reportThisPlayerCheatingText'), on_activate_call=self._on_cheating_press, autoselect=True)
def mainmenu_reftersh_not_in_game(self, positions): retval = old_mainmenu_refresh_not_in_game(self, positions) foof = (-1 if ba.app.small_ui else 1 if ba.app.med_ui else 3) if ba.app.small_ui: play_button_width = self._button_width * 0.65 elif ba.app.med_ui: play_button_width = self._button_width * 0.65 else: play_button_width = self._button_width * 0.65 h, v, scale = positions[self._p_index - 4] v = v + foof watch_delay = 0.0 if self._t_delay_play == 0.0 else max( 0.0, self._t_delay_play - 0.1) this_h = h + play_button_width * 0.5 * scale + 100 * scale this_b_width = self._button_width * 0.25 * scale this_b_height = self._button_height * 0.82 * scale self._bapman_button = btn = ba.buttonwidget( parent=self._root_widget, position=(this_h - this_b_width * 0.5, v), size=(this_b_width, this_b_height), autoselect=self._use_autoselect, button_type='square', label='', transition_delay=watch_delay, on_activate_call=ba.Call(_bapman_press, self)) ba.textwidget(parent=self._root_widget, position=(this_h, v + self._button_height * 0.33), size=(0, 0), scale=0.75, transition_delay=watch_delay, color=(0.75, 1.0, 0.7), draw_controller=btn, maxwidth=self._button_width * 0.33, text='Bapman', h_align='center', v_align='center') icon_size = this_b_width * 0.55 ba.imagewidget(parent=self._root_widget, size=(icon_size, icon_size), draw_controller=btn, transition_delay=watch_delay, position=(this_h - 0.5 * icon_size, v + 0.33 * this_b_height), texture=ba.gettexture('folder')) return retval