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


Python Inventory.getCell方法代码示例

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


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

示例1: Scene

# 需要导入模块: from inventory import Inventory [as 别名]
# 或者: from inventory.Inventory import getCell [as 别名]

#.........这里部分代码省略.........
						elif event.key in hero.MAGIC_KEYS:
							self._hero.setSpell(hero.KEY_MAP[event.key])

					if event.type in (MOUSEMOTION, MOUSEBUTTONDOWN, MOUSEBUTTONUP):
						for submodule in self._submodules:
							if submodule.getRectangle().collidepoint(event.pos):
								x, y, _, _ = submodule.getRectangle()
								_pos = event.pos[0] - x, event.pos[1] - y

							else:
								_pos = None

							submodule.mouseEvent(event, _pos)
							if submodule == self._map and event.type == MOUSEBUTTONDOWN and _pos: # obsługa otwierania skrzynki(głównie)
								_field = self._map.getLayer('Fields').get(_pos, True)
								if _field:
									_field.getLogic().clicked(self, self._hero)

							if submodule == self._map and event.type == MOUSEBUTTONUP and event.button == 1 and _pos: # upuszczanie przedmiotu
								_field = self._map.getLayer('Fields').get(_pos, True)
								if _field:
									_field = _field.getLogic()

								if _field and utils.distance(_field.getGrid()[:2], self._hero.getGrid()[:2]) <= 1:
									for _obj in self._freeobjects:
										if not _obj.attach(_field):
											_obj.attach(_obj.getAttached())
								else:
									for _obj in self._freeobjects:
										_obj.attach(_obj.getAttached())

							if submodule == self.inventory and event.type == MOUSEBUTTONUP and event.button == 1 and _pos: # ↑
								for _obj in self._freeobjects:
									if not _obj.attach(self.inventory.getCell(_pos)):
										_obj.attach(_obj.getAttached())

							if submodule == self.chestitems and event.type == MOUSEBUTTONUP and event.button == 1 and _pos: # ↑
								for _obj in self._freeobjects:
									if not self.chestitems.opened or not _obj.attach(self.chestitems.getCell(_pos)):
										_obj.attach(_obj.getAttached())

						for _obj in self._freeobjects:
							_obj.mouseEvent(event)

						if event.type == MOUSEBUTTONDOWN and event.button == 3 and self._map.getRectangle().collidepoint(event.pos): # rzucanie czaru
							self._hero.castSpell()

						if event.type == MOUSEBUTTONDOWN and event.button == 1 and self._map.getRectangle().collidepoint(event.pos): # atak
							self._hero.punch()

				if self._hero.getGrid()[2] != self._map.getStorey(): # zmiana poziomu lochu
					self._map.removeLayer('Missiles')
					self._map.addLayer('Missiles', 3, MissilesLayer(self._map))
					self._map.switchStorey(self._hero.getGrid()[2] - self._map.getStorey())
					self._shadow.clear()
					for _id, _ in self._actual:
						self._creatureLayer.remove(_id)

					self._actual = []
					_counter = 0
					_storey = self._map.getStorey()
					for _name, _monster in self._monsters:
						if _monster.getGrid()[2] == _storey:
							self._creatureLayer.add(_name + '_' + str(_counter), _monster.getSprite(self._creatureLayer, _name + '_' + str(_counter)))
							self._actual.append((_name + '_' + str(_counter), _monster))
							_monster.move((0, 0, 0))
开发者ID:Neverous,项目名称:ii-python11,代码行数:70,代码来源:scene.py


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