codecombat安息之云山峰41关代码分享

来源:互联网 发布:订货会软件 编辑:程序博客网 时间:2024/04/26 19:15
codecombat中国游戏网址:http://www.codecombat.cn/
所有代码为javascript代码分享

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

41、Summit's Gate

//需要一个好的操作
// Fight your way into the Inner Sanctum of the ogre chieftain, and kill her.
this.flags = function(){
var flagg = this.findFlag("green");
var flagb = this.findFlag("black");
if (flagg) {
    this.pickUpFlag(flagg);
}
if (flagb) {
    this.jumpTo(flagb.pos);
    this.pickUpFlag(flagb);
}
};
this.attacks = function(){
var enemy = this.findNearest(this.findEnemies());
if (enemy && this.distanceTo(enemy) < 10) {
     if (this.isReady("bash")) {
        this.bash(enemy);   
    }
    else if (this.isReady("throw")) {
        this.throw(enemy);
    }
    else {
      this.attack(enemy);  
    }
}
};
this.builds = function(){
if (this.gold > this.costOf("archer")) {
    this.summon("archer");
}

};
this.comm = function(friend){
if (friend) {
    var enemy = friend.findNearestEnemy();
    if (friend.type == "paladin" && this.health < this.maxHealth) {
        this.command(friend, "cast", "heal", this);
    }
    else if (enemy && enemy.type != "tower") {
        this.command(friend, "attack", enemy);
    }
    else {
        if (friend.pos.x < 240) {
        this.command(friend, "move", {x:friend.pos.x+1,y:28});            
        }

    }
}

};
this.commandFriends = function() {
    // Command your friends.
    var friends = this.findFriends();
    for(var i=0; i < friends.length; i++) {
        var friend = friends[i];
         if(friend.type == "paladin") {
            this.comm(friend);
        }
        else if (friend.type == "archer") {
            this.comm(friend);
        }
        else if (friend.type == "soldier") {
            this.comm(friend);
        }
    }
};
loop {
    this.flags();
    this.builds();
    this.attacks();
    this.commandFriends();
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0 0
原创粉丝点击