您的位置:首页 > 编程语言

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

2015-09-14 00:02 393 查看
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();

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: