本文整理汇总了Python中ComponentManager.ComponentManager.check_Component方法的典型用法代码示例。如果您正苦于以下问题:Python ComponentManager.check_Component方法的具体用法?Python ComponentManager.check_Component怎么用?Python ComponentManager.check_Component使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComponentManager.ComponentManager
的用法示例。
在下文中一共展示了ComponentManager.check_Component方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Walk_Direction
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import check_Component [as 别名]
def Walk_Direction(creatureid, direction):
cCoord = CM.get_Component('Coord', creatureid)
newCoord = Coord(cCoord.X + direction.X, cCoord.Y + direction.Y)
Coords = CM.dict_of('Coord')
walkable = True
for key, value in Coords.iteritems():
if value == newCoord:
if CM.check_Component('Tile', key):
tile = CM.get_Component('Tile', key)
if not tile.Passable:
walkable = False
if walkable:
cCoord.X = newCoord.X
cCoord.Y = newCoord.Y
return True
else:
return False
示例2: Teleport_Random
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import check_Component [as 别名]
def Teleport_Random(creatureid):
cCoord = CM.get_Component('Coord', creatureid)
x = randint(1, config.playscreen_width - 1)
y = randint(1, config.playscreen_height - 1)
newCoord = Coord(x, y)
Coords = CM.dict_of('Coord')
walkable = True
for key, value in Coords.iteritems():
if value == newCoord:
if CM.check_Component('Tile', key):
tile = CM.get_Component('Tile', key)
if not tile.Passable:
walkable = False
if walkable:
cCoord.X = newCoord.X
cCoord.Y = newCoord.Y
else:
Teleport_Random(creatureid)
示例3: Blink_Random_Failable
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import check_Component [as 别名]
def Blink_Random_Failable(creatureid, mindist=4, maxdist=10):
cCoord = CM.get_Component('Coord', creatureid)
x = randint(mindist, maxdist) * choice([-1, 1])
y = randint(mindist, maxdist) * choice([-1, 1])
newCoord = Coord(cCoord.X + x, cCoord.Y + y)
while newCoord.X < 1 or newCoord.X > config.playscreen_width - 3 or \
newCoord.Y < 1 or newCoord.Y > config.playscreen_height - 3:
x = randint(mindist, maxdist) * choice([-1, 1])
y = randint(mindist, maxdist) * choice([-1, 1])
newCoord = Coord(cCoord.X + x, cCoord.Y + y)
Coords = CM.dict_of('Coord')
walkable = True
for key, value in Coords.iteritems():
if value == newCoord:
if CM.check_Component('Tile', key):
tile = CM.get_Component('Tile', key)
if not tile.Passable:
walkable = False
if walkable:
cCoord.X = newCoord.X
cCoord.Y = newCoord.Y