예제 #1
0
    def __init__(self, obj, config):
        super().__init__(config)
        self.log.info(self.M("ship_create"))
        utils.parent_groups(obj)

        self.obj = obj
        self.hull = [o for o in self.obj.childrenRecursive if 'HULL' in o][0]
        self.vert_center = [
            o for o in self.hull.childrenRecursive if 'VERT_CENTER' in o
        ][0]

        self._event = scheduler.Event(self.update)
        scheduler.add_event(self._event)

        self.miniguns = GunStorage(
            minigun.MiniGun(o, self.config["MINIGUN_CONFIG"])
            for o in self.obj.childrenRecursive if 'MINIGUN' in o)
        self.railguns = GunStorage(
            railgun.RailGun(o, self.config["RAILGUN_CONFIG"])
            for o in self.obj.childrenRecursive if 'RAILGUN' in o)
        self.thrusters = GunStorage(
            Thruster(self.hull, o, self.config['THRUSTER_CONFIG'])
            for o in self.obj.childrenRecursive if 'THRUSTER' in o)

        self.hull.removeParent()

        self.navigation_target = self.hull.worldPosition
예제 #2
0
 def __init__(self, conf):
     super().__init__(conf)
     self._event = scheduler.Event(self.update)
     scheduler.add_event(self._event)
     
     self.alive_bullets = set()
     self.dead_bullets = set()
     
     for _i in range(self.config['BULLET_LIMIT']):
         self.dead_bullets.add(_Bullet())
예제 #3
0
    def __init__(self, scene):
        super().__init__({})
        self.scene = scene
        self.unused_trails = [
            _GpuTrail(t) for t in self.scene.objectsInactive
            if '__TRAIL_INSTANCE__' in t
        ]
        self.used_trails = []

        self._event = scheduler.Event(self.update)
        scheduler.add_event(self._event)
        self.scene.pre_draw.append(self._draw)
예제 #4
0
 def __init__(self, scene, conf, mouse):
     super().__init__(conf)
     self.log.info(self.M("create_hud"))
     self._event = scheduler.Event(self.update)
     scheduler.add_event(self._event)
     
     self.scene = scene
     self.ship = None
     self.mouse = mouse
     
     self.weapon_selector = WeaponSelector(
         [o for o in scene.objects if 'WEAPON_SELECTOR' in o][0],
         self.config['WEAPON_UI_CONFIG'],
         self.mouse
     )
예제 #5
0
    def __init__(self, scene, conf):
        super().__init__(conf)

        logging.basicConfig(level=config.get('SYS/LOG_LEVEL'),
                            format='%(message)s')
        if config.get('SYS/EXIT_ON_ERROR'):
            self.log.info("exit_with_error_enabled")
            sys.excepthook = err
        else:
            sys.excepthook = sys.__excepthook__

        for cb in gc.callbacks.copy():
            gc.callbacks.remove(cb)
        gc.callbacks.append(gc_notify)

        exit_key = config.get('KEYS/EMERGENCY_ABORT_KEY')
        if exit_key:
            bge.logic.setExitKey(bge.events.__dict__[exit_key])

        self.log.info(self.M("init_game"))
        self._event = scheduler.Event(self.update)
        scheduler.add_event(self._event)

        bge.logic.addScene('HUD')
        self.scene = scene
        self.hud = None
        self.hud_scene = None

        self.hero = ship.Ship(self.scene.objects['HeroShipMain'],
                              self.config['HERO_CONFIG'])
        self.camera = camera.Camera(self.scene.objects['MainCamera'],
                                    self.config['CAMERA_CONFIG'])
        self.mouse = mouse.Mouse(self.config['MOUSE_CONFIG'])

        self.environment = environment.Environment(
            self.scene.objects['LightRig'],
            self.scene.objects['TerrainTiles'],
            self.scene.objects['SkySphere'],
        )

        self.scene.objects['MainCamera'].setParent(self.hero.vert_center)
        self.camera.set_view(0.5, -0.5, 0.2)

        self.navigation_waypoints = []

        self.scene.active_camera = self.camera.camera
        bge.render.showMouse(True)
예제 #6
0
    def __init__(self, obj, config):
        super().__init__(obj, config)
        self.log.debug(self.M("create_minigun", game_object=obj.name))
        utils.parent_groups(obj)
        objs = obj.childrenRecursive

        self.obj = obj
        self.yaw = [o for o in objs if 'YAW' in o][0]
        self.pitch = [o for o in objs if 'PITCH' in o][0]
        self.barrel = [o for o in objs if 'BARREL' in o][0]
        self.spawner = [o for o in objs if 'SPAWNER' in o][0]

        self._target = None
        self.barrel_angle = 0.0
        self.barrel_velocity = 0.0
        self.time_since_last_shot = 0.0

        self._event = scheduler.Event(self.update)
        scheduler.add_event(self._event)
예제 #7
0
    def __init__(self, obj, conf):
        super().__init__(obj, conf)
        self.log.debug(self.M("create_railgun", game_object=obj.name))
        utils.parent_groups(obj)
        objs = obj.childrenRecursive

        self.obj = obj
        self.yaw = [o for o in objs if 'MAIN_YAW' in o][0]

        self.pitch = [o for o in objs if 'PITCH' in o][0]
        self.barrels = [
            Barrel(o, self.config['BARREL_CONFIG']) for o in objs
            if 'SPAWNER' in o
        ]

        self._target = None

        self._event = scheduler.Event(self.update)
        scheduler.add_event(self._event)

        self.salvo_number = 0
        self.time_since_last_shot = self.config['RELOAD_TIME']
예제 #8
0
 def __init__(self, ship_obj, obj, conf):
     super().__init__(conf)
     self.obj = obj
     self.ship_obj = ship_obj
     self._event = scheduler.Event(self.update)
     scheduler.add_event(self._event)