Пример #1
0
	def initAgents(self):
		"""
		Setup agents.

		For this techdemo we have a very simple 'active things on the map' model,
		which is called agents. All rio maps will have a separate layer for them.

		Note that we keep a mapping from map instances (C++ model of stuff on the map)
		to the python agents for later reference.
		"""
		self.agentlayer = self.map.getLayer('TechdemoMapGroundObjectLayer')
		self.hero = Hero(TDS, self.model, 'PC', self.agentlayer)
		self.instance_to_agent[self.hero.agent.getFifeId()] = self.hero
		self.hero.start()

		self.girl = Girl(TDS, self.model, 'NPC:girl', self.agentlayer)
		self.instance_to_agent[self.girl.agent.getFifeId()] = self.girl
		self.girl.start()

		# Fog of War stuff
		#self.hero.agent.setVisitor(True)
		#self.hero.agent.setVisitorRadius(2)
		#self.girl.agent.setVisitor(True)
		#self.girl.agent.setVisitorRadius(1)

		self.beekeepers = create_anonymous_agents(TDS, self.model, 'beekeeper', self.agentlayer, Beekeeper)
		for beekeeper in self.beekeepers:
			self.instance_to_agent[beekeeper.agent.getFifeId()] = beekeeper
			beekeeper.start()

		# Clouds are currently defunct.
		cloudlayer = self.map.getLayer('TechdemoMapTileLayer')
		self.clouds = create_anonymous_agents(TDS, self.model, 'Cloud', cloudlayer, Cloud)
		for cloud in self.clouds:
			cloud.start(0.1, 0.05)
Пример #2
0
	def initAgents(self):
		"""
		Setup agents.

		For this techdemo we have a very simple 'active things on the map' model,
		which is called agents. All rio maps will have a separate layer for them.

		Note that we keep a mapping from map instances (C++ model of stuff on the map)
		to the python agents for later reference.
		"""
		self.agentlayer = self.map.getLayer('TechdemoMapGroundObjectLayer')
		self.hero = Hero(TDS, self.model, 'PC', self.agentlayer)
		self.instance_to_agent[self.hero.agent.getFifeId()] = self.hero
		self.hero.start()

		self.girl = Girl(TDS, self.model, 'NPC:girl', self.agentlayer)
		self.instance_to_agent[self.girl.agent.getFifeId()] = self.girl
		self.girl.start()

		self.beekeepers = create_anonymous_agents(TDS, self.model, 'beekeeper', self.agentlayer, Beekeeper)
		for beekeeper in self.beekeepers:
			self.instance_to_agent[beekeeper.agent.getFifeId()] = beekeeper
			beekeeper.start()

		# Clouds are currently defunct.
		cloudlayer = self.map.getLayer('TechdemoMapTileLayer')
		self.clouds = create_anonymous_agents(TDS, self.model, 'Cloud', cloudlayer, Cloud)
		for cloud in self.clouds:
			cloud.start(0.1, 0.05)
