本文整理汇总了Python中ComponentManager.ComponentManager.get_Component方法的典型用法代码示例。如果您正苦于以下问题:Python ComponentManager.get_Component方法的具体用法?Python ComponentManager.get_Component怎么用?Python ComponentManager.get_Component使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComponentManager.ComponentManager
的用法示例。
在下文中一共展示了ComponentManager.get_Component方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: death_cleanup
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Component [as 别名]
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)
示例2: take_turn
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Component [as 别名]
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)
示例3: dire_choice
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Component [as 别名]
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!')
示例4: take_turn
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Component [as 别名]
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)
示例5: clear_choice
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Component [as 别名]
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')
示例6: hobs_choice
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Component [as 别名]
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.')
示例7: Place_Monsters_On_Level
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Component [as 别名]
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
示例8: queens_choice
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Component [as 别名]
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')
示例9: take_turn
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Component [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)
示例10: take_turn
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Component [as 别名]
def take_turn(self):
impcreature = CM.get_Component('Creature', self.ImpId)
impcoord = CM.get_Component('Coord', self.ImpId)
playercoord = CM.get_Component('Coord', config.PlayerId)
disttoplayer = hypot(impcoord.X - playercoord.X,
impcoord.Y - playercoord.Y)
if disttoplayer < impcreature.VisionRange:
if coordfov(impcoord, playercoord):
if int(disttoplayer) <= 1:
Attack_Coord(self.BasicAttackId, self.ImpId,
playercoord)
MC.Walk_Direction_Persistantly(
self.ImpId, MC.Get_Direction_To(impcoord, playercoord))
else:
MC.Blink_Random_Failable(self.ImpId, 0, 2)
示例11: take_turn
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Component [as 别名]
def take_turn(self):
batcoord = CM.get_Component('Coord', self.BatId)
playercoord = CM.get_Component('Coord', config.PlayerId)
disttoplayer = hypot(batcoord.X - playercoord.X,
batcoord.Y - playercoord.Y)
if int(disttoplayer) <= 1:
Attack_Coord(self.BasicAttackId, self.BatId, playercoord)
direction = random.choice([D.N, D.S, D.E, D.W,
D.NE, D.NW, D.SE, D.SW])
MC.Walk_Direction(self.BatId, direction)
playercoord = CM.get_Component('Coord', config.PlayerId)
disttoplayer = hypot(batcoord.X - playercoord.X,
batcoord.Y - playercoord.Y)
if int(disttoplayer) <= 1:
Attack_Coord(self.BasicAttackId, self.BatId, playercoord)
示例12: savage_choice
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Component [as 别名]
def savage_choice(savageid):
choice = None
while choice is None:
choice = Menu('The Savage hawk is grounded. ' +
'Now claim your reward!',
['The claws glow',
'The eyes glow',
'and believe it or not the wings glow!'], 60)
playercreature = CM.get_Component('Creature', config.PlayerId)
if choice == 0:
playercreature.Special['SideSwipe'] = True
Message('You feel that just walking past enemies (diagonally)' +
' that you can get attacks in!')
if choice == 1:
if playercreature.BaseAgility < 10:
playercreature.BaseAgility += 1
if 'Dodge' in playercreature.Special:
playercreature.Special['Dodge'] += 10
else:
playercreature.Special['Dodge'] = 20
Message('Your eyesight sharpens and you feel you can dodge better.')
if choice == 2:
if 'CardinalLeap' in playercreature.Special:
(need, cur, dist) = playercreature.Special('CardinalLeap')
need -= 1
if need <= 1:
need = 3
dist += 1
playercreature.Special['CardinalLeap'] = (need, need, dist)
else:
playercreature.Special['CardinalLeap'] = (5, 5, 3)
Message('The seems like it can occasionally ' +
'boost your leaping ability. (ctrl + cardinal direction)')
示例13: take_turn
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Component [as 别名]
def take_turn(self):
kangaroocreature = CM.get_Component('Creature', self.KangarooId)
kangaroocoord = CM.get_Component('Coord', self.KangarooId)
playercoord = CM.get_Component('Coord', config.PlayerId)
disttoplayer = hypot(kangaroocoord.X - playercoord.X,
kangaroocoord.Y - playercoord.Y)
if disttoplayer <= kangaroocreature.VisionRange and \
coordfov(kangaroocoord, playercoord):
if int(disttoplayer) <= 1:
Attack_Coord(self.BasicAttackId, self.KangarooId,
playercoord)
else:
direction = MC.Get_Direction_To(kangaroocoord, playercoord)
MC.Walk_Direction_Persistantly(self.KangarooId, direction)
else:
MC.Walk_Random_Multiple_Failable(self.KangarooId, 1, 2)
示例14: Place_Boss
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Component [as 别名]
def Place_Boss(dungeonlevel):
monster = bossmonsters[dungeonlevel.Level]
playercoord = CM.get_Component('Coord', config.PlayerId)
sourcex = -playercoord.X
if sourcex > config.playscreen_width * .25 and \
sourcex < config.playscreen_width * .75:
if sourcex < config.playscreen_width * .5:
sourcex -= int(config.playscreen_width * .25)
else:
sourcex += int(config.playscreen_width * .25)
sourcey = -playercoord.Y
if sourcey > config.playscreen_height * .25 and \
sourcey < config.playscreen_height * .75:
if sourcey < config.playscreen_height * .5:
sourcey -= int(config.playscreen_height * .25)
else:
sourcey += int(config.playscreen_height * .25)
sourcecoord = Coord(sourcex, sourcey)
if not Try_Place(sourcecoord, dungeonlevel, monster):
failure_in_Relation = 0
maxoffset = 5
while not Place_in_Relation(sourcecoord, dungeonlevel, monster,
maxoffset=maxoffset, minoffset=0):
failure_in_Relation += 1
if failure_in_Relation > maxoffset * 10:
maxoffset += 1
failure_in_Relation = 0
示例15: take_turn
# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import get_Component [as 别名]
def take_turn(self):
antcreature = CM.get_Component('Creature', self.AntId)
antcoord = CM.get_Component('Coord', self.AntId)
playercoord = CM.get_Component('Coord', config.PlayerId)
disttoplayer = hypot(antcoord.X - playercoord.X,
antcoord.Y - playercoord.Y)
if disttoplayer < antcreature.VisionRange:
if coordfov(antcoord, playercoord):
if int(disttoplayer) <= 1:
Attack_Coord(self.BasicAttackId, self.AntId, playercoord)
else:
direction = MC.Get_Direction_To(antcoord, playercoord)
if not MC.Walk_Direction(self.AntId, direction):
directions = MC.Get_Alt_Direction_To(direction)
if not MC.Walk_Direction(self.AntId, directions[0]):
MC.Walk_Direction(self.AntId, directions[1])