zoukankan      html  css  js  c++  java
  • 【网易官方】极客战记(codecombat)攻略-游戏开发1-行为驱动开发

    关卡连接:https://codecombat.163.com/play/level/behavior-driven-development

    免费试玩:https://codecombat.163.com/play

    你可以使用行为属性来改变单位的 AI。

    简介

    单位的行为可以通过 behavior 属性来设置。

    skeleton3.behavior = "Scampers" 这句代码会让 skeleton3 变量中存储的骷髅怪随机移动。

    skeleton3.behavior = "AttacksNearest" 则是攻击最近的敌人。

    skeleton3.behavior = "Defends" 则只在敌人接近时发起攻击。

    skeleton3.behavior = "RunsAway" 会让单位从玩家周围逃开。

    记得选取正确的变量,如 skeleton3 、 ogre2 、 ogre3 、 archer1 !

    默认代码

    # 使用behavior属性为单位指定行为。
    skeleton1 = game.spawnXY("skeleton", 60, 48)
    skeleton2 = game.spawnXY("skeleton", 60, 30)
    skeleton3 = game.spawnXY("skeleton", 60, 12)
    skeleton1.behavior = "Scampers"
    skeleton2.behavior = "Scampers"
    # 将"Scampers"指定给 skeleton3.behavior
    ogre1 = game.spawnXY("ogre", 70, 50)
    ogre2 = game.spawnXY("ogre", 70, 30)
    ogre3 = game.spawnXY("ogre", 70, 10)
    ogre1.behavior = "AttacksNearest"
    # 将"AttacksNearest"指定给 ogre2.behavior
    # 将"AttacksNearest"指定给 ogre3.behavior
    archer1 = game.spawnXY("archer", 10, 30)
    # 将"Defends"指定给 archer1.behavior
    # 下面这里不要做任何修改。
    # 不过不妨看看!
    player = game.spawnPlayerXY("raider", 20, 30)
    player.attackDamage = 10
    player.maxHealth = 9001
    game.addSurviveGoal()
    game.addDefeatGoal()
    game.spawnXY("forest", 40, 10)
    game.spawnXY("forest", 40, 18)
    game.spawnXY("forest", 40, 26)
    game.spawnXY("forest", 40, 42)
    game.spawnXY("forest", 40, 50)
    game.spawnXY("forest", 40, 58)
    game.spawnXY("lightstone", 30, 45)
    game.spawnXY("lightstone", 30, 20)
    game.spawnXY("lightstone", 30, 55)
    game.spawnXY("lightstone", 30, 10)
    game.spawnXY("potion-medium", 10, 50)
    game.spawnXY("potion-medium", 10, 15)

    概览

    Coming soon!

    行为驱动开发 解法

    # 使用behavior属性为单位指定行为。
    skeleton1 = game.spawnXY("skeleton", 60, 48)
    skeleton2 = game.spawnXY("skeleton", 60, 30)
    skeleton3 = game.spawnXY("skeleton", 60, 12)
    skeleton1.behavior = "Scampers"
    skeleton2.behavior = "Scampers"
    # 将"Scampers"指定给 skeleton3.behavior
    skeleton3.behavior = "Scampers"
    ogre1 = game.spawnXY("ogre", 70, 50)
    ogre2 = game.spawnXY("ogre", 70, 30)
    ogre3 = game.spawnXY("ogre", 70, 10)
    ogre1.behavior = "AttacksNearest"
    # 将"AttacksNearest"指定给 ogre2.behavior
    ogre2.behavior = "AttacksNearest"
    # 将"AttacksNearest"指定给 ogre3.behavior
    ogre3.behavior = "AttacksNearest"
    archer1 = game.spawnXY("archer", 14, 30)
    # 将"Defends"指定给 archer1.behavior
    archer1.behavior = "Defends"
    # 下面这里不要做任何修改
    # 不过不妨看看!
    player = game.spawnPlayerXY("raider", 20, 30)
    player.attackDamage = 10
    player.maxHealth = 9001
    game.addSurviveGoal()
    game.addDefeatGoal()
    game.spawnXY("forest", 40, 10)
    game.spawnXY("forest", 40, 18)
    game.spawnXY("forest", 40, 26)
    game.spawnXY("forest", 40, 42)
    game.spawnXY("forest", 40, 50)
    game.spawnXY("forest", 40, 58)
    game.spawnXY("lightstone", 30, 45)
    game.spawnXY("lightstone", 30, 20)
    game.spawnXY("lightstone", 30, 55)
    game.spawnXY("lightstone", 30, 10)
    game.spawnXY("potion-medium", 10, 50)
    game.spawnXY("potion-medium", 10, 15)
     

    本攻略发于极客战记官方教学栏目,原文地址为:

    https://codecombat.163.com/news/jikezhanji-xingweiqudongkaifa

    极客战记——学编程,用玩的!
  • 相关阅读:
    Linux下删除某些非法字符文件名的文件
    华为面经之我的同学是个死神
    算法面经之华为
    【剑指offer】两个链表的第一个公共结点
    算法面经之百度
    【剑指offer】丑数
    【剑指offer】把数组排成最小的数
    【深度学习最优化方法】
    【矩阵范数与秩、正定】
    算法面经之大华+顺丰+爱奇艺
  • 原文地址:https://www.cnblogs.com/codecombat/p/12124064.html
Copyright © 2011-2022 走看看