def enterTeam1(self, character): app.mouse.task = app.mouse.hover self.character = character self.movement_candidates = find_nearby(app.world.terrain, character.x, character.y, 3.5) self.attack_candidates = find_nearby(app.world.terrain, character.x, character.y, 1.0) for tile in self.movement_candidates: tile.nodePath.setColor(0.5, 0.6, 1.0) if app.world.terrain.hoveredTile == tile: tile.nodePath.setColor(0.75, 0.9, 1.5) for tile in self.attack_candidates: tile.nodePath.setColor(1.0, 0.6, 0.5) if app.world.terrain.hoveredTile == tile: tile.nodePath.setColor(1.5, 0.9, 0.75)
def enterTeam2(self, character): player = find_opponent(app.world.teams, character) self.movement_candidates = find_nearby(app.world.terrain, character.x, character.y, 3.5) self.attack_candidates = find_nearby(app.world.terrain, character.x, character.y, 1.0) if player.tile in self.attack_candidates: character.set_action(Attack(character, player)) else: shortest_distance = 10000000 closest_tile = None for tile in self.movement_candidates: if tile.get_inhabitants(): continue vector = Point2(tile.x, tile.y) - Point2(player.x, player.y) distance = vector.lengthSquared() if distance < shortest_distance and distance > 0: shortest_distance = distance closest_tile = tile character.set_action(Move(character, closest_tile)) self.demand('Charge')