コード例 #1
0
ファイル: gfx.py プロジェクト: PlumpMath/yyagl
 def __set_model(self):
     LogMgr().log('loading track model')
     time = globalClock.getFrameTime()
     filename = 'assets/models/tracks/' + self.props.name + '/track_all.bam'
     if not exists(filename):
         system('python yyagl/build/process_track.py ' + self.props.name)
     LogMgr().log('loading ' + filename)
     eng.load_model(filename, callback=self.end_loading)
コード例 #2
0
 def enterRace(self, track_path='', car_path='', drivers=''):
     LogMgr().log('entering Race state')
     base.ignore('escape-up')
     if 'save' not in self.mdt.options.dct:
         self.mdt.options['save'] = {}
     self.mdt.options['save']['track'] = track_path
     self.mdt.options['save']['car'] = car_path
     self.mdt.options['save']['drivers'] = drivers
     self.mdt.options.store()
     keys = self.mdt.options['settings']['keys']
     joystick = self.mdt.options['settings']['joystick']
     sounds = {
         'engine': 'assets/sfx/engine.ogg',
         'brake': 'assets/sfx/brake.ogg',
         'crash': 'assets/sfx/crash.ogg',
         'crash_hs': 'assets/sfx/crash_high_speed.ogg',
         'lap': 'assets/sfx/lap.ogg',
         'landing': 'assets/sfx/landing.ogg'
     }
     if Server().is_active:
         self.season.create_race_server(keys, joystick, sounds)
     elif Client().is_active:
         self.season.create_race_client(keys, joystick, sounds)
     else:
         race_props = self.mdt.logic.build_race_props(
             car_path, drivers, track_path, keys, joystick, sounds)
         self.mdt.logic.season.create_race(race_props)
     LogMgr().log('selected drivers: ' + str(drivers))
     self.mdt.logic.season.race.logic.drivers = drivers
     track_name_transl = track_path
     track_dct = {
         'desert': _('desert'),
         'mountain': _('mountain'),
         'amusement': _('amusement park')
     }
     if track_path in track_dct:
         track_name_transl = track_dct[track_path]
     singlerace = game.logic.season.__class__ == SingleRaceSeason
     self.mdt.logic.season.race.fsm.demand(
         'Loading', track_path, car_path, [], drivers,
         ['prototype', 'desert', 'mountain', 'amusement'],
         track_name_transl, singlerace, [
             'kronos', 'themis', 'diones', 'iapeto', 'phoibe', 'rea',
             'iperion'
         ], 'assets/images/cars/%s_sel.png',
         'assets/images/drivers/driver%s_sel.png',
         game.options['settings']['joystick'],
         game.options['settings']['keys'],
         Utils().menu_args, 'assets/sfx/countdown.ogg')
     self.mdt.logic.season.race.attach_obs(self.mdt.logic.on_race_loaded)
     exit_meth = self.mdt.logic.on_ingame_exit_confirm
     self.mdt.logic.season.race.attach_obs(exit_meth)
コード例 #3
0
ファイル: gfx.py プロジェクト: PlumpMath/yyagl
 def end_loading(self, model=None):
     if model:
         self.model = model
     anim_name = '**/%s*%s*' % (self.props.empty_name, self.props.anim_name)
     for model in self.model.findAllMatches(anim_name):
         # bam files don't contain actor info
         new_root = NodePath(model.get_name())
         new_root.reparent_to(model.get_parent())
         new_root.set_pos(model.get_pos())
         new_root.set_hpr(model.get_hpr())
         new_root.set_scale(model.get_scale())
         model_subname = model.get_name()[len(self.props.empty_name):]
         path = '%s/%s' % (self.props.path, model_subname)
         if '.' in path:
             path = path.split('.')[0]
         anim_path = '%s-%s' % (path, self.props.anim_name)
         self.__actors += [Actor(path, {'anim': anim_path})]
         self.__actors[-1].loop('anim')
         self.__actors[-1].setPlayRate(.5, 'anim')
         self.__actors[-1].reparent_to(new_root)
         has_omni = model.has_tag(self.props.omni_tag)
         if has_omni and model.get_tag(self.props.omni_tag):
             new_root.set_tag(self.props.omni_tag, 'True')
             a_n = self.__actors[-1].get_name()
             LogMgr().log('set omni for ' + a_n)
             self.__actors[-1].node().setBounds(OmniBoundingVolume())
             self.__actors[-1].node().setFinal(True)
         model.remove_node()
     self.signs = Signs(self.model, self.props.sign_name, self.props.thanks)
     self.signs.set_signs()
     self.model.prepareScene(eng.base.win.getGsg())
     self.model.premungeScene(eng.base.win.getGsg())
     Gfx.async_bld(self)
