本文整理汇总了Python中inventory.Inventory.open方法的典型用法代码示例。如果您正苦于以下问题:Python Inventory.open方法的具体用法?Python Inventory.open怎么用?Python Inventory.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inventory.Inventory
的用法示例。
在下文中一共展示了Inventory.open方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Actor
# 需要导入模块: from inventory import Inventory [as 别名]
# 或者: from inventory.Inventory import open [as 别名]
class Actor(movable_object.Movable_Object):
is_event_handler = True
def __init__(self, body):
cshape = cm.AARectShape(eu.Vector2(0, 0), TILE_SIZE_IN_PIXELS / 2, body.img.height / 2)
super(Actor, self).__init__(body.img, cshape=cshape)
self.fight_group = -1
self.direction = 1
self.owner = self
self.body = body(self)
self.launcher = Launcher(self)
self.state = "stand"
self.inventory = Inventory(self)
self.ground_count = 0
self.on_ground = False
self.recovery = 0.0 # Time before moment when acton can be controlled again
height = property(lambda self: self.body.img.height)
width = property(lambda self: self.body.img.width)
def setup_b2body(self):
super(Actor, self).setup_b2body()
pix_to_tile = pixels_to_tiles
rx, ry = pix_to_tile((self.cshape.rx, self.cshape.ry))
self.b2body.CreateFixture(
b2.b2FixtureDef(
shape=b2.b2PolygonShape(
vertices=[(-rx, ry), (-rx, -ry + 0.1), (-rx + 0.1, -ry), (rx - 0.1, -ry), (rx, -ry + 0.1), (rx, ry)]
)
)
)
self.b2body.fixtures[-1].filterData.categoryBits = B2SMTH | B2ACTOR
self.b2body.CreateFixture(
b2.b2FixtureDef(shape=b2.b2EdgeShape(vertex1=(-rx, -ry), vertex2=(rx, -ry)), isSensor=True)
)
self.b2body.fixtures[-1].filterData.categoryBits = B2GNDSENS
self.b2body.fixtures[-1].filterData.maskBits = B2LEVEL | B2ACTOR
self.world.addEventHandler(self.b2body.fixtures[-1], self.on_ground_begin, self.on_ground_end)
def use_item(self, item_type, trigger, args): # MAIN or SECONDARY
if item_type is MAIN:
item = self.inventory.main_item
else:
item = self.inventory.secondary_item
if not item:
return
if trigger and not item.on_use and item.available:
item.start_use(*args)
elif trigger and item.on_use and item.available:
item.continue_use(*args)
elif not trigger and item.on_use and item.available:
item.end_use(*args)
def start_interact_with_item(self, item):
if item and item.item_update:
self.schedule(item.item_update)
def stop_interact_with_item(self, item):
if item and item.item_update:
self.unschedule(item.item_update)
def collide(self, other):
other._collide_actor(self)
def _collide_actor(self, other):
coll.collide_actor_actor(self, other)
def _collide_hit_zone(self, other):
coll.collide_actor_hit_zone(self, other)
def _collide_slash(self, other):
coll.collide_actor_slash(self, other)
def activate_trigger(self, trigger):
self.dispatch_event("on_activate_trigger", trigger, self)
def put_item(self, item):
self.inventory.put_item(item)
def open(self):
self.inventory.open()
def close(self):
self.inventory.close()
def destroy(self):
"""
Remove Actor from level
"""
if self.fight_group > 0:
for armor in filter(lambda x: (x.attached is not None), self.body.body_parts):
armor.attached.drop()
self.fight_group = -1
#.........这里部分代码省略.........