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


Python ComponentManager.ComponentManager类代码示例

本文整理汇总了Python中ComponentManager.ComponentManager的典型用法代码示例。如果您正苦于以下问题:Python ComponentManager类的具体用法?Python ComponentManager怎么用?Python ComponentManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ComponentManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: take_turn

 def take_turn(self):
     lioncreature = CM.get_Component('Creature', self.LionId)
     lioncoord = CM.get_Component('Coord', self.LionId)
     playercoord = CM.get_Component('Coord', config.PlayerId)
     disttoplayer = get_distance(lioncoord, playercoord)
     if disttoplayer <= lioncreature.VisionRange and \
             coordfov(lioncoord, playercoord):
         if int(disttoplayer) <= 1:
             Attack_Coord(self.BasicAttackId, self.LionId,
                          playercoord)
         else:
             direction = MC.Get_Direction_To(lioncoord, playercoord)
             MC.Walk_Direction_Persistantly(self.LionId, direction)
     else:
         coord = CM.dict_of('Coord')
         tile = CM.dict_of('Tile')
         dist = (lioncreature.VisionRange, False)
         for key, coord in coord.iteritems():
             if get_distance(coord, lioncoord) <= \
                 lioncreature.VisionRange and key != self.LionId and \
                     (tile[key].TileName == 'Lion' or
                         tile[key].TileName == 'Dire Lion'):
                 newdist = get_distance(lioncoord, coord)
                 if newdist < dist:
                     dist = (newdist, coord)
         if dist[1]:
             if dist[0] < 2:
                 direction = MC.Get_Direction_To(dist[1], lioncoord)
             else:
                 direction = MC.Get_Direction_To(lioncoord, dist[1])
             MC.Walk_Direction_Persistantly(self.LionId, direction)
开发者ID:Akhier,项目名称:12Down,代码行数:31,代码来源:Lion.py

示例2: dire_choice

def dire_choice(direid):
    choice = None
    while choice is None:
        choice = Menu('The Dire and dead, only 2 letters ' +
                      'different now the same. ' +
                      'Now claim your reward!',
                      ['You could probably sharpen your weapon on its bones',
                       'Maybe reinforce your gear with its fur?',
                       'How about a collar made of it\'s mane'], 60)
    playercreature = CM.get_Component('Creature', config.PlayerId)
    if choice == 0:
        playerattack = CM.get_Component('Attack', config.PlayerAttack)
        playerattack.Dice += 1
        playerattack.Sides -= 1
        if 'PierceDefense' in playerattack.Special:
            playerattack.Special['PierceDefense'] += 5
        else:
            playerattack.Special['PierceDefense'] = 10
        Message('Well that improves things')
    if choice == 1:
        if 'EnhancedDefense' in playercreature.Special:
            playercreature.Special['EnhancedDefense'] += 10
        else:
            playercreature.Special['EnhancedDefense'] = 20
        if playercreature.BaseDefense < 10:
            playercreature.BaseDefense += 2
        else:
            playercreature.BaseDefense += 1
        Message('Just a bit more defensive')
    if choice == 2:
        playercreature['Fear'] = 5
        Message('With this things might fear you. That\'s a good thing!')
开发者ID:Akhier,项目名称:12Down,代码行数:32,代码来源:Lion.py

示例3: take_turn

 def take_turn(self):
     frogcreature = CM.get_Component('Creature', self.FrogId)
     frogcoord = CM.get_Component('Coord', self.FrogId)
     frogtile = CM.get_Component('Tile', self.FrogId)
     playercoord = CM.get_Component('Coord', config.PlayerId)
     disttoplayer = hypot(frogcoord.X - playercoord.X,
                          frogcoord.Y - playercoord.Y)
     if disttoplayer < frogcreature.VisionRange and \
             coordfov(frogcoord, playercoord):
         if int(disttoplayer) <= 1:
             Attack_Coord(self.BasicAttackId, self.FrogId,
                          playercoord)
         else:
             direction = MC.Get_Direction_To(frogcoord, playercoord)
             if self.resting <= 0:
                 if not MC.Walk_Direction(self.FrogId, direction):
                     directions = MC.Get_Alt_Direction_To(direction)
                     if not MC.Walk_Direction(self.FrogId, directions[0]):
                         MC.Walk_Direction(self.FrogId, directions[1])
                 self.resting = 2
             else:
                 MC.Walk_Direction_Multiple(self.FrogId, direction, 3)
                 Message('The ' + frogtile.TileName + ' jumps.')
                 self.resting -= 1
     else:
         MC.Walk_Random_Failable(self.FrogId)
