当前位置: 首页>>代码示例>>Python>>正文


Python SimpleXMLSerializer._deserializeList方法代码示例

本文整理汇总了Python中fife.extensions.serializers.simplexml.SimpleXMLSerializer._deserializeList方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleXMLSerializer._deserializeList方法的具体用法?Python SimpleXMLSerializer._deserializeList怎么用?Python SimpleXMLSerializer._deserializeList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fife.extensions.serializers.simplexml.SimpleXMLSerializer的用法示例。


在下文中一共展示了SimpleXMLSerializer._deserializeList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: NPC

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import _deserializeList [as 别名]
class NPC(Agent):
	def __init__(self, settings, model, agentName, layer, world, uniqInMap=True, name=""):
		super(NPC, self).__init__(settings, model, agentName, layer, uniqInMap)
		self._state = _STATE_NONE
		self._name = name
		self._agentName = agentName
		self._layer = layer
		self._availableActions = { 'walk': False,
					   'run': False,
					   'talk': False,
					   'die': False,
					   'explode': False,
					   'holdgun': False,
					   'firegun': False,
					   'beshot': False,
					   'walkgun': False,
					   'rungun': False,
					   'diegun': False,
					   'beshotgun': False,
					   'holdpistol': False,
					   'aimpistolleft': False,
					   'aimpistolright': False,
					   'firepistolleft': False,
					   'firepistolright': False,
					   'walkpistol': False,
					   'runpistol': False,
					   'diepistol': False,
					   'beshotpistol': False,
					   'teleportstart': False,
					   'teleportend': False,
					   'glitch': False,
					   'describe' : True}
		self._action = { 'walk': self.walk,
				 'run': self.run,
				 'talk': self.talk,
				 'die': self.die,
				 'explode': self.explode,
				 'holdgun': self._idle,
				 'firegun': self.fire,
				 'beshot': self.beshot,
				 'walkgun': self.walk,
				 'rungun': self.run,
				 'diegun': self.die,
				 'beshotgun': self.beshot,
				 'holdpistol': self._idle,
				 'aimpistolleft': self.aimleft,
				 'aimpistolright': self.aimright,
				 'firepistolleft': self.fireleft,
				 'firepistolright': self.fireright,
				 'walkpistol': self.walk,
				 'runpistol': self.run,
				 'diepistol': self.die,
				 'beshotpistol': self.beshot,
				 'teleportstart': self.teleportstart,
				 'teleportend': self.teleportend,
				 'glitch': self.glitch,
				 'decribe' : self.describe }
		self._world = world
		self._loadNPC(self._name)
		
	def _loadNPC(self, name):
		self._npcFile = SimpleXMLSerializer(filename="npcs/" + name + ".xml")
		actionstr = self._npcFile.get("npc", "actions", None)
		actions = self._npcFile._deserializeDict(actionstr)
		for action, bool in actions.iteritems():
			if bool == "True":
				self._availableActions[action] = True
			else:
				self._availableActions[action] = False
		self._actionchance = self._npcFile.get("npc", "actionchance", 0)
		self._description = self._npcFile.get("npc", "description", "I can see a mysterious figure,\n but I can't quite make them out.")
		self._autowalk = self._npcFile.get("npc", "autowalk", True)
		self._hasdialogue = self._npcFile.get("npc", "hasdialogue", False)
		self._autowalk = self._npcFile.get("npc", "autowalk", True)
		self._loadDialogue()
		self._idle()
	
	def _loadDialogue(self):
		if not self._hasdialogue:
			return
		self._dialogue = {}
		self._idledialogue = []
		index = []
		index = self._npcFile._deserializeList(self._npcFile.get("dialogue", "index", ""))
		for line in index:
			self._dialogue[line] = self._npcFile._deserializeDict(self._npcFile.get("dialogue", line, ""))
		idleindex = self._npcFile._deserializeList(self._npcFile.get("dialogue", "idleindex", ""))
		for line in idleindex:
			self._idledialogue.append(self._dialogue[line])
	
	def _listAvailableTopics(self):
		returninglist = []
		if not self._hasdialogue:
			return returninglist
		for index, dialogue in self._dialogue.iteritems():
			if dialogue["requires"] in self._world._player._plots or dialogue["requires"] == '0' and dialogue not in self._idledialogue:
				returninglist.append((index, dialogue["topic"]))
		return returninglist
	
	def _talk(self, index):