コード例 #4
0
 def enterMenu(self):
     LogMgr().log('entering Menu state')
     menu_props = MenuProps(
         Utils().menu_args, self.mdt.options,
         ['kronos', 'themis', 'diones', 'iapeto', 'phoibe', 'rea'],
         'assets/images/cars/%s.png', eng.curr_path +
         'assets/models/cars/%s/phys.yml', ['desert', 'mountain'],
         [_('desert'), _('mountain')], 'assets/images/tracks/%s.png',
         self.mdt.options['settings']['player_name'], [
             'assets/images/drivers/driver%s.png',
             'assets/images/drivers/driver%s_sel.png'
         ], 'assets/images/cars/%s_sel.png',
         self.mdt.options['development']['multiplayer'],
         'assets/images/gui/yorg_title.png',
         'http://feeds.feedburner.com/ya2tech?format=xml',
         'http://www.ya2.it', 'save' in self.mdt.options.dct,
         self.mdt.options['development']['season'], ['prototype', 'desert'],
         'http://www.ya2.it/support-us',
         Utils().drivers)
     self.__menu = YorgMenu(menu_props)
     self.__menu.gui.menu.attach_obs(self.mdt.logic.on_input_back)
     self.__menu.gui.menu.attach_obs(self.mdt.logic.on_options_back)
     self.__menu.gui.menu.attach_obs(self.mdt.logic.on_car_selected)
     self.__menu.gui.menu.attach_obs(self.mdt.logic.on_car_selected_season)
     self.__menu.gui.menu.attach_obs(self.mdt.logic.on_driver_selected)
     self.__menu.gui.menu.attach_obs(self.mdt.logic.on_exit)
     self.__menu.gui.menu.attach_obs(self.mdt.logic.on_continue)
     self.mdt.logic.menu_start()
     if self.mdt.logic.season:
         self.mdt.logic.season.detach_obs(self.mdt.event.on_season_end)
         self.mdt.logic.season.detach_obs(self.mdt.event.on_season_cont)
コード例 #5
0
ファイル: fsm.py プロジェクト: PlumpMath/yyagl
 def exitLoading(self):
     LogMgr().log('exiting Loading state')
     self.mdt.gui.loading.exit_loading()
     self.mdt.event.notify('on_race_loaded')
     #eng.set_cam_pos((0, 0, 0))
     self.mdt.logic.player_car.attach_obs(self.mdt.event.on_wrong_way)
     self.mdt.logic.player_car.attach_obs(self.mdt.event.on_respawn)
     self.mdt.logic.player_car.attach_obs(self.mdt.event.on_end_race)
コード例 #6
0
ファイル: phys.py プロジェクト: PlumpMath/yyagl
 def _load_phys(self):
     fpath = self.props.phys_file % self.mdt.name
     with open(fpath) as phys_file:  # pass phys props as a class
         self.cfg = load(phys_file)
     self.cfg['max_speed'] = self.get_speed()
     self.cfg['friction_slip'] = self.get_friction()
     self.cfg['roll_influence'] = self.get_roll_influence()
     s_a = (self.mdt.name, round(self.cfg['max_speed'],
                                 2), self.props.driver_engine)
     LogMgr().log('speed %s: %s (%s)' % s_a)
     fr_slip = round(self.cfg['friction_slip'], 2)
     f_a = (self.mdt.name, fr_slip, self.props.driver_tires)
     LogMgr().log('friction %s: %s (%s)' % f_a)
     r_a = (self.mdt.name, round(self.cfg['roll_influence'],
                                 2), self.props.driver_suspensions)
     LogMgr().log('roll %s: %s (%s)' % r_a)
     s_a = lambda field: setattr(self, field, self.cfg[field])
     map(s_a, self.cfg.keys())
コード例 #7
0
ファイル: phys.py プロジェクト: PlumpMath/yyagl
 def apply_damage(self, reset=False):
     if reset:
         self.max_speed = self.get_speed()
         self.friction_slip = self.get_friction()
         self.roll_influence = self.get_roll_influence()
     else:
         self.max_speed *= .95
         self.friction_slip *= .95
         self.roll_influence *= 1.05
     fric = lambda whl: whl.setFrictionSlip(self.friction_slip)
     map(fric, self.vehicle.get_wheels())
     roll = lambda whl: whl.setRollInfluence(self.roll_influence)
     map(roll, self.vehicle.get_wheels())
     s_a = (str(round(self.max_speed, 2)), self.props.driver_engine)
     LogMgr().log('speed: %s (%s)' % s_a)
     f_a = (str(round(self.friction_slip, 2)), self.props.driver_tires)
     LogMgr().log('friction: %s (%s)' % f_a)
     r_a = (str(round(self.roll_influence,
                      2)), self.props.driver_suspensions)
     LogMgr().log('roll: %s (%s)' % r_a)
コード例 #8
0
ファイル: fsm.py プロジェクト: PlumpMath/yyagl
 def enterLoading(self, track_path, car_path, player_cars, drivers, tracks,
                  track_name_transl, single_race, grid, cars_path,
                  drivers_path, joystick, keys, menu_args, countdown_sfx):
     LogMgr().log('entering Loading state')
     self.menu_args = menu_args
     self.countdown_sfx = countdown_sfx
     loading_props = LoadingProps(track_path, car_path, drivers, tracks,
                                  track_name_transl, single_race, grid,
                                  cars_path, drivers_path, joystick, keys,
                                  menu_args)
     self.mdt.gui.loading.enter_loading(loading_props)
     args = [track_path, car_path, player_cars]
     eng.do_later(1.0, self.mdt.logic.load_stuff, args)
コード例 #9
0
ファイル: car.py プロジェクト: PlumpMath/yyagl
 def __init__(self, car_props):
     LogMgr().log('init car ' + car_props.name)
     self.name = car_props.name
     self.laps = car_props.laps
     self.road_name = car_props.road_name
     gui_props = CarGuiProps(car_props.color_main, car_props.color,
                             car_props.font, car_props.laps)
     audio_props = CarAudioProps(car_props.sounds['engine'],
                                 car_props.sounds['brake'],
                                 car_props.sounds['crash'],
                                 car_props.sounds['crash_hs'],
                                 car_props.sounds['lap'],
                                 car_props.sounds['landing'])
     carlogic_props = CarLogicProps(car_props.pos, car_props.hpr,
                                    car_props.cam_vec, car_props.joystick,
                                    car_props.track_waypoints)
     cargfx_props = CarGfxProps(car_props.model_name,
                                car_props.damage_paths,
                                car_props.wheel_gfx_names,
                                car_props.particle_path)
     carphys_props = CarPhysProps(
         car_props.coll_path, car_props.coll_name,
         car_props.race.track.phys.model, car_props.phys_file,
         car_props.wheel_names, car_props.tuning_engine,
         car_props.tuning_tires, car_props.tuning_suspensions,
         car_props.driver_engine, car_props.driver_tires,
         car_props.driver_suspensions, car_props.car_names)
     carfsm_props = CarFsmProps(car_props.road_name,
                                car_props.track_waypoints,
                                car_props.car_names)
     carevent_props = CarEventProps(
         car_props.keys, car_props.joystick, car_props.rocket_path,
         car_props.respawn_name, car_props.pitstop_name,
         car_props.road_name, car_props.wall_name, car_props.goal_name,
         car_props.bonus_name, car_props.roads_names)
     init_lst = [[('fsm', self.fsm_cls, [self, carfsm_props])],
                 [('gfx', self.gfx_cls, [self, cargfx_props]),
                  ('phys', self.phys_cls, [self, carphys_props]),
                  ('gui', self.gui_cls, [self, gui_props]),
                  ('event', self.event_cls, [self, carevent_props]),
                  ('logic', self.logic_cls, [self, carlogic_props]),
                  ('ai', self.ai_cls, [
                      self, car_props.road_name, car_props.track_waypoints,
                      car_props.car_names
                  ])], [('audio', self.audio_cls, [self, audio_props])]]
     GameObject.__init__(self, init_lst, car_props.callback)
コード例 #10
0
 def __init__(self, track_props):
     LogMgr().log('init track')
     self.props = t_p = track_props
     trackphys_props = TrackPhysProps(
         t_p.coll_path, t_p.unmerged, t_p.merged, t_p.ghosts,
         t_p.corner_names, t_p.waypoint_names, t_p.show_waypoints,
         t_p.weapons, t_p.weapon_names, t_p.start, t_p.bonus_model,
         t_p.bonus_suff)
     trackgfx_props = TrackGfxProps(
         t_p.name, t_p.track_path, t_p.model_name, t_p.empty_name,
         t_p.anim_name, t_p.omni_tag, t_p.shaders, t_p.sign_cb,
         t_p.sign_name, t_p.shadow_src)
     init_lst = [
         [('phys', TrackPhys, [self, trackphys_props]),
          ('gfx', TrackGfx, [self, trackgfx_props])],
         [('event', TrackEvent, [self, t_p.shaders, t_p.shadow_src])],
         [('audio', TrackAudio, [self, t_p.music_path])]]
     GameObject.__init__(self, init_lst, t_p.callback)
コード例 #11
0
 def exitMenu(self):
     LogMgr().log('exiting Menu state')
     self.__menu.destroy()
     self.mdt.audio.menu_music.stop()
コード例 #12
0
 def exitRace(self):
     LogMgr().log('exiting Race state')
     self.mdt.logic.season.race.destroy()
     base.accept('escape-up', self.demand, ['Exit'])
コード例 #13
0
ファイル: phys.py プロジェクト: PlumpMath/yyagl
 def __load(self, names, merged, ghost):
     for geom_name in names:
         LogMgr().log('setting physics for: ' + geom_name)
         geoms = PhysMgr().find_geoms(self.model, geom_name)
         if geoms:
             self.__process_meshes(geoms, geom_name, merged, ghost)
コード例 #14
0
ファイル: fsm.py プロジェクト: PlumpMath/yyagl
 def exitPlay():
     LogMgr().log('exiting Play state')
     eng.show_cursor()
コード例 #15
0
ファイル: fsm.py プロジェクト: PlumpMath/yyagl
 def enterPlay(self):
     LogMgr().log('entering Play state')
     cars = [self.mdt.logic.player_car] + self.mdt.logic.cars
     map(lambda car: car.demand('Play'), cars)