本文整理匯總了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