#.........这里部分代码省略.........
开发者ID:Drakekin,项目名称:Zero-Sum-Cascade-Old,代码行数:103,代码来源:npc.py

示例2: InteractiveObject

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import _deserializeList [as 别名]
class InteractiveObject(fife.InstanceActionListener):
	def __init__(self, objectmanager, model, file):
		fife.InstanceActionListener.__init__(self)
		self._manager = objectmanager
		self._model = model
		self._objectFile = SimpleXMLSerializer(file)
		self._agentName = self._objectFile.get("object", "agentname", "dummy")
		self._layer = self._manager._world._map.getLayer(self._objectFile.get("object", "layer", "player"))
		self._agent = self._layer.getInstance(self._agentName)
		self._agent.addActionListener(self)
		self._status = self._objectFile.get("object", "status", 'INACTIVE')
		
		self._actions = { 'use' : self.use,
				  'destroy' : self.destroy,
				  'turnon' : self.activate,
				  'turnoff' : self.deactivate,
				  'explode' : self.explode,
				  'describe': self.describe,
				  'glitch' : self.glitch }
		self._availableactions = { 'use' : False,
					   'destroy' : False,
					   'turnon' : False,
					   'turnoff' : False,
					   'explode' : False,
					   'describe' : True,
					   'glitch' : False }
		
		actionstr = self._objectFile.get("object", "actions", None)
		actions = self._objectFile._deserializeDict(actionstr)
		for action, bool in actions.iteritems():
			if bool in ("True"):
				self._availableactions[action] = True
			else:
				self._availableactions[action] = False
		self._description = self._objectFile.get("object", "description", "I can see something, but\n I can't tell what it is")
		self._talk = self._objectFile.get("object", "talk", False)
		self._message = self._objectFile._deserializeList(self._objectFile.get("object", "messages", ""))
		self._usesound = self._objectFile.get("object", "sound", False)
		if self._usesound:
			self._manager._world._sounds._loadclip(self._agentName, self._objectFile.get("object", "soundfile", ""), False, False)
			self._sound = self._manager._world._sounds._emitters[self._agentName]
		self._loadObject()
		self.onInstanceActionFinished(self._agent, "")
	
	def onInstanceActionFinished(self, instance, action):
		if self._status == 'ACTIVE':
			self._agent.act('on', self._agent.getFacingLocation())
		elif self._status == 'INACTIVE':
			self._agent.act('off', self._agent.getFacingLocation())
		elif self._status == 'DESTROYED':
			self._agent.act('dead', self._agent.getFacingLocation())
		elif self._status == 'GLITCHED':
			self._agent.act('glitch', self._agent.getFacingLocation())
	
	def use(self):
		if self._status == 'ACTIVE':
			self._agent.act('use', self._agent.getFacingLocation())
			self._manager._world._player._agent.setFacingLocation(self._agent.getLocation())
			if self._noactioncallbacks == 0:
				self._action()
			elif self._noactioncallbacks == 1:
				self._action(self._actioncallbacks[0])
			elif self._noactioncallbacks == 2:
				self._action(self._actioncallbacks[0], self._actioncallbacks[1])
			elif self._noactioncallbacks == 3:
				self._action(self._actioncallbacks[0], self._actioncallbacks[1], self._actioncallbacks[2])
			elif self._noactioncallbacks == 4:
				self._action(self._actioncallbacks[0], self._actioncallbacks[1], self._actioncallbacks[2], self._actioncallbacks[3])
			elif self._noactioncallbacks == 5:
				self._action(self._actioncallbacks[0], self._actioncallbacks[1], self._actioncallbacks[2], self._actioncallbacks[3], self._actioncallbacks[4])
			if self._talk:
				rand = random.randint(0, len(self._message) - 1)
				self._manager._world._player._agent.say(self._message[rand], 3500)
			if self._usesound:
				self._sound.play()

	def destroy(self):
		self._agent.act('die', self._agent.getFacingLoaction)
		self._status = 'DESTROYED'
	
	def activate(self):
		self._agent.act('turnon', self._agent.getFacingLoaction)
		self._status = 'ACTIVE'
	
	def deactivate(self):
		self._agent.act('turnoff', self._agent.getFacingLoaction)
		self._status = 'INACTIVE'
	
	def explode(self):
		self._agent.act('explode', self._agent.getFacingLoaction)
		self._status = 'DESTROYED'
	
	def describe(self):
		self._manager._world._player._agent.say(self._description, 5000)
	
	def glitch(self):
		self._agent.act('glitch', self._agent.getFacingLoaction)
		self._status = 'GLITCHED'
		
	def noAction(self):
