mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-01-27 01:13:13 +08:00
Merge pull request #13 from Dmitry450/master
Fixed meteor shower. Fixed text in co-op score screen. Fixed TNT respawn
This commit is contained in:
commit
d987239709
@ -330,7 +330,7 @@ class GameActivity(Activity):
|
||||
self._map_type.preload()
|
||||
self._map: Optional[ba.Map] = None
|
||||
self._powerup_drop_timer: Optional[ba.Timer] = None
|
||||
self._tnt_objs: Optional[Dict[int, Any]] = None
|
||||
self._tnt_spawners: Optional[Dict[int, Any]] = None
|
||||
self._tnt_drop_timer: Optional[ba.Timer] = None
|
||||
self.initial_player_info: Optional[List[Dict[str, Any]]] = None
|
||||
self._game_scoreboard_name_text: Optional[ba.Actor] = None
|
||||
@ -1111,12 +1111,8 @@ class GameActivity(Activity):
|
||||
repeat=True)
|
||||
self._standard_drop_powerups()
|
||||
if enable_tnt:
|
||||
self._tnt_objs = {}
|
||||
self._tnt_drop_timer = _ba.Timer(5.5,
|
||||
_general.WeakCall(
|
||||
self._standard_drop_tnt),
|
||||
repeat=True)
|
||||
self._standard_drop_tnt()
|
||||
self._tnt_spawners = {}
|
||||
self._setup_standard_tnt_drops()
|
||||
|
||||
def _standard_drop_powerup(self, index: int, expire: bool = True) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
@ -1136,24 +1132,15 @@ class GameActivity(Activity):
|
||||
_ba.timer(i * 0.4, _general.WeakCall(self._standard_drop_powerup,
|
||||
i))
|
||||
|
||||
def _standard_drop_tnt(self) -> None:
|
||||
def _setup_standard_tnt_drops(self) -> None:
|
||||
"""Standard tnt drop."""
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.actor import bomb
|
||||
|
||||
# Drop TNT on the map for any tnt location with no existing tnt box.
|
||||
for i, point in enumerate(self.map.tnt_points):
|
||||
assert self._tnt_objs is not None
|
||||
if i not in self._tnt_objs:
|
||||
self._tnt_objs[i] = {'absent_ticks': 9999, 'obj': None}
|
||||
tnt_obj = self._tnt_objs[i]
|
||||
|
||||
# Respawn once its been dead for a while.
|
||||
if not tnt_obj['obj']:
|
||||
tnt_obj['absent_ticks'] += 1
|
||||
if tnt_obj['absent_ticks'] > 3:
|
||||
tnt_obj['obj'] = bomb.Bomb(position=point, bomb_type='tnt')
|
||||
tnt_obj['absent_ticks'] = 0
|
||||
assert self._tnt_spawners is not None
|
||||
if self._tnt_spawners.get(i) is None:
|
||||
self._tnt_spawners[i] = bomb.TNTSpawner(point)
|
||||
|
||||
def setup_standard_time_limit(self, duration: float) -> None:
|
||||
"""
|
||||
|
||||
@ -1193,22 +1193,22 @@ class CoopScoreScreen(ba.Activity):
|
||||
Text(ba.Lstr(resource='coopSelectWindow.timeRemainingText'),
|
||||
position=(-360, -70 - 100),
|
||||
color=(1, 1, 1, 0.7),
|
||||
h_align='center',
|
||||
v_align='center',
|
||||
transition='fade_in',
|
||||
h_align=Text.HAlign.CENTER,
|
||||
v_align=Text.VAlign.CENTER,
|
||||
transition=Text.Transition.FADE_IN,
|
||||
scale=0.8,
|
||||
maxwidth=300,
|
||||
transition_delay=2.0).autoretain()
|
||||
self._tournament_time_remaining_text = Text('',
|
||||
position=(-360,
|
||||
-110 - 100),
|
||||
color=(1, 1, 1, 0.7),
|
||||
h_align='center',
|
||||
v_align='center',
|
||||
transition='fade_in',
|
||||
scale=1.6,
|
||||
maxwidth=150,
|
||||
transition_delay=2.0)
|
||||
self._tournament_time_remaining_text = Text(
|
||||
'',
|
||||
position=(-360, -110 - 100),
|
||||
color=(1, 1, 1, 0.7),
|
||||
h_align=Text.VAlign.CENTER,
|
||||
v_align=Text.VAlign.CENTER,
|
||||
transition=Text.Transition.FADE_IN,
|
||||
scale=1.6,
|
||||
maxwidth=150,
|
||||
transition_delay=2.0)
|
||||
|
||||
# If we're a tournament, show prizes.
|
||||
try:
|
||||
|
||||
@ -1047,17 +1047,17 @@ class TNTSpawner:
|
||||
category: Gameplay Classes
|
||||
"""
|
||||
|
||||
def __init__(self, position: Sequence[float], respawn_time: float = 30.0):
|
||||
def __init__(self, position: Sequence[float], respawn_time: float = 20.0):
|
||||
"""Instantiate with given position and respawn_time (in seconds)."""
|
||||
self._position = position
|
||||
self._tnt: Optional[Bomb] = None
|
||||
self._respawn_time = random.uniform(0.8, 1.2) * respawn_time
|
||||
self._wait_time = 0.0
|
||||
self._update()
|
||||
# (go with slightly more than 1 second to avoid timer stacking)
|
||||
self._update_timer = ba.Timer(1.1,
|
||||
ba.WeakCall(self._update),
|
||||
repeat=True)
|
||||
self._respawn_time = random.uniform(0.8, 1.2) * respawn_time
|
||||
self._wait_time = 0.0
|
||||
|
||||
def _update(self) -> None:
|
||||
tnt_alive = self._tnt is not None and self._tnt.node
|
||||
|
||||
@ -164,7 +164,7 @@ class MeteorShowerGame(ba.TeamGameActivity):
|
||||
# Augment standard behavior.
|
||||
super().handlemessage(msg)
|
||||
|
||||
death_time = ba.time()
|
||||
death_time = ba.time(timeformat=ba.TimeFormat.MILLISECONDS)
|
||||
|
||||
# Record the player's moment of death.
|
||||
msg.spaz.player.gamedata['death_time'] = death_time
|
||||
@ -240,8 +240,10 @@ class MeteorShowerGame(ba.TeamGameActivity):
|
||||
self._meteor_time = max(0.01, self._meteor_time * 0.9)
|
||||
|
||||
def end_game(self) -> None:
|
||||
cur_time = ba.time()
|
||||
cur_time = ba.time(timeformat=ba.TimeFormat.MILLISECONDS)
|
||||
assert self._timer is not None
|
||||
start_time = self._timer.getstarttime(
|
||||
timeformat=ba.TimeFormat.MILLISECONDS)
|
||||
|
||||
# Mark 'death-time' as now for any still-living players
|
||||
# and award players points for how long they lasted.
|
||||
@ -252,13 +254,14 @@ class MeteorShowerGame(ba.TeamGameActivity):
|
||||
# Throw an extra fudge factor in so teams that
|
||||
# didn't die come out ahead of teams that did.
|
||||
if 'death_time' not in player.gamedata:
|
||||
player.gamedata['death_time'] = cur_time + 0.001
|
||||
player.gamedata['death_time'] = cur_time + 1
|
||||
|
||||
# Award a per-player score depending on how many seconds
|
||||
# they lasted (per-player scores only affect teams mode;
|
||||
# everywhere else just looks at the per-team score).
|
||||
score = int(player.gamedata['death_time'] -
|
||||
self._timer.getstarttime())
|
||||
self._timer.getstarttime(
|
||||
timeformat=ba.TimeFormat.MILLISECONDS))
|
||||
if 'death_time' not in player.gamedata:
|
||||
score += 50 # a bit extra for survivors
|
||||
self.stats.player_scored(player, score, screenmessage=False)
|
||||
@ -281,8 +284,7 @@ class MeteorShowerGame(ba.TeamGameActivity):
|
||||
longest_life = 0
|
||||
for player in team.players:
|
||||
longest_life = max(longest_life,
|
||||
(player.gamedata['death_time'] -
|
||||
self._timer.getstarttime()))
|
||||
player.gamedata['death_time'] - start_time)
|
||||
results.set_team_score(team, longest_life)
|
||||
|
||||
self.end(results=results)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user