本文整理汇总了Python中GameState.get_equipped_in_slot方法的典型用法代码示例。如果您正苦于以下问题:Python GameState.get_equipped_in_slot方法的具体用法?Python GameState.get_equipped_in_slot怎么用?Python GameState.get_equipped_in_slot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameState
的用法示例。
在下文中一共展示了GameState.get_equipped_in_slot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: equip
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import get_equipped_in_slot [as 别名]
def equip(self):
# if the slot is already being used, dequip whatever is there first
old_equipment = GameState.get_equipped_in_slot(self.slot)
if old_equipment is not None:
old_equipment.dequip()
# equip object and show a message about it
self.is_equipped = True
Utils.message('Equipped ' + self.owner.name + ' on ' + self.slot + '.', libtcod.light_green)
示例2: pick_up
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import get_equipped_in_slot [as 别名]
def pick_up(self):
# add to the player's inventory and remove from the map
if len(GameState.inventory) >= 26:
Utils.message('Your inventory is full, cannot pick up ' + self.owner.name + '.', libtcod.red)
else:
GameState.inventory.append(self.owner)
GameState.current_level.get_all_objects().remove(self.owner)
Utils.message('You picked up a ' + self.owner.name + '!', libtcod.green)
# special case: automatically equip, if the corresponding equipment slot is unused
equipment = self.owner.equipment
if equipment and GameState.get_equipped_in_slot(equipment.slot) is None:
equipment.equip()