开发者ID:Akhier,项目名称:12Down,代码行数:26,代码来源:Frog.py

示例4: queens_choice

def queens_choice(queenid):
    choice = None
    while choice is None:
        choice = Menu('You have beaten the first boss. Now claim your reward!',
                      ['Reinforce your gear with it\'s shell',
                       'Wield it\'s jaws as daggers',
                       'Examine the weird glow on it\'s antenna'], 60)
    playercreature = CM.get_Component('Creature', config.PlayerId)
    if choice == 0:
        playercreature.BaseAgility -= 1
        playercreature.BaseDefense += 1
        if 'EnhancedDefense' in playercreature.Special:
            playercreature.Special['EnhancedDefense'] += 15
        else:
            playercreature.Special['EnhancedDefense'] = 25
        Message('Your armor feels studier though it is stiffer')
    if choice == 1:
        playerattack = CM.get_Component('Attack', config.PlayerAttack)
        playerattack.Dice = 2
        playerattack.Sides = 4
        playerattack.Special['PierceDefense'] = 10
        Message('Maybe having 2 sharp daggers will up your damager?')
    if choice == 2:
        playercreature.BaseAgility += 1
        playercreature.VisionRange += 1
        config.fov_recompute = True
        Message('The strange glow streams into your eyes. After the shock ' +
                'wears of you notice you can see better')
开发者ID:Akhier,项目名称:12Down,代码行数:28,代码来源:Ant.py

示例5: hobs_choice

def hobs_choice(hobsid):
    choice = None
    while choice is None:
        choice = Menu('The Hobgoblin is now hobless. ' +
                      'Now claim your reward!',
                      ['An actual helmet! Joy',
                       'This sword is big but glows',
                       'Fallen on the ground next to it is a vial'], 60)
    playercreature = CM.get_Component('Creature', config.PlayerId)
    playerattack = CM.get_Component('Attack', config.PlayerAttack)
    if choice == 0:
        playercreature.Special['ReduceCrit'] = 50
        if playercreature.BaseDefense <= 5:
            playercreature.BaseDefense += 1
        Message('Unlike you probably assumed this doesn\'t seem ' +
                'to reduce the chance of getting critted ' +
                'but rather damage taken from one.')
    if choice == 1:
        playerattack = Attack(2, 6, special={'PlusAgility': 4,
                                             'PierceDefense': 5})
        Message('This seems to be a magic weapon which helps in combat!')
    if choice == 2:
        playerattack.Special['CausePoison'] = (35, 5, 1)
        Message('The vial contains a sticky poison ' +
                'so you apply it to your weapon.')
开发者ID:Akhier,项目名称:12Down,代码行数:25,代码来源:Goblin.py

示例6: clear_choice

def clear_choice(clearid):
    choice = None
    while choice is None:
        choice = Menu('The Clear jellyfish is just a splatter on the ' +
                      'ceiling. Now claim your reward!',
                      ['This tentacle could be a whip',
                       'I wonder what it tastes like',
                       'There is a glowing puddle on the floor'], 60)
    playercreature = CM.get_Component('Creature', config.PlayerId)
    if choice == 0:
        attack = CM.get_Component('Attack', config.PlayerAttack)
        attack = Attack(1, 12, special={'Paralyze': 20})
        Message('Slimy but a workable whip none the less.')
    if choice == 1:
        if playercreature.BaseAgility < 10:
            playercreature.BaseAgility = 10
        else:
            playercreature.BaseAgility += 5
        playercreature.Special['ParalyzeResistance'] = 5
        Message('Actually it tastes good and you feel a bit more flexible.')
    if choice == 2:
        if 'HealthPotion' in playercreature.Special:
            playercreature.Special['HealthPotion'] += 3
        else:
            playercreature.Special['HealthPotion'] = 5
        Message('You shove it in a bottle and if you ' +
                'squint it looks like a health potion')
