-
Notifications
You must be signed in to change notification settings - Fork 0
/
EvilOne.as
43 lines (42 loc) · 1.29 KB
/
EvilOne.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
package {
import flash.display.Sprite;
import flash.net.URLRequest;
import com.junkbyte.console.Cc;
public class EvilOne extends Ship {
private static var imageFile:URLRequest = new URLRequest("http://www.davidpmah.com/planegame/images/evilone.png");
public function EvilOne(x:Number, y:Number):void {
this.x = x;
this.y = y;
xVelocity = Math.random() * 10 - 5;
yVelocity = Math.random() * 10;
graphics.lineStyle(1, 0x000000);
graphics.beginFill(0x0000dd);
graphics.drawRect(-20, -20, 40, 40);
loadSprite();
}
override public function act(index:int):Array {
var sendbacks:Array = super.act(index);
if(Math.random() * 30 < 1) {
sendbacks.push( (new Signal()).setFloater(this.fire()).setIndex(index));
}
this.move();
return sendbacks;
}
private function fire():Projectile{
var bolt:EnemyBoltOne = new EnemyBoltOne(this.x, this.y - 10);
if(this.y < player.y && Math.random() * 2 < 1) {
bolt.affectVelocity(getRatio());
}
return bolt;
}
override public function move():void {
this.x = this.x + xVelocity;
this.y = this.y + yVelocity;
}
override public function getType():String{
return "EvilOne";
}
override public function radius():Number{return 30;}
override public function image():URLRequest{return imageFile;};
}
}