Пример #3
0
	def load(self, filename):
		self.filename = filename
		self.reset()
		self.map = loadMapFile(filename, self.engine)
		self.maplistener = MapListener(self.map)

		self.agentlayer = self.map.getLayer('TechdemoMapGroundObjectLayer')
		self.hero = Hero(self.model, 'PC', self.agentlayer)
		self.instance_to_agent[self.hero.agent.getFifeId()] = self.hero
		self.hero.start()

		self.girl = Girl(self.model, 'NPC:girl', self.agentlayer)
		self.instance_to_agent[self.girl.agent.getFifeId()] = self.girl
		self.girl.start()

		self.beekeepers = create_anonymous_agents(self.model, 'beekeeper', self.agentlayer, Beekeeper)
		for beekeeper in self.beekeepers:
			self.instance_to_agent[beekeeper.agent.getFifeId()] = beekeeper
			beekeeper.start()

		cloudlayer = self.map.getLayer('TechdemoMapTileLayer')
		self.clouds = create_anonymous_agents(self.model, 'Cloud', cloudlayer, Cloud)
		for cloud in self.clouds:
			cloud.start(0.1, 0.05)

		for cam in self.view.getCameras():
			self.cameras[cam.getId()] = cam
		self.cameras['main'].attach(self.hero.agent)

		self.view.resetRenderers()
		renderer = fife.FloatingTextRenderer.getInstance(self.cameras['main'])
		textfont = self.engine.getGuiManager().createFont('fonts/rpgfont.png', 0, str(TDS.readSetting("FontGlyphs", strip=False)));
		renderer.changeDefaultFont(textfont)

		renderer = fife.FloatingTextRenderer.getInstance(self.cameras['small'])
		renderer.changeDefaultFont(None)

		renderer = self.cameras['main'].getRenderer('CoordinateRenderer')
		renderer.clearActiveLayers()
		renderer.addActiveLayer(self.map.getLayer(str(TDS.readSetting("CoordinateLayerName"))))

		renderer = self.cameras['main'].getRenderer('QuadTreeRenderer')
		renderer.setEnabled(True)
		renderer.clearActiveLayers()
		if str(TDS.readSetting("QuadTreeLayerName")):
			renderer.addActiveLayer(self.map.getLayer(str(TDS.readSetting("QuadTreeLayerName"))))

		self.cameras['small'].getLocationRef().setExactLayerCoordinates( fife.ExactModelCoordinate( 40.0, 40.0, 0.0 ))
		self.initial_cam2_x = self.cameras['small'].getLocation().getExactLayerCoordinates().x
		self.cur_cam2_x = self.initial_cam2_x
		self.cam2_scrolling_right = True
		self.cameras['small'].setEnabled(False)

		self.target_rotation = self.cameras['main'].getRotation()
    def initAgents(self):
        """
        Setup agents.

        For this techdemo we have a very simple 'active things on the map' model,
        which is called agents. All rio maps will have a separate layer for them.

        Note that we keep a mapping from map instances (C++ model of stuff on the map)
        to the python agents for later reference.
        """
        self.agentlayer = self.map.getLayer('TechdemoMapGroundObjectLayer')
        self.hero = Hero(TDS, self.model, 'PC', self.agentlayer)
        self.instance_to_agent[self.hero.agent.getFifeId()] = self.hero
        self.hero.start()

        self.girl = Girl(TDS, self.model, 'NPC:girl', self.agentlayer)
        self.instance_to_agent[self.girl.agent.getFifeId()] = self.girl
        self.girl.start()
        
        self.bees = create_anonymous_agents(TDS, self.model, 'bee', self.agentlayer,Bee)
        for bee in self.bees:
            self.instance_to_agent[bee.agent.getFifeId()] = bee
            bee.start()
   
        self.beekeepers = create_anonymous_agents(TDS, self.model, 'beekeeper', self.agentlayer, Beekeeper)
        for beekeeper in self.beekeepers:
            self.instance_to_agent[beekeeper.agent.getFifeId()] = beekeeper
            beekeeper.start()
        
        self.tourist_male2 = create_anonymous_agents(TDS, self.model, 'tourist_male2',self.agentlayer, Tourist_male2)
        for tourist_male2 in self.tourist_male2:
            self.instance_to_agent[tourist_male2.agent.getFifeId()] = tourist_male2
            tourist_male2.start()

        self.hippie_priest = Hippie_priest(TDS, self.model, 'hippie_priest', self.agentlayer)
        self.instance_to_agent[self.hippie_priest.agent.getFifeId()] = self.hippie_priest
        self.hippie_priest.start()
Пример #5
0
    def initAgents(self):
        """
        Setup agents.

        For this techdemo we have a very simple 'active things on the map' model,
        which is called agents. All rio maps will have a separate layer for them.

        Note that we keep a mapping from map instances (C++ model of stuff on the map)
        to the python agents for later reference.
        """
        self.agentlayer = self.map.getLayer('TechdemoMapGroundObjectLayer')
        self.boy = Boy(TDS, self.model, 'PC', self.agentlayer, self.soundmanager, world = self)
        self.instance_to_agent[self.boy.agent.getFifeId()] = self.boy
        self.mainAgent = self.boy
        self.boy.start()

        self.girl = Girl(TDS, self.model, 'NPC:girl', self.agentlayer, self.soundmanager, world = self, looseCallback = self.loose, updateLifeCallback = self.gui.girlLifeUpdate)
        self.instance_to_agent[self.girl.agent.getFifeId()] = self.girl
        self.girl.start()

        self.priest = Priest(TDS, self.model, 'priest', self.agentlayer, self.soundmanager, world = self)
        self.instance_to_agent[self.priest.agent.getFifeId()] = self.priest
        self.priest.start()

        self.chemist = Chemist(TDS, self.model, 'chemist', self.agentlayer, self.soundmanager, world = self, winCallback=self.win)
        self.instance_to_agent[self.chemist.agent.getFifeId()] = self.chemist
        self.chemist.start()

        self.bees = []
        for i in xrange(num_bees):
            bee = Bee(TDS, self.model, 'bee' + str(i), self.agentlayer, self.soundmanager, girl = self.girl)
            self.instance_to_agent[bee.agent.getFifeId()] = bee
            bee.start()
            self.bees.append(bee)

        for i in xrange(12):
            dynamite = Dynamite(TDS, self.model, 'dyn_' + str(i), self.agentlayer, self.soundmanager, bees=self.bees, girl=self.girl)
            self.instance_to_agent[dynamite.agent.getFifeId()] = dynamite
            dynamite.start()

        self.beekeepers = create_anonymous_agents(TDS, self.model, 'beekeeper', self.agentlayer, Beekeeper, self.soundmanager)
        for beekeeper in self.beekeepers:
            self.instance_to_agent[beekeeper.agent.getFifeId()] = beekeeper
            beekeeper.start()
            
        moveObject(self.agentlayer.getInstance('flask0'), x=3.5, y=9.5)
        moveObject(self.agentlayer.getInstance('coins0'), x=-18, y=-15)
        moveObject(self.agentlayer.getInstance('coins1'), x=-22.5, y=-14.5)
        moveObject(self.agentlayer.getInstance('coins2'), x=-18, y=-14.5)