home *** CD-ROM | disk | FTP | other *** search
- class CShip extends MovieClip
- {
- var myType;
- var speed;
- var pos;
- var depthInMovie;
- var lifeCount;
- var shotCounter;
- var curShotTime;
- var timeCounter;
- var removeFlag;
- var myWidth2;
- var myScale;
- static var PLAYER;
- static var SHOT_TIME = 8000;
- static var SHOT_SMALL_TIME = 400;
- static var NUM_SHOTS = 3;
- static var SCREEN_WIDTH = 550;
- function CShip()
- {
- super();
- }
- function init(myType_, speed_, pos_, depthInMovie_)
- {
- this.myType = myType_;
- this.speed = speed_;
- this.pos = pos_;
- this.depthInMovie = depthInMovie_;
- if(this.myType == 2)
- {
- this.lifeCount = 2;
- }
- else
- {
- this.lifeCount = 1;
- }
- this.shotCounter = 0;
- this.curShotTime = CShip.SHOT_TIME - CShip.SHOT_TIME * 0.3 + CShip.SHOT_TIME * 0.6 * Math.random();
- this.timeCounter = 0;
- this.removeFlag = false;
- this.myWidth2 = this._width * 0.29;
- if(this.myType == 1)
- {
- this.myScale = 0.75;
- }
- else
- {
- this.myScale = 1.3;
- }
- }
- function process(dTime)
- {
- var _loc2_ = this.speed * dTime / 1000;
- this.timeCounter += dTime;
- this.pos.x += _loc2_;
- }
- 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 * 150;
- if(this.pos.x >= objTransform.nearWidth && this._x - this._width / 2 >= CShip.SCREEN_WIDTH)
- {
- this.removeFlag = true;
- }
- var _loc6_ = objTransform.nearHeight - CShip.PLAYER.y;
- var _loc5_ = Math.sqrt((this.pos.x - CShip.PLAYER.x) * (this.pos.x - CShip.PLAYER.x) + this.pos.z * this.pos.z);
- var _loc3_ = _loc6_ / _loc5_;
- if(_loc3_ < 0.66)
- {
- this.gotoAndStop(1);
- }
- else if(_loc3_ < 1.2)
- {
- this.gotoAndStop(2);
- }
- else
- {
- this.gotoAndStop(3);
- }
- }
- function canShot()
- {
- return this.myType > 0 && this.timeCounter >= this.curShotTime;
- }
- function doShot()
- {
- this.timeCounter = 0;
- this.shotCounter = this.shotCounter + 1;
- if(this.shotCounter < CShip.NUM_SHOTS)
- {
- this.curShotTime = CShip.SHOT_SMALL_TIME;
- }
- else
- {
- this.curShotTime = CShip.SHOT_TIME - CShip.SHOT_TIME * 0.3 + CShip.SHOT_TIME * 0.6 * Math.random();
- this.shotCounter = 0;
- }
- }
- function doDmage()
- {
- this.lifeCount = this.lifeCount - 1;
- return this.lifeCount <= 0;
- }
- function disable()
- {
- this.removeMovieClip();
- }
- }
-