// Pokonaj ogry przywołując i dowodząc jednostkami.
// Przywołaj 2 rycerzy.
game.spawnXY("soldier", 35, 20);
game.spawnXY("soldier", 45, 20);
// Przywołaj 2 łuczników.
game.spawnXY("archer", 24, 25);
game.spawnXY("archer", 63, 18);
function fightEnemies(event) {
while(true) {
// event.target is the unit that is executing this event handler function!
var friendUnit = event.target;
var enemy = friendUnit.findNearestEnemy();
// Have friendUnit attack() the enemy!
friendUnit.attack(enemy);
}
}
// This attaches the fightEnemies handler to all soldiers' "spawn" events.
game.setActionFor("soldier", "spawn", fightEnemies);
// Now, attach fightEnemies to the archers' "spawn" events:
game.setActionFor("archer", "spawn", fightEnemies);
Projektuję strony www Lublin na Joomla i WordPress