开发者ID:Akhier,项目名称:12Down,代码行数:27,代码来源:Jellyfish.py

示例7: death_cleanup

def death_cleanup(creatureid):
    creaturetile = CM.get_Component('Tile', creatureid)
    creaturedeath = CM.get_Component('Death', creatureid)
    creaturetile.Char = creaturedeath.Char
    creaturetile.Passable = True
    Message(creaturedeath.DeathMessage, Color.darker_red)
    CM.remove_Components(['Creature', 'Action'], creatureid)
开发者ID:Akhier,项目名称:12Down,代码行数:7,代码来源:C_Death.py

示例8: Place_Monsters_On_Level

def Place_Monsters_On_Level(dungeonlevelid):
    dungeonlevel = CM.get_Component('DungeonLevel', dungeonlevelid)
    curmap = CM.get_Component('Map', dungeonlevel.MapId)
    random.seed(curmap.Seed)
    placed_monsters = 0
    while placed_monsters <= config.monster_per_level:
        if dungeonlevel.Level == 1:
            monster = monsters[1]
        elif dungeonlevel.Level == 2:
            if random.randint(1, 10) == 1:
                monster = monsters[1]
            else:
                monster = monsters[2]
        else:
            if random.randint(1, 10) > 1:
                monster = monsters[dungeonlevel.Level]
            elif random.randint(1, 10) > 1:
                monster = monsters[dungeonlevel.Level - 1]
            else:
                monster = monsters[dungeonlevel.Level - 2]
        x = random.randint(1, curmap.Width - 1)
        y = random.randint(1, curmap.Height - 1)
        if x < curmap.Width / 2 - 4 or x > curmap.Width / 2 + 4 or \
                y < curmap.Height / 2 - 4 or y > curmap.Height / 2 + 4:
            testcoord = Coord(x, y)
            if Try_Place(testcoord, dungeonlevel, monster):
                placed_monsters += 1
                placed_in_relation = 0
                while Place_in_Relation(testcoord, dungeonlevel,
                                        monster) and \
                        placed_in_relation <= config.monster_per_level * .25:
                    placed_monsters += 1
                    placed_in_relation += 1
开发者ID:Akhier,项目名称:12Down,代码行数:33,代码来源:S_PlaceMonsters.py

示例9: __init__

 def __init__(self, lionid):
     self.LionId = lionid
     self.BasicAttackId = EM.new_Id
     tile = CM.get_Component('Tile', lionid)
     if tile.TileName == 'Lion':
         CM.add_Component(self.BasicAttackId, 'Attack', Attack(2, 6))
     else:
         CM.add_Component(self.BasicAttackId, 'Attack',
                          Attack(2, 6, special={'PierceDefense': 10}))
开发者ID:Akhier,项目名称:12Down,代码行数:9,代码来源:Lion.py

示例10: __init__

 def __init__(self, kangarooid):
     self.KangarooId = kangarooid
     self.BasicAttackId = EM.new_Id
     tile = CM.get_Component('Tile', kangarooid)
     if tile.TileName == 'Kangaroo':
         CM.add_Component(self.BasicAttackId, 'Attack', Attack(4, 2))
     else:
         CM.add_Component(self.BasicAttackId, 'Attack',
                          Attack(4, 2, special={'Paralyze': 10}))
     self.playerinvision = False
开发者ID:Akhier,项目名称:12Down,代码行数:10,代码来源:Kangaroo.py

示例11: coord_to_coord_fov