#.........这里部分代码省略.........
开发者ID:Drakekin,项目名称:Zero-Sum-Cascade-Old,代码行数:103,代码来源:objectmanager.py

示例3: World

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import _deserializeList [as 别名]

#.........这里部分代码省略.........
			camera_id = cam.getId()
			# Add the camera with that ID to the array
			self._cameras[camera_id] = cam
			# Reset the camera
			cam.resetRenderers()
			
		if purpose == 'LEVEL':
			# Start the player character
			self._startPlayerActor()
			if location != None:
				self._player._agent.setLocation(location)
			if direction != None:
				self._player._agent.setFacingLocation(direction)
			if self._hud != None:
				self._hud.show()
			
			self._loadLevelMapCallback("", 0.775)
		
		# Start the floating text renderer
		renderer = fife.FloatingTextRenderer.getInstance(self._cameras['main'])
		textfont = self._engine.getGuiManager().createFont('fonts/rpgfont.png', 0, str(self._setting.get("FIFE", "FontGlyphs")))
		renderer.changeDefaultFont(textfont)
		renderer.setDefaultBackground(0,0,0,0)
		renderer.setDefaultBorder(0,0,0,0)
		renderer.activateAllLayers(self._map)
		renderer.setEnabled(True)
		
		if purpose == 'LEVEL':
			self._loadLevelMapCallback("", 0.8)
		else:
			self._loadMenuMapCallback("", 0.8)
	
		if self._mapsettings.get("map", "usewaypoints", False):
			self._waypoints = self._mapsettings._deserializeList(self._mapsettings.get("map", "waypoints", ""))
		else:
			self._waypoints = None

		if purpose == 'LEVEL':
			self._loadLevelMapCallback("", 0.825)
		else:
			self._loadMenuMapCallback("", 0.825)
		
		if self._mapsettings.get("map", "useobjects", False):
			self._objects = objectmanager.ObjectManager(self)
			objlist = self._mapsettings._deserializeList(self._mapsettings.get("map", "objectlist", False))
			for file in objlist:
				self._objects._loadObjects(file)
		
		if purpose == 'LEVEL':
			self._loadLevelMapCallback("", 0.85)
		else:
			self._loadMenuMapCallback("", 0.85)
		
		if self._mapsettings.get("map", "dynamicnpcs", False):
			self._npclist = self._mapsettings._deserializeDict(self._mapsettings.get("map", "npclist", False))
			if self._npclist != False:
				for id, name in self._npclist.iteritems():
					self._npcs[name] = npc.NPC(self._setting, self._model, id, self._map.getLayer('player'), self, True, name)
		
		if purpose == 'LEVEL':
			self._loadLevelMapCallback("", 0.9)
		else:
			self._loadMenuMapCallback("", 0.9)
		
		self._eventtracker = eventtracker.EventTracker(self._engine, self._model, self._sounds, self)
		if self._mapsettings.get("map", "useevents", False):
开发者ID:Drakekin,项目名称:Zero-Sum-Cascade-Old,代码行数:70,代码来源:world.py


注:本文中的fife.extensions.serializers.simplexml.SimpleXMLSerializer._deserializeList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。