Ejemplo n.º 1
0
 def _set_cycle_text(self, cycle):
     self._scene.add_action(
         scene_actions.ChangeText(ref=self._top_panel_ref,
                                  child_ref=self._cycle_text_ref,
                                  text='Cycle: {:d}/{:d}'.format(
                                      cycle,
                                      self._world.constants.max_cycles)))
Ejemplo n.º 2
0
    def update_statuses(self, current_cycle):
        # Cycle
        self._set_cycle_text(current_cycle)

        # Scores
        self._scene.add_action(
            scene_actions.ChangeText(cycle=self._eat_delay,
                                     ref=self._top_panel_ref,
                                     child_ref=self._pacman_score_ref,
                                     text=str(self._world.scores['Pacman'])))

        self._scene.add_action(
            scene_actions.ChangeText(cycle=self._eat_delay,
                                     ref=self._top_panel_ref,
                                     child_ref=self._ghost_score_ref,
                                     text=str(self._world.scores['Ghost'])))
Ejemplo n.º 3
0
 def _set_text(self, child_ref, text, reference=None, cycle=None):
     reference = reference if reference != None else self._top_panel_ref
     self._scene.add_action(
         scene_actions.ChangeText(ref=reference,
                                  cycle=cycle,
                                  child_ref=child_ref,
                                  text=text))
Ejemplo n.º 4
0
 def update_super_text(self, remaining_time):
     self._scene.add_action(
         scene_actions.ChangeText(
             ref=self._top_panel_ref,
             child_ref=self._super_text_ref,
             text=str(remaining_time) if remaining_time > 0 else ''))
Ejemplo n.º 5
0
 def _change_text(self, reference, child_ref, cycle, text):
     self._scene.add_action(
         scene_actions.ChangeText(ref=reference,
                                  child_ref=child_ref,
                                  cycle=cycle,
                                  text=text))
Ejemplo n.º 6
0
    def _draw_agents(self):
        for side in self._sides:
            agents = self._world.polices if side == 'Police' else self._world.terrorists
            skins = self.POLICE_SKINS if side == 'Police' else self.TERRORIST_SKINS
            material_offsets = self.POLICE_MATERIAL_OFFSETS if side == 'Police' else self.TERRORIST_MATERIAL_OFFSETS
            heads = self.POLICE_HEADS if side == 'Police' else self.TERRORIST_HEADS
            items = self.POLICE_ITEMS if side == 'Police' else self.TERRORIST_ITEMS

            for agent in agents:
                reference = self._rm.new()
                self._agents_ref[side][agent.id] = reference

                self._scene.add_action(
                    scene_actions.InstantiateBundleAsset(
                        ref=reference,
                        asset=scene_actions.Asset(bundle_name='main',
                                                  asset_name=side)))

                # set ID
                self._scene.add_action(
                    scene_actions.ChangeText(
                        ref=reference,
                        child_ref=
                        'Root/Hips/Spine_01/Spine_02/Spine_03/Neck/Head/Canvas/ID',
                        text=str(agent.id)))

                # set appearance
                skin = skins[agent.id % len(skins)]
                self._scene.add_action(
                    scene_actions.ChangeIsActive(
                        ref=reference,
                        child_ref='Skin/{0}'.format(skin),
                        is_active=True))

                material_num = (
                    ((agent.id // len(material_offsets)) +
                     material_offsets[agent.id % len(material_offsets)]) %
                    self.TOTAL_SKINS_MATERIALS) + 1
                self._scene.add_action(
                    scene_actions.ChangeMaterial(
                        ref=reference,
                        child_ref='Skin/{0}'.format(skin),
                        material_asset=scene_actions.Asset(
                            bundle_name='main',
                            asset_name='Material{:d}'.format(material_num)),
                        index=0))

                for head in heads[agent.id % len(heads)]:
                    if head == None:
                        continue
                    self._scene.add_action(
                        scene_actions.ChangeIsActive(
                            ref=reference,
                            child_ref=
                            'Root/Hips/Spine_01/Spine_02/Spine_03/Neck/Head/HeadMask/{0}'
                            .format(head),
                            is_active=True))

                for item in items[agent.id % len(items)]:
                    if item == None:
                        continue
                    self._scene.add_action(
                        scene_actions.ChangeIsActive(
                            ref=reference,
                            child_ref='Root/Hips/Items/{0}'.format(item),
                            is_active=True))

                self._scene.add_action(
                    scene_actions.ChangeIsActive(
                        ref=reference,
                        child_ref=
                        'Root/Hips/Spine_01/Spine_02/Spine_03/Clavicle_R/Shoulder_R/Elbow_R/Hand_R/{0}'
                        .format(side + 'Rifle'),
                        is_active=True))

                # set position
                self._agents_direction[side][agent.id] = agent.init_direction
                self._move_xz(reference, None, None, agent.position)
                self._turn_y(reference, None, None,
                             self.DIR_TO_ANGLE[agent.init_direction.name])