sep-pm-platformer/project/level/elements/static/GoalDoorReceiverLevelElemen...

30 lines
1.3 KiB
Python
Raw Permalink Normal View History

2023-03-28 18:09:29 +02:00
from level.Level import Level
from level.elements.static.ReceiverLevelElement import ReceiverLevelElement
from physics.SpriteManager import SpriteManager
2023-03-29 16:08:12 +02:00
from physics.TickData import TickData
2023-03-28 18:09:29 +02:00
from sprite.SpritesheetManager import SpritesheetManager
class GoalDoorReceiverLevelElement(ReceiverLevelElement):
def __init__(self, tile: dict, level: Level, level_screen_manager: 'LevelScreenManager'):
super().__init__(tile, level, level_screen_manager)
2023-03-29 16:08:12 +02:00
self.is_collider = False
2023-03-28 18:09:29 +02:00
def load(self, sprite_manager: SpriteManager, spritesheet_manager: SpritesheetManager, level: Level):
self.spritesheet = spritesheet_manager.get_sheet('goal_door')
self.set_animation_state('open' if self.active_state else 'close')
self.position_scale.position = self.tile['position']
def set_active(self, active: bool):
super().set_active(active)
self.set_animation_state('open' if self.active_state else 'close')
2023-03-29 14:14:45 +02:00
self.is_collider = False
2023-03-29 16:08:12 +02:00
self.register_collisions = self.active_state
def tick(self, tick_data: TickData):
super().tick(tick_data)
for collision in self.get_collides_with():
if collision.secondary_sprite.id == 'player':
if self.active_state:
self.level_screen_manager.player_success()