zoukankan      html  css  js  c++  java
  • 「网易官方」极客战记(codecombat)攻略-沙漠-宠物工程师-pet-engineer

    (点击图片进入关卡)

    强大的战斗机器。但是,简单的说,即使是宠物也可以使用它们!

    简介

    当听到 archer 的呼救声时,把你的宠物移到左边的按钮(靠近机器人)。

    当听到 soldier 的呼救声时,把你的宠物移到右边的按钮(靠近大炮)。

    使用 "hear" 事件处理程序的 event.speaker 参数来识别谁在呼救!

    默认代码

    # 根据需要将宠物移到左或右按钮。
    def onHear(event):
        # 找到门卫
        archer = pet.findNearestByType("archer")
        soldier = pet.findNearestByType("soldier")
        # 如果"event.speaker"参数是 `archer`:

     

            # 移动到左边的按钮。

     

        # 如果"event.speaker"参数是`soldier`:

     

            # 移动到右边的按钮。

     

    pet.on("hear", onHear)
    # 您不必更改下面的代码。
    # 你的英雄应该保护右下角的通道。
    while True:
        enemy = hero.findNearestEnemy()
        if enemy:
            hero.attack(enemy)

    概览

    你可以检查谁的 event.speaker 是这样的:

    archer = pet.findNearestByType("archer")
    if event.speaker == archer:
        # It's the archer

    左边的按钮位于 x 32 , y 30 。

    左边的按钮位于 x 48 , y 30 。

    宠物工程师解法

    # 根据需要将宠物移到左或右按钮。
    def onHear(event):
        # 找到门卫
        archer = pet.findNearestByType("archer")
        soldier = pet.findNearestByType("soldier")
        # 如果"event.speaker"参数是 `archer`:
        if event.speaker == archer:
            # 移动到左边的按钮。
            pet.moveXY(32, 30)
        # 如果"event.speaker"参数是`soldier`:
        elif event.speaker == soldier:
            # 移动到右边的按钮。
            pet.moveXY(48, 30)
    pet.on("hear", onHear)
    # 您不必更改下面的代码。
    # 你的英雄应该保护右下角的通道。
    while True:
        enemy = hero.findNearestEnemy()
        if enemy:
            hero.attack(enemy)
     
    本攻略发于极客战记官方教学栏目,原文地址为:
  • 相关阅读:
    [quote] Rough Notes on Linux Networking Stack
    All my miscellaneous assembly
    chrome浏览器屏幕网页内嵌的flash广告?
    [quote] How to determine what target is given in Makefile from the make command-line?
    [quote] colour your linux command line
    python 3 函数
    python 2 控制流
    薛定谔的猫 转载
    using distance to keep track of the min in a stack
    Java String
  • 原文地址:https://www.cnblogs.com/codecombat/p/13444353.html
Copyright © 2011-2022 走看看