public function collide():Boolean {
var tanks:Array = Global.tanks;
// collision detection between bullets and tanks
for (var i:int = tanks.length - 1; i >= 0; i--)
{
// tanks won't hit themselves
if (sender.id == tanks[i].id || sender.type == tanks[i].type) {
continue;
}
if (new Point(global_x, global_y).collideRect(tanks[i].getRect())) {
// check tank's hp points
if (tanks[i].hp > 0) {
tanks[i].hp -= this.damage;
}
if (tanks[i].hp <= 0) {
if (tanks[i].type == 'enemy_tank') {
Global.current_enemies_num--;
// gain experience
(this.sender as AllyTank).gainExp(tanks[i].containing_exp);
}
tanks[i].remove();
Global.dying_tanks = Global.dying_tanks.concat(tanks.splice(i, 1));
}
return true;
}
}
...public function collide():Boolean {