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
     
    本攻略发于极客战记官方教学栏目,原文地址为:
  • 相关阅读:
    Dynamics AX 2012 R3 Demo 安装与配置
    [转]SQL SERVER 2008 登陆失败(SQL和windows都没有对应的权限)
    [转]vs2008安装失败的总结与分享
    Dynamics AX 2012 R2 在报表上显示和打印条码
    WinCE Show App Icon
    [转]clrDateTime to Dynamics AX TransDate
    WINCE 隐藏标题栏
    HTTP 请求未经客户端身份验证方案“Anonymous”授权。从服务器收到的身份验证标头为“Negotiate,NTLM”
    4.销售和分发
    MEANIO
  • 原文地址:https://www.cnblogs.com/codecombat/p/13383775.html
Copyright © 2011-2022 走看看