本文整理汇总了Python中enemy.Enemy.getEnemy方法的典型用法代码示例。如果您正苦于以下问题:Python Enemy.getEnemy方法的具体用法?Python Enemy.getEnemy怎么用?Python Enemy.getEnemy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enemy.Enemy
的用法示例。
在下文中一共展示了Enemy.getEnemy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getScoreOfKilledEnemies
# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import getEnemy [as 别名]
def getScoreOfKilledEnemies(self, killedEnemies):
score = 0
multiplier = 1
for dist in range(len(killedEnemies)):
list = killedEnemies[dist]
sortedList = sorted(list)
for enemy in sortedList:
score += Enemy.getEnemy(enemy)['points'] * multiplier
multiplier *= 2
return score
示例2: moveEnemy
# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import getEnemy [as 别名]
def moveEnemy(self, speed):
for i in range(self.level.numberEnemies):
if (Enemy.getEnemy(self.level.listEnemies[i][3])['speed'] == speed):
curX = self.level.listEnemies[i][0]
curY = self.level.listEnemies[i][1]
tempDir = self.level.listEnemies[i][2]
tempWP = Enemy.getEnemy(self.level.listEnemies[i][3])['wallpass']
tempIntel = Enemy.getEnemy(self.level.listEnemies[i][3])['intelligence']
newX = 0
newY = 0
randInt = 0
hasDied = False
hasMoved = False
if (tempIntel == 3): randInt = 2
elif (tempIntel == 2): randInt = 10
if (tempIntel == 2 or tempIntel == 3):
if (self.level.board[curY+1][curX].peek() == Tile.Bomberman and hasMoved == False):
newX = curX
newY = curY + 1
tempDir = 0
hasMoved = True
hasDied = True
if (self.level.board[curY-1][curX].peek() == Tile.Bomberman and hasMoved == False):
newX = curX
newY = curY - 1
tempDir = 2
hasMoved = True
hasDied = True
if (self.level.board[curY][curX+1].peek() == Tile.Bomberman and hasMoved == False):
newX = curX + 1
newY = curY
tempDir = 1
hasMoved = True
hasDied = True
if (self.level.board[curY][curX-1].peek() == Tile.Bomberman and hasMoved == False):
newX = curX - 1
newY = curY
tempDir = 3
hasMoved = True
hasDied = True
tempTile = self.level.board[curY+1][curX].peek()
if (tempTile != Tile.Bomb and ((tempTile == Tile.Brick and tempWP == True) or tempTile != Tile.Brick) and tempTile != Tile.Concrete and random.randint(1,randInt) == 1 and hasMoved == False):
newX = curX
newY = curY + 1
tempDir = 0
hasMoved = True
tempTile = self.level.board[curY-1][curX].peek()
if (tempTile != Tile.Bomb and ((tempTile == Tile.Brick and tempWP == True) or tempTile != Tile.Brick) and tempTile != Tile.Concrete and random.randint(1,randInt) == 1 and hasMoved == False):
newX = curX
newY = curY - 1
tempDir = 2
hasMoved = True
tempTile = self.level.board[curY][curX+1].peek()
if (tempTile != Tile.Bomb and ((tempTile == Tile.Brick and tempWP == True) or tempTile != Tile.Brick) and tempTile != Tile.Concrete and random.randint(1,randInt) == 1 and hasMoved == False):
newX = curX + 1
newY = curY
tempDir = 1
hasMoved = True
tempTile = self.level.board[curY][curX-1].peek()
if (tempTile != Tile.Bomb and ((tempTile == Tile.Brick and tempWP == True) or tempTile != Tile.Brick) and tempTile != Tile.Concrete and random.randint(1,randInt) == 1 and hasMoved == False):
newX = curX - 1
newY = curY
tempDir = 3
hasMoved = True
if (hasMoved == True):
self.level.listEnemies[i][0] = newX
self.level.listEnemies[i][1] = newY
self.level.listEnemies[i][2] = tempDir
self.popTileAt(curX, curY)
self.setTileAt(newX, newY, self.level.listEnemies[i][3])
if (hasDied == True):
self.death()
return False
if (tempIntel == 1 or hasMoved == False):
if (tempDir == 0):
newX = curX
newY = curY + 1
elif (tempDir == 1):
newX = curX + 1
newY = curY
elif (tempDir == 2):
newX = curX
newY = curY - 1
elif (tempDir == 3):
newX = curX - 1
newY = curY
tempTile = self.level.board[newY][newX].peek()
if (tempTile == Tile.Bomb or (tempTile == Tile.Brick and tempWP == False) or tempTile == Tile.Concrete):
if (tempDir == 0): newY -= 2
elif (tempDir == 1): newX -= 2
#.........这里部分代码省略.........