极客战记-小心陷阱

若是你卡在这里了,那么看看这个攻略吧

筹办工作

  1. 1

    选择英雄和编程说话

  2. 2

    选择装备

  3. 3

    写中文注释

python

  1. 1

    写代码

    # 若是你试图进犯一个远处的仇敌,你的英雄会忽略失落所有的旗子而朝它冲曩昔。

    # 你需要确保你只进犯接近本身的仇敌!

    while True:

        flag = hero.findFlag()

        enemy = hero.findNearestEnemy()

        

        if flag:

            # 去拔旗子。

            hero.pickUpFlag(flag)

            hero.say("我应该去把旗子拔起来。")

        elif enemy:

            # 仅当仇敌的距离小于10米时才进犯。

            if hero.distanceTo(enemy)<10:

                if hero.isReady("cleave"):

                    hero.cleave(enemy)

                else:

                    hero.attack(enemy)

  2. 2

    运行

javascript

  1. 1

    写代码

    // 若是你试图进犯一个远处的仇敌,你的英雄会忽略失落所有的旗子而朝它冲曩昔。

    // 你需要确保你只进犯接近本身的仇敌!

    while (true) {

        var flag = hero.findFlag();

        var enemy = hero.findNearestEnemy();

        if (flag) {

            // 去拔旗子。

            hero.pickUpFlag(flag);

        } else if (enemy) {

            // 仅当仇敌的距离小于10米时才进犯。

            var distance = hero.distanceTo(enemy);

            if (distance < 10) {

                var ready = hero.isReady("cleave");

                if (ready) {

                    hero.cleave(enemy);

                } else {

                    hero.attack(enemy);

                }

            }

        }

    }

  2. 2

    运行

coffeescript

  1. 1

    写代码

    # 若是你试图进犯一个远处的仇敌,你的英雄会忽略失落所有的旗子而朝它冲曩昔。

    # 你需要确保你只进犯接近本身的仇敌!

    loop

        flag = @findFlag()

        enemy = @findNearestEnemy()

        

        if flag

            # 去拔旗子。

            @pickUpFlag(flag)

            @say "我应该去把旗子拔起来。"

        else if enemy

            # 仅当仇敌的距离小于10米时才进犯。

            distance = @distanceTo(enemy)

            if distance<10

                ready = hero.isReady "cleave"

                if ready

                    @cleave enemy

                else

                    @attack enemy

  2. 2

    运行

lua

  1. 1

    写代码

    -- 若是你试图进犯一个远处的仇敌,你的英雄会忽略失落所有的旗子而朝它冲曩昔。

    -- 你需要确保你只进犯接近本身的仇敌!

    while true do

        local flag = hero:findFlag()

        local enemy = hero:findNearestEnemy()

        

        if flag then

            -- 去拔旗子。

            hero:pickUpFlag(flag)

            hero:say("我应该去把旗子拔起来。")

        elseif enemy then

            -- 仅当仇敌的距离小于10米时才进犯。

            if hero:distanceTo(enemy)<10 then

                if hero:isReady("cleave") then

                    hero:cleave(enemy)

                else

                    hero:attack(enemy)

                end

            end

        end

    end

  2. 2

    运行

  • 发表于 2018-05-20 00:00
  • 阅读 ( 774 )
  • 分类:其他类型

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
联系我们:uytrv@hotmail.com 问答工具