当前位置: 首页>>代码示例>>Python>>正文


Python ComponentManager.get_Components方法代码示例

本文整理汇总了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)
开发者ID:Akhier,项目名称:12Down,代码行数:53,代码来源:Elephant.py

示例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)
开发者ID:Akhier,项目名称:12Down,代码行数:42,代码来源:Dog.py


注:本文中的ComponentManager.ComponentManager.get_Components方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。