zoukankan      html  css  js  c++  java
  • 「网易官方」极客战记(codecombat)攻略-沙漠-游魂-wandering-souls

    (点击图片进入关卡)

    让那些迷失的灵魂安息吧。

    简介

    这些徘徊的骷髅并不危险,但你需要击败它们并收集闪光石,让他们从诅咒中解脱。

    对于强悍的敌人,只攻击一次是不够的,所以你应该使用 while 条件循环,当 他们的 health 大于0 时攻击。

    while enemy.health > 0:
        hero.attack(enemy)

    你可以把这个循环放入另一个 while 中,逐个击败敌人。

    它不仅可以用于敌人,还可以用于物品,例如,如果他们不想被收集的话。

    默认代码

    # 攻击骷髅捡走宝石
    while True:
        enemies = hero.findEnemies()
        enemyIndex = 0
        while enemyIndex < len(enemies):
            enemy = enemies[enemyIndex]
            # 敌人有血量时进攻。
            while enemy.health > 0:
                hero.attack(enemy)
            enemyIndex += 1
        items = hero.findItems()
        itemIndex = 0
        # 遍历所有的物品。
        while itemIndex < len(items):
            item = items[itemIndex]
            # 而距离大于2:

     

                # 试着拿到物品

     

            # 别忘了让itemIndex变大 (itemIndex+=1)或(itemIndex=itemIndex+1)
            itemIndex += 1

    概览

    那些游荡的灵魂很难收集。你需要一直向一个球移动,直到能抓住它们为止!

    while hero.distanceTo(item) > 2:
        # 靠近点!

    游魂 解法

    # 攻击骷髅捡走宝石
    while True:
        enemies = hero.findEnemies()
        enemyIndex = 0
        while enemyIndex < len(enemies):
            enemy = enemies[enemyIndex]
            # 敌人有血量时进攻。
            while enemy.health > 0:
                hero.attack(enemy)
            enemyIndex += 1
        items = hero.findItems()
        itemIndex = 0
        # 遍历所有的物品。
        while itemIndex < len(items):
            item = items[itemIndex]
            # 而距离大于2:
            while hero.distanceTo(item) > 2:
                # 试着拿到物品
                hero.moveXY(item.pos.x, item.pos.y)
            # 别忘了让itemIndex变大 (itemIndex+=1)或(itemIndex=itemIndex+1)
            itemIndex += 1
     
    本攻略发于极客战记官方教学栏目,原文地址为:
  • 相关阅读:
    arc模式和ios的关系
    uitableview置底部,不显示到最顶层
    Mac OS X Lion 10.7.4 升级包
    ObjectiveC urlencode/urldecode url加密解密
    UITableView阴影
    iOS SDK: Working with URL Schemes
    黑苹果mac lion 10.7.3升级10.7.4
    查找 EXC_BAD_ACCESS 问题根源的方法
    "unrecognized selector sent to instance"问题的解决
    测量应用程序cass和cad的使用感受
  • 原文地址:https://www.cnblogs.com/codecombat/p/13383775.html
Copyright © 2011-2022 走看看