home *** CD-ROM | disk | FTP | other *** search
- class CEnemyPlane extends MovieClip
- {
- var pos;
- var dir;
- var speed;
- var bigPlane;
- var depthInMovie;
- var state;
- var lastDepth;
- var xDir;
- var lifeCount;
- var removeFlag;
- var shotCounter;
- var curShotTime;
- var timeCounter;
- var myWidth2;
- var myHeight2;
- var myDepth2;
- var toAway;
- static var PLAYER;
- static var SHOT_TIME = 4500;
- static var SHOT_SMALL_TIME = 250;
- static var NUM_SHOTS = 3;
- function CEnemyPlane()
- {
- super();
- }
- function init(pos_, dir_, speed_, objTransform, bigPlane_, depthInMovie_)
- {
- this.pos = pos_;
- this.dir = dir_;
- this.speed = speed_;
- this.bigPlane = bigPlane_;
- this.depthInMovie = depthInMovie_;
- this.state = 0;
- this.lastDepth = objTransform.depth / 5.5;
- if(this.dir.x > 0)
- {
- this.xDir = -1;
- }
- else
- {
- this.xDir = 1;
- }
- if(this.bigPlane)
- {
- this.lifeCount = 2;
- }
- else
- {
- this.lifeCount = 1;
- }
- this.removeFlag = false;
- this.shotCounter = 0;
- this.curShotTime = CEnemyPlane.SHOT_TIME * 0.3 + 3 * CEnemyPlane.SHOT_TIME * Math.random();
- this.timeCounter = 0;
- this.myWidth2 = this._width * 0.5;
- this.myHeight2 = this._height * 0.4;
- this.myDepth2 = CShot.LENGTH * 0.5;
- this.toAway = false;
- }
- function process(dTime)
- {
- if(this.state == 0)
- {
- this.timeCounter += dTime;
- }
- if(this.state == 0 && this.pos.z <= this.lastDepth)
- {
- if(!this.bigPlane)
- {
- if(CEnemyPlane.PLAYER._x > this._x && this.dir.x > 0)
- {
- this.dir.x = - Math.abs(this.dir.x);
- }
- if(CEnemyPlane.PLAYER._x < this._x && this.dir.x < 0)
- {
- this.dir.x = Math.abs(this.dir.x);
- }
- if(CEnemyPlane.PLAYER._y > this._y && this.dir.y > 0)
- {
- this.dir.y = - Math.abs(this.dir.y);
- }
- if(CEnemyPlane.PLAYER._y < this._y && this.dir.y < 0)
- {
- this.dir.y = Math.abs(this.dir.y);
- }
- if(this.dir.x > 0)
- {
- this.xDir = -1;
- }
- else
- {
- this.xDir = 1;
- }
- }
- if(this.dir.y > 0 && !this.bigPlane)
- {
- this.gotoAndStop("st_d1");
- }
- else
- {
- this.gotoAndStop("st_u1");
- }
- if(this.bigPlane)
- {
- this.dir.y = - Math.abs(this.dir.y);
- }
- this.state = 1;
- this.toAway = true;
- }
- else if(this.state == 1 && this.pos.z <= this.lastDepth / 2)
- {
- if(!this.bigPlane)
- {
- if(this.dir.y > 0)
- {
- this.gotoAndStop("st_d2");
- }
- else
- {
- this.gotoAndStop("st_u2");
- }
- }
- this.state = 2;
- }
- var _loc2_ = this.speed * dTime / 1000;
- if(this.state == 0)
- {
- this.pos.x += this.dir.x * _loc2_;
- this.pos.y += this.dir.y * _loc2_;
- this.pos.z += this.dir.z * _loc2_;
- }
- else
- {
- if(this.bigPlane)
- {
- this.pos.x += this.dir.x * _loc2_;
- }
- else
- {
- this.pos.x += this.dir.x * _loc2_ * 140 * (this.lastDepth - this.pos.z) / this.lastDepth;
- }
- this.pos.y += this.dir.y * _loc2_ * 180 * (this.lastDepth - this.pos.z) / this.lastDepth;
- this.pos.z += this.dir.z * _loc2_ * ((this.lastDepth - this.pos.z) / this.lastDepth + 1);
- }
- }
- function screenSynchronize(objTransform)
- {
- var _loc2_ = {x:0,y:0,k:0};
- objTransform.getScreenXY(this.pos.x,this.pos.y,this.pos.z,_loc2_);
- this._x = _loc2_.x;
- this._y = _loc2_.y;
- this._xscale = (this._yscale = _loc2_.k * 100) * this.xDir;
- if(this.pos.z < 0)
- {
- this.removeFlag = true;
- }
- }
- function canShot()
- {
- return this.timeCounter >= this.curShotTime;
- }
- function doShot()
- {
- this.timeCounter = 0;
- this.shotCounter = this.shotCounter + 1;
- if(!this.bigPlane && this.shotCounter < CEnemyPlane.NUM_SHOTS || this.bigPlane && this.shotCounter < CEnemyPlane.NUM_SHOTS * 1.2)
- {
- this.curShotTime = CEnemyPlane.SHOT_SMALL_TIME;
- }
- else
- {
- this.curShotTime = CEnemyPlane.SHOT_TIME - CEnemyPlane.SHOT_TIME * 0.3 + CEnemyPlane.SHOT_TIME * 0.6 * Math.random();
- this.shotCounter = 0;
- }
- }
- function doDmage()
- {
- this.lifeCount = this.lifeCount - 1;
- return this.lifeCount <= 0;
- }
- function disable()
- {
- this.removeMovieClip();
- }
- }
-