def __init__(self, texture_name: str, player: Player, position: Point, robustness: Robustness = 0, id: Optional[int] = None): GameObject.__init__(self, texture_name, robustness, position, id) self.map = self.game.map self.name = decolorised_name(texture_name) self.player: Player = player self.faction: Faction = self.player.faction # Each Unit or Building keeps a set containing enemies it actually # sees and updates this set each frame: self.known_enemies: Set[PlayerEntity] = set() # when an Unit or Building detect enemy, enemy detects it too # automatically, to decrease number of is_visible functions calls: self.mutually_detected_enemies: Set[PlayerEntity] = set() self.nearby_friends: Set[PlayerEntity] = set() self.targeted_enemy: Optional[PlayerEntity] = None self.selection_marker: Optional[SelectedEntityMarker] = None # this is checked so frequent that it is worth caching it: self.is_building = isinstance(self, Building) self.is_unit = not self.is_building self.is_infantry = isinstance(self, Soldier) self._max_health = 100 self._health = self._max_health self.armour = 0 self.cover = 0 self.detection_radius = TILE_WIDTH * 8 # how far this Entity can see self.attack_radius = TILE_WIDTH * 5 # area inside which all map-nodes are visible for this entity: self.observed_nodes: Set[MapNode] = set() # area inside which every enemy unit could by attacked: self.fire_covered: Set[MapNode] = set() # flag used to avoid enemy units revealing map for human player, only # player's units and his allies units reveal map for him: self.should_reveal_map = self.faction is self.game.local_human_player.faction self._weapons: List[Weapon] = [] # use this number to animate shot blast from weapon: self.barrel_end = self.cur_texture_index self._ammunition = 100 self.experience = 0 self.kill_experience = 0 self.register_to_objectsowners(self.game, self.player)
def __init__(self, level, rect): GameObject.__init__(self, level, rect) # De image. self.image = imageExit # Bijhouden of er al een keer gefinished is omdat de collision detection # dubbel is. # self.finished = False
def __init__(self, level, rect): GameObject.__init__(self, level, rect) # De image. self.image = imageCoin