-
Notifications
You must be signed in to change notification settings - Fork 1
/
Weapon.as
47 lines (43 loc) · 1.12 KB
/
Weapon.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package{
import flash.display.MovieClip;
import flash.events.Event;
public class Weapon extends MovieClip{
var speed:Number;
var type:Number;
function Weapon(){
speed = 3;
rotation = 30;
type = Math.floor(Math.random()*3+1);
this.x = 650;
this.y = Math.random()*200+50;
addEventListener("enterFrame", enterFrame);
}
function enterFrame(e:Event){
this.rotation -= .5;
this.x -= speed;
if(this.hitTestObject(Game.ship)){
if(type){
if(Wingman.list.length < Wingman.maxWingmen){
var wingman = new Wingman();
alert("Wingman!");
stage.addChild(wingman);
}
else { alert("Too many Wingmen!"); }
}
removeEventListener("enterFrame", enterFrame);
stage.removeChild(this);
}
if(this.x < -30 || Game.ship.visible == false){
removeEventListener("enterFrame", enterFrame);
stage.removeChild(this);
}
}
function alert(floaty) {
var alert = new FloatyAlert();
alert.x = Game.ship.x;
alert.y = Game.ship.y - 15;
alert.floatyText.text = floaty;
stage.addChild(alert);
}
}
}