def use(self, player: GameObject): if self.level > 0: if self._next_usage <= time.time( ) and player.mana > self.mana_cost: player.mana -= self.mana_cost tornado_projectile: TornadoProjectile = TornadoProjectile( self.level, player) scene: Scene = SceneManagement.active_scene tornado_projectile.move( Vector2(player.center.x - tornado_projectile.width / 2, player.transform.y)) tornado_projectile.add_to_collision_mask(scene.enemies) scene.projectiles.add(tornado_projectile) scene.dynamics.add(tornado_projectile) player.apply_force( Vector2(0, PlayerSettings.Ability.TornadoJump.STRENGTH)) self._next_usage = time.time() + self.cooldown
def _on_collide(self, other: GameObject, direction_of_impact: Vector2, impact_side: ImpactSide, delta_time: float): if other != self._target: Enemy._on_collide(self, other, direction_of_impact, impact_side, delta_time) else: if impact_side != ImpactSide.TOP: # Collided with player, he need to suffer other: GameObject if impact_side == ImpactSide.BOTTOM: i = 0 other.take_damage(1000) elif impact_side == ImpactSide.RIGHT: i = 1 elif impact_side == ImpactSide.LEFT: i = -1 other.apply_force(EnemySettings.HeavyRock.KNOCKBACK * i) other.take_damage(EnemySettings.HeavyRock.SIDE_DAMAGE) if other.is_dead: self._target = None
def _on_collide(self, other: GameObject, direction_of_impact: Vector2, impact_side: ImpactSide, delta_time: float): if isinstance(other, PhysicsReceiver): other.apply_force(self._direction * self._force * delta_time)
def _on_collide(self, other: GameObject, direction_of_impact: Vector2, impact_side: ImpactSide, delta_time: float): if isinstance(other, Player): other.apply_force(self._direction * 30) other.take_damage(20) self.kill()
def _on_collide(self, other: GameObject, direction_of_impact: Vector2, impact_side: ImpactSide, delta_time: float): if isinstance(other, RigidPhysicsAwareGameObject): other.apply_force(Vector2(self.velocity.x, PlayerSettings.Ability.Gust.PROJECTILE_HIT_STRENGTH_Y)) self.kill()
def _on_collide(self, other: GameObject, direction_of_impact: Vector2, direction: ImpactSide, delta_time: float): if isinstance(other, RigidPhysicsAwareGameObject): other.apply_force( direction_of_impact.normalize() * PlayerSettings.Ability.TornadoJump.KNOCKBACK_STRENGTH * self.level)
def _on_collide(self, other: GameObject, direction_of_impact: Vector2, impact_side: ImpactSide, delta_time: float): if isinstance(other, RigidPhysicsAwareGameObject): other.apply_force(self.strength)