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

    极客战记——学编程,用玩的!
  • 相关阅读:
    MySQL 调优 —— Using filesort
    The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
    JMS解决系统间通信问题
    LinkedList,ArrayList末尾插入谁效率高?
    C#学习笔记二:C#程序结构
    C#学习笔记一:C#开发环境的设置
    "NetworkError: 500 Internal Server Error
    JSON数据与JavaScript对象转换
    在使用Ibatis查询数据返回时,报如下错误:java ibatis The error happened while setting a property on the result object
    The APR based Apache Tomcat Native library
  • 原文地址:https://www.cnblogs.com/codecombat/p/12124064.html
Copyright © 2011-2022 走看看