def coord_to_coord_fov(coord, coord2):
    line = get_line((coord.X, coord.Y), (coord.X, coord.Y))
    line = line[1:-1]
    coords = CM.dict_of('Coord')
    tiles = CM.dict_of('Tile')
    for key, value in coords.iteritems():
        if value in line:
            if key in tiles:
                if not tiles.Passable:
                    return False
    return True
开发者ID:Akhier,项目名称:12Down,代码行数:11,代码来源:S_CoordtoCoordFov.py

示例12: make_imp

def make_imp(coord, dungeonlevel):
    newmonsterid = EM.new_Id()
    CM.add_Component(newmonsterid, 'Coord', coord)
    CM.add_Component(newmonsterid, 'Tile',
                     Tile('Imp', 'i', False, True,
                          color=Color.red))
    CM.add_Component(newmonsterid, 'Death',
                     Death('The dead imp quickly fades from reality.',
                           '.', effects=[death_cleanup]))
    CM.add_Component(newmonsterid, 'Creature',
                     Creature(20, 0, 10, 18, 4, 79))
    CM.add_Component(newmonsterid, 'Action', Imp_AI(newmonsterid))
    dungeonlevel.MonsterIds.append(newmonsterid)
开发者ID:Akhier,项目名称:12Down,代码行数:13,代码来源:Imp.py

示例13: make_hawk

def make_hawk(coord, dungeonlevel):
    newmonsterid = EM.new_Id()
    CM.add_Component(newmonsterid, 'Coord', coord)
    CM.add_Component(newmonsterid, 'Tile',
                     Tile('Hawk', 'h', False, True,
                          color=Color.darker_orange))
    CM.add_Component(newmonsterid, 'Death',
                     Death('The dead hawk flutters to the ground dead.',
                           '~', effects=[death_cleanup]))
    CM.add_Component(newmonsterid, 'Creature',
                     Creature(10, 0, 10, 25, 10, 73))
    CM.add_Component(newmonsterid, 'Action', Hawk_AI(newmonsterid))
    dungeonlevel.MonsterIds.append(newmonsterid)
开发者ID:Akhier,项目名称:12Down,代码行数:13,代码来源:Hawk.py

示例14: make_kangaroo

def make_kangaroo(coord, dungeonlevel):
    newmonsterid = EM.new_Id()
    CM.add_Component(newmonsterid, 'Coord', coord)
    CM.add_Component(newmonsterid, 'Tile',
                     Tile('Kangaroo', 'k', False, True,
                          color=Color.dark_sepia))
    CM.add_Component(newmonsterid, 'Death',
                     Death('This kangaroo won\'t be hopping anymore.',
                           '~', effects=[death_cleanup]))
    CM.add_Component(newmonsterid, 'Creature',
                     Creature(10, 0, 10, 25, 10, 73))
    CM.add_Component(newmonsterid, 'Action', Kangaroo_AI(newmonsterid))
    dungeonlevel.MonsterIds.append(newmonsterid)
开发者ID:Akhier,项目名称:12Down,代码行数:13,代码来源:Kangaroo.py

示例15: make_dog

def make_dog(coord, dungeonlevel):
    newmonsterid = EM.new_Id()
    CM.add_Component(newmonsterid, 'Coord', coord)
    CM.add_Component(newmonsterid, 'Tile',
                     Tile('Dog', 'd', False, True,
                          color=Color.darker_yellow))
    CM.add_Component(newmonsterid, 'Death',
                     Death('The little doggie wimpers as it falls over.',
                           '~', effects=[death_cleanup]))
    CM.add_Component(newmonsterid, 'Creature',
                     Creature(12, 1, 14, 8, 5, 26, special={'Dodge': 10}))
    CM.add_Component(newmonsterid, 'Action', Dog_AI(newmonsterid))
    dungeonlevel.MonsterIds.append(newmonsterid)
开发者ID:Akhier,项目名称:12Down,代码行数:13,代码来源:Dog.py


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