home *** CD-ROM | disk | FTP | other *** search
- class fwg.Enemy_1 extends MovieClip
- {
- var nY;
- var nR;
- var nSpeed_x;
- var nSpeed_y;
- var nMoment;
- var bFall;
- var nDir;
- var pTarget;
- var nRange_atk;
- var nTime;
- var nRadius;
- var vHit;
- var nHealth_max;
- var mClip;
- var __nHealth;
- var mHealth;
- var bHit;
- var nHealth;
- function Enemy_1()
- {
- super();
- this._y += Common.rdm_2(-50,20);
- this.nY = this._y;
- this.nR = 0;
- this.nSpeed_x = 0;
- this.nSpeed_y = 0;
- this.nMoment = 0;
- this.bFall = true;
- this.nDir = 1;
- this.pTarget = Global.GAME.pKnight;
- Global.GAME.aEnemy.push(this);
- this.nRange_atk = 250 + random(100);
- this.nTime = 0;
- this.nRadius = 40;
- this.vHit = new math.Vector(0,0);
- this.nHealth = this.nHealth_max = 200;
- }
- function init()
- {
- this.mClip.mHead.gotoAndStop(random(this.mClip.mHead._totalframes) + 1);
- }
- function get nHealth()
- {
- return this.__nHealth;
- }
- function set nHealth(_nHealth)
- {
- this.__nHealth = _nHealth;
- this.mHealth.mClip._xscale = this.__nHealth / this.nHealth_max * 100;
- }
- function walk(_n)
- {
- if(this.nDir != _n || this.nSpeed_x == 0)
- {
- this.mClip.mArm_0.mClip.gotoAndStop(1);
- this.nDir = _n;
- this._xscale = this.nDir * 100;
- this.mClip._rotation = 0;
- this.nMoment = 1;
- this.nSpeed_x = _n * 9;
- }
- }
- function bow(_m, x, y)
- {
- var _loc2_ = {x:x,y:y};
- _m.localToGlobal(_loc2_);
- Global.GAME.mClip.globalToLocal(_loc2_);
- var _loc3_ = Common.getAngle(Global.GAME.pKnight,this);
- Common.addClip("fwg.Arrow_2","mArrow_2",Global.GAME.mClip,{_x:_loc2_.x,_y:_loc2_.y,_rotation:(Math.abs(_loc3_) >= 1.5707963267948966 ? _loc3_ * Common.a2r + random(40) + 10 : _loc3_ * Common.a2r - random(40) - 10),nDir:this.nDir});
- }
- function fallEnd()
- {
- }
- function beHit(_l, _r)
- {
- this.nMoment = 4;
- this.mClip.mHead.mEye.gotoAndPlay(2);
- this.bHit = true;
- this.nHealth -= 10;
- this.nTime = 30;
- }
- function movement()
- {
- var _loc2_ = getTimer();
- if(this.bHit)
- {
- switch(this.nMoment)
- {
- case 4:
- if(this.nHealth > 0)
- {
- this.mClip.mArm._rotation = - Common.linearCycle(_loc2_,800,30);
- this.mClip.mArm._yscale = 100 - Common.linearCycle(_loc2_,800,200);
- this.mClip.mHead._rotation = Common.linearCycle(_loc2_ + 100,800,30);
- this.mClip._y = - Common.linearCycle(_loc2_,800,20);
- this.mClip._rotation = - Common.linearCycle(_loc2_ + 100,800,30);
- this.mClip.mLeg._rotation = - Common.linearCycle(_loc2_,800,60);
- if(this.nTime <= 0)
- {
- this.nTime = 0;
- this.bHit = false;
- this.nMoment = 0;
- }
- else
- {
- this.nTime = this.nTime - 1;
- }
- }
- else
- {
- this.nSpeed_x = 0;
- this.nMoment = 6;
- this.remove();
- }
- break;
- case 5:
- break;
- case 6:
- if(this.mClip._alpha > 90)
- {
- this.remove();
- }
- this.mClip._alpha -= 10;
- if(this.mClip._alpha < 0)
- {
- Global.GAME.pKnight.nKill = Global.GAME.pKnight.nKill + 1;
- Global.GAME.nScore += 5;
- Global.playSound("sdDeath_d");
- this.removeMovieClip();
- }
- break;
- case 7:
- }
- }
- else
- {
- switch(this.nMoment)
- {
- case 0:
- case 1:
- this.mClip.mArm._rotation = - Common.linearCycle(_loc2_,800,30);
- this.mClip.mArm._yscale = 100 - Common.linearCycle(_loc2_,800,200);
- this.mClip.mHead._rotation = Common.linearCycle(_loc2_ + 100,800,30);
- this.mClip._y = - Common.linearCycle(_loc2_,800,20);
- this.mClip._rotation = - Common.linearCycle(_loc2_ + 100,800,30);
- this.mClip.mLeg._rotation = - Common.linearCycle(_loc2_,800,60);
- break;
- case 2:
- case 3:
- }
- }
- }
- function moving()
- {
- var _loc2_ = getTimer();
- this._x += this.nSpeed_x;
- this._y += this.nSpeed_y;
- if(Math.abs(this._y - this.nY) > 50)
- {
- this.nSpeed_y = Common.vpNum(this.nY - this._y);
- }
- else
- {
- this.nSpeed_y == 0 && (this.nSpeed_y = -1);
- }
- }
- function onEnterFrame()
- {
- if(!Global.GAME.bPause)
- {
- this.ctrl();
- this.moving();
- this.movement();
- }
- }
- function ctrl()
- {
- if(!this.bHit)
- {
- var _loc2_ = this.pTarget._x - this._x;
- if(Math.abs(_loc2_) > this.nRange_atk)
- {
- this.walk(Common.vpNum(_loc2_));
- }
- else if(this.nTime == 0)
- {
- if(Common.vpNum(_loc2_) == this.nDir)
- {
- this.bow(this.mClip.mHead,50,10);
- this.nTime = 60;
- }
- }
- else
- {
- this.nTime = this.nTime - 1;
- }
- }
- }
- function remove()
- {
- Common.removeArray(Global.GAME.aEnemy,this);
- }
- }
-