本文整理汇总了Python中ComponentManager.ComponentManager.get_Components方法的典型用法代码示例。如果您正苦于以下问题:Python ComponentManager.get_Components方法的具体用法?Python ComponentManager.get_Components怎么用?Python ComponentManager.get_Components使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComponentManager.ComponentManager
的用法示例。
在下文中一共展示了ComponentManager.get_Components方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: take_turn
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Components [as 别名]
def take_turn(self):
elephantcreature = CM.get_Component('Creature', self.ElephantId)
elephantcoord = CM.get_Component('Coord', self.ElephantId)
elephanttile = CM.get_Component('Tile', self.ElephantId)
playercoord = CM.get_Component('Coord', config.PlayerId)
disttoplayer = hypot(elephantcoord.X - playercoord.X,
elephantcoord.Y - playercoord.Y)
if disttoplayer < elephantcreature.VisionRange and \
coordfov(elephantcoord, playercoord):
if int(disttoplayer) <= 1:
if not self.resting:
Attack_Coord(self.BasicAttackId, self.ElephantId,
playercoord)
self.resting = True
else:
self.resting = False
Message('The ' + elephanttile.TileName +
' rests this turn instead of attacking.',
color=Color.yellow)
else:
self.resting = False
direction = MC.Get_Direction_To(elephantcoord, playercoord)
if not MC.Walk_Direction(self.ElephantId, direction):
directions = MC.Get_Alt_Direction_To(direction)
if not MC.Walk_Direction(self.ElephantId, directions[0]):
MC.Walk_Direction(self.ElephantId, directions[1])
else:
tiles = CM.dict_of('Tile')
elephantids = []
for key, value in tiles.iteritems():
if value.TileName == 'Elephant' or \
value.TileName == 'Pink Elephant':
if key != self.ElephantId:
elephantids.append(key)
elephantcoords = CM.get_Components('Coord', elephantids)
shortestdist = (False, elephantcreature.VisionRange)
for key, coord in elephantcoords.iteritems():
dist = hypot(
elephantcoord.X - coord.X, elephantcoord.Y - coord.Y)
if dist < shortestdist[1] and dist > 1.5:
shortestdist = (coord, dist)
if shortestdist[0]:
direction = MC.Get_Direction_To(elephantcoord, shortestdist[0])
if not MC.Walk_Direction(self.ElephantId, direction):
directions = MC.Get_Alt_Direction_To(direction)
if not MC.Walk_Direction(self.ElephantId, directions[0]):
MC.Walk_Direction(self.ElephantId, directions[1])
else:
direction = random.choice([D.N, D.S, D.E, D.W,
D.NE, D.NW, D.SE, D.SW])
MC.Walk_Direction(self.ElephantId, direction)
示例2: take_turn
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Components [as 别名]
def take_turn(self):
dogcreature = CM.get_Component('Creature', self.DogId)
dogcoord = CM.get_Component('Coord', self.DogId)
playercoord = CM.get_Component('Coord', config.PlayerId)
disttoplayer = hypot(dogcoord.X - playercoord.X,
dogcoord.Y - playercoord.Y)
if disttoplayer < dogcreature.VisionRange and \
coordfov(dogcoord, playercoord):
if int(disttoplayer) <= 1:
Attack_Coord(self.BasicAttackId, self.DogId, playercoord)
else:
direction = MC.Get_Direction_To(dogcoord, playercoord)
if not MC.Walk_Direction(self.DogId, direction):
directions = MC.Get_Alt_Direction_To(direction)
if not MC.Walk_Direction(self.DogId, directions[0]):
MC.Walk_Direction(self.DogId, directions[1])
else:
tiles = CM.dict_of('Tile')
dogids = []
for key, value in tiles.iteritems():
if value.TileName == 'Dog' or \
value.TileName == 'Rabid Dog':
if key != self.DogId:
dogids.append(key)
dogcoords = CM.get_Components('Coord', dogids)
shortestdist = (False, dogcreature.VisionRange)
for key, coord in dogcoords.iteritems():
dist = hypot(dogcoord.X - coord.X, dogcoord.Y - coord.Y)
if dist < shortestdist[1] and dist > 1.5:
shortestdist = (coord, dist)
if shortestdist[0]:
direction = MC.Get_Direction_To(dogcoord, shortestdist[0])
if not MC.Walk_Direction(self.DogId, direction):
directions = MC.Get_Alt_Direction_To(direction)
if not MC.Walk_Direction(self.DogId, directions[0]):
MC.Walk_Direction(self.DogId, directions[1])
else:
direction = random.choice([D.N, D.S, D.E, D.W,
D.NE, D.NW, D.SE, D.SW])
MC.Walk_Direction(self.DogId, direction)