class FireFlameRushInstance(AbilityInstance): charge_speed_multiplier = 3 def __init__(self, player): AbilityInstance.__init__(self, player) self.scheduler = Scheduler(2) self.scheduler.on_fire += self.expire def run(self): AbilityInstance.run(self) self.player.is_charging = True self.player.move_speed *= self.charge_speed_multiplier self.player.collided += self.on_player_collided def on_player_collided(self, player, object): if object.type == "player": # @todo: do damage... print "Flame Rush collided with another player!" self.expire() return False if not object.isPassable: # @todo: stun? damage? etc... print "Flame Rush collided with some other object!" self.expire() return False def update(self, dt): AbilityInstance.update(self, dt) self.scheduler.addtime(dt) def expire(self): AbilityInstance.expire(self) self.player.is_charging = False self.player.move_speed /= self.charge_speed_multiplier
class FireFlameRushInstance(AbilityInstance): power_cost = 30 charge_speed_multiplier = 3 damage = 20 duration = .5 radius = 12 def __init__(self, player): AbilityInstance.__init__(self, player) self.scheduler = Scheduler(self.duration) self.scheduler.fired += self.expire self.type = "FireFlameRushInstance" self.collided = Event() def run(self): AbilityInstance.run(self) self.player.is_charging = True if self.player.world.is_master: self.player.move_speed *= self.charge_speed_multiplier self.player.collided += self.on_player_collided def on_player_collided(self, object): if not self.is_active: return False if not object.isPassable or object.type == "player": self.collided(self.player) # create the bounding circle to check collision against bounding_circle = collision.BoundingCircle(self.radius) # get a list of colliding players colliders = self.player.world.get_colliders( bounding_circle, self.player.position, [self.player], objects.Player) # for each player, apply effects if self.player.world.is_master: self.master(colliders) self.expire() return False def master(self, colliders): for player in colliders: player.apply_damage(self.damage, self.player, 202) print "Flame Rush collided with some other object!" def update(self, dt): AbilityInstance.update(self, dt) self.scheduler.addtime(dt) def expire(self): AbilityInstance.expire(self) self.player.is_charging = False if self.player.world.is_master: self.player.move_speed /= self.charge_speed_multiplier
class FireFlameRushInstance(AbilityInstance): power_cost = 30 charge_speed_multiplier = 3 damage = 20 duration = .5 radius = 12 def __init__(self, player): AbilityInstance.__init__(self, player) self.scheduler = Scheduler(self.duration) self.scheduler.fired += self.expire self.type = "FireFlameRushInstance" self.collided = Event() def run(self): AbilityInstance.run(self) self.player.is_charging = True if self.player.world.is_master: self.player.move_speed *= self.charge_speed_multiplier self.player.collided += self.on_player_collided def on_player_collided(self, object): if not self.is_active: return False if not object.isPassable or object.type == "player": self.collided(self.player) # create the bounding circle to check collision against bounding_circle = collision.BoundingCircle(self.radius) # get a list of colliding players colliders = self.player.world.get_colliders(bounding_circle, self.player.position, [self.player], objects.Player) # for each player, apply effects if self.player.world.is_master: self.master(colliders) self.expire() return False def master(self, colliders): for player in colliders: player.apply_damage(self.damage, self.player, 202) print "Flame Rush collided with some other object!" def update(self, dt): AbilityInstance.update(self, dt) self.scheduler.addtime(dt) def expire(self): AbilityInstance.expire(self) self.player.is_charging = False if self.player.world.is_master: self.player.move_speed /= self.charge_speed_multiplier
def __init__(self, player): AbilityInstance.__init__(self, player) self.scheduler = Scheduler(self.duration) self.scheduler.fired += self.expire self.type = "FireFlameRushInstance" self.collided = Event()
def __init__(self, player, delay): Scheduler.__init__(self, delay) self.player = player
def schedule(self, in_time, callback, *params): s = Scheduler(in_time, *params) s.fired += lambda *_: self.schedulers.remove(s) s.fired += callback self.schedulers.append(s)
def __init__(self, player): AbilityInstance.__init__(self, player) self.scheduler = Scheduler(2) self.scheduler.on_fire += self.expire