function fire(){
if(reloaded){
x=maze.getNextHighestDepth();
bullet_array.push("shot"+x);
var bullet:MovieClip=maze.attachMovie("shot", "shot"+x, x);
bullet._x=_root.crosshair._x-maze._x;
bullet._y=_root.crosshair._y-maze._y;
randomNum=random(bulletOffset)-bulletOffset/2;
bullet._rotation=crosshair._rotation+randomNum;
bullet.xSpeed=Math.cos(Math.PI/180 * bullet._rotation)*bulletSpeed;
bullet.ySpeed=Math.sin(Math.PI/180 * bullet._rotation)*bulletSpeed;
bullet.life=0;
bullet.onEnterFrame=function(){
this._x+=this.xSpeed;
this._y+=this.ySpeed;
this.life++;
if(this.life>totalLife){
this.removeMovieClip();
this.unloadMovie();
}
};
reload();
}
}
function reload(){
reloaded=false;
timer=setInterval(this, "Reloaded", reloadSpeed);
}
function Reloaded(){
clearInterval(timer);
reloaded=true
}
for (x=0; x<2; x++) {
attachEnemy();
}
function attachEnemy() {
x = maze.getNextHighestDepth();
var enemy:MovieClip = maze.attachMovie("box", "box"+x, x);
enemy._x = 0;
enemy._y = 0;
enemy.onEnterFrame = function() {
for (x in bullet_array) {
if (this.hitTest(maze[bullet_array[x]])) {
maze[bullet_array[x]].removeMovieClip();
this.removeMovieClip();
bullet_array.splice(x,1);
_root.explosion(this._x,this._y);
}
}
};
}