home *** CD-ROM | disk | FTP | other *** search
- class fwg.Knight extends MovieClip
- {
- var nTime_hit;
- var nGn;
- var bRun;
- var nW_h;
- var nSpeed_x;
- var nSpeed_y;
- var nY_p1;
- var nY_p2;
- var nR;
- var nR_weapon;
- var nMoment;
- var nMode;
- var bChain;
- var nMode_skill;
- var nTime_0;
- var nTime_hold;
- var bFall;
- var nDir;
- var nRadius;
- var nSuper_max;
- var nHealth_max;
- var vHit;
- var nCombo;
- var sdHit;
- var sdRun;
- var nY_house;
- var mHouse;
- var nY_hero;
- var mHero;
- var __nHealth;
- var nKill;
- var pCtrl;
- var __nSuper;
- var __nKill;
- var nHealth;
- var nSuper;
- function Knight()
- {
- super();
- this.nTime_hit = 0;
- this.nGn = 0;
- this.bRun = true;
- this.nW_h = 20;
- this.nSpeed_x = 0;
- this.nSpeed_y = 0;
- this.nY_p1 = 0;
- this.nY_p2 = 0;
- this.nR = 0;
- this.nR_weapon = 0;
- this.nMoment = 0;
- this.nMode = 0;
- this.bChain = false;
- this.nMode_skill = 0;
- this.nTime_0 = 0;
- this.nTime_hold = 0;
- this.bFall = true;
- this.nDir = 1;
- this.nRadius = 40;
- this.nSuper = this.nSuper_max = 200;
- this.nHealth = this.nHealth_max = 100;
- this.vHit = new math.Vector(0,-30);
- this.nKill = 0;
- this.nCombo = 0;
- this.sdHit = new Sound(this);
- this.sdRun = new Sound(this);
- this.sdRun.attachSound("sdHorse_run");
- this.sdHit.attachSound("sdHit_" + random(3));
- }
- function init()
- {
- this.nY_house = this.mHouse._y;
- this.nY_hero = this.mHero._y;
- }
- function get nHealth()
- {
- return this.__nHealth;
- }
- function set nHealth(_nHealth)
- {
- this.__nHealth = _nHealth;
- if(this.__nHealth < 0)
- {
- Global.GAME.nKill = this.nKill;
- Global.GAME.gotoAndStop("gameover");
- }
- Global.GAME.mHealth.mClip._xscale = this.__nHealth / this.nHealth_max * 100;
- }
- function onEnterFrame()
- {
- if(!Global.GAME.bPause)
- {
- this.pCtrl.move();
- this.falling();
- this.moving();
- this.movement();
- }
- }
- function get nSuper()
- {
- return this.__nSuper;
- }
- function set nSuper(_nSuper)
- {
- this.__nSuper = _nSuper;
- Global.GAME.mSuper.mClip._xscale = this.__nSuper / this.nSuper_max * 100;
- }
- function get nKill()
- {
- return this.__nKill;
- }
- function set nKill(_nKill)
- {
- this.__nKill = _nKill;
- Global.GAME.mKill.sTxt = "KILLS: " + this.__nKill;
- if(this.__nKill > 0)
- {
- this.nCombo = this.nCombo + 1;
- Global.GAME.nScore += this.nCombo;
- Global.GAME.mCombo.removeMovieClip();
- Global.GAME.mCombo = Global.GAME.attachMovie("mCombo","mCombo",Global.GAME.getNextHighestDepth(),{_x:Global.WIDTH - 10,_y:350,sTxt:"SLAUGHTER\nBONUS " + this.nCombo,nTime:120 - this.nCombo * 2,rtFun:function()
- {
- Global.GAME.pKnight.nCombo = 0;
- }});
- }
- }
- function beHit(_l, _r)
- {
- if(getTimer() - this.nTime_hit > 50)
- {
- this.nTime_hit = getTimer();
- this.sdHit.attachSound("sdHit_" + random(3));
- this.sdHit.start();
- }
- this.nHealth -= 2;
- }
- function walk(_n)
- {
- if(this.nDir != _n || this.nSpeed_x == 0)
- {
- this.nDir = _n;
- this._xscale = this.nDir * 100;
- !this.bRun ? (this.nSpeed_x = _n * 4) : (this.nSpeed_x = _n * 7);
- if(!this.bFall)
- {
- if(this.bRun)
- {
- this.nMoment = 2;
- }
- else
- {
- this.nMoment = 1;
- this.mHouse._y = this.nY_house;
- this.mHero._y = this.nY_hero;
- this.mHouse.mTail._rotation = 0;
- }
- }
- }
- }
- function stand()
- {
- this.nSpeed_x = 0;
- this.bRun = true;
- if(!this.bFall)
- {
- this.nMoment = 0;
- this.mHouse._y = this.nY_house;
- this.mHero._y = this.nY_hero;
- this.mHouse.mTail._rotation = 0;
- this.mHouse.mLeg_0._rotation = 0;
- this.mHouse.mLeg_2._rotation = 0;
- this.mHouse.mLeg_1._rotation = 0;
- this.mHouse.mLeg_3._rotation = 0;
- this.setPos();
- }
- }
- function jump()
- {
- if(!this.bFall)
- {
- Global.playSound("sdJp");
- this.nMoment = 3;
- this.nSpeed_y = -24;
- this.bFall = true;
- this.mHouse._y = this.nY_house;
- this.mHero._y = this.nY_hero;
- this.mHouse.mTail._rotation = 90;
- this.mHouse.mLeg_0._rotation = -90;
- this.mHouse.mLeg_2._rotation = -90;
- this.mHouse.mLeg_1._rotation = 60;
- this.mHouse.mLeg_3._rotation = 60;
- }
- }
- function fallEnd()
- {
- this.bFall = false;
- this.nSpeed_y = 0;
- this.setPos();
- if(this.nSpeed_x != 0)
- {
- this.nMoment = 2;
- }
- else
- {
- this.sdRun.start();
- this.stand();
- }
- }
- function houseAtk()
- {
- }
- function attacking()
- {
- this.nTime_hold = this.nTime_hold + 1;
- }
- function attack_2()
- {
- if(this.nSuper > 160)
- {
- this.nSuper -= 160;
- this.mHero.mArm_0.gotoAndStop(this.nMode * 10 + 2);
- }
- }
- function isStop()
- {
- var _loc2_ = !this.bChain;
- this.bChain = false;
- return _loc2_;
- }
- function atkReady()
- {
- this.nTime_0 = 0;
- this.bChain = false;
- }
- function attack_0()
- {
- if(this.nMode_skill == 0)
- {
- if(getTimer() - this.nTime_0 < 300)
- {
- this.bChain = true;
- }
- this.nTime_0 = getTimer();
- this.mHero.mArm_0.mClip.play();
- }
- }
- function ckHit(_m)
- {
- var _loc4_ = {x:0,y:0};
- var _loc2_ = new Object();
- _m.localToGlobal(_loc4_);
- for(var _loc9_ in Global.GAME.aEnemy)
- {
- _loc2_.x = Global.GAME.aEnemy[_loc9_].vHit.x;
- _loc2_.y = Global.GAME.aEnemy[_loc9_].vHit.y;
- Global.GAME.aEnemy[_loc9_].localToGlobal(_loc2_);
- var _loc5_ = Common.distance(_loc4_.x,_loc4_.y,_loc2_.x,_loc2_.y);
- if(_loc5_ < _m.nRadius + Global.GAME.aEnemy[_loc9_].nRadius)
- {
- if(getTimer() - this.nTime_hit > 50)
- {
- this.nTime_hit = getTimer();
- this.sdHit.attachSound("sdHit_" + random(3));
- this.sdHit.start();
- }
- this.nSuper < 200 && this.nSuper;
- Global.GAME.aEnemy[_loc9_].beHit(_m.nPower,this.nDir <= 0 ? 3.141592653589793 - _m._rotation / Common.a2r : _m._rotation / Common.a2r);
- _loc2_.x = (_loc4_.x + _loc2_.x) / 2;
- _loc2_.y = (_loc4_.y + _loc2_.y) / 2;
- Global.GAME.aEnemy[_loc9_].globalToLocal(_loc2_);
- Common.addClip("mBlood",null,Global.GAME.aEnemy[_loc9_],{_x:_loc2_.x,_y:_loc2_.y,_rotation:_m._rotation + Common.rdm_2(-60,60)});
- }
- }
- }
- function changeWeapon(_n)
- {
- if(_n == undefined)
- {
- this.nMode != 1 ? (this.nMode = 1) : (this.nMode = 0);
- }
- else
- {
- this.nMode = _n;
- }
- Global.playSound("sdCh");
- this.mHero.mArm_0.gotoAndStop(this.nMode * 10 + 1);
- }
- function movement()
- {
- var _loc2_ = getTimer();
- switch(this.nMoment)
- {
- case 0:
- this.mHero.mHead._y = - Common.linearCycle(_loc2_,800,2) - 10;
- this.mHouse.mHead._rotation = Common.linearCycle(_loc2_,800,15);
- break;
- case 1:
- this.mHero.mHead._y = - Common.linearCycle(_loc2_,800,2) - 10;
- this.mHouse.mHead._rotation = Common.linearCycle(_loc2_,800,15);
- this.mHouse.mLeg_0._rotation = 45 - Common.linearCycle(_loc2_,800,90);
- this.mHouse.mLeg_2._rotation = 45 - Common.linearCycle(_loc2_ + 400,800,90);
- this.mHouse.mLeg_1._rotation = 45 - Common.linearCycle(_loc2_ + 100,800,90);
- this.mHouse.mLeg_3._rotation = 45 - Common.linearCycle(_loc2_ + 500,800,90);
- break;
- case 2:
- this.mHero.mHead._y = - Common.unlinearCycle(_loc2_,500,2) - 10;
- this.mHouse.mHead._rotation = Common.unlinearCycle(_loc2_,500,15);
- this.mHouse.mTail._rotation = Common.linearCycle(_loc2_ - 100,500,60);
- this.mHouse.mLeg_0._rotation = 60 - Common.unlinearCycle(_loc2_,500,120);
- this.mHouse.mLeg_2._rotation = 60 - Common.unlinearCycle(_loc2_ + 50,500,120);
- this.mHouse.mLeg_1._rotation = Common.unlinearCycle(_loc2_,500,120) - 60;
- this.mHouse.mLeg_3._rotation = Common.unlinearCycle(_loc2_ + 50,500,120) - 60;
- this.mHouse._y = - Common.linearCycle(_loc2_ + 50,500,20) + this.nY_house + 5;
- this.mHero._y = - Common.linearCycle(_loc2_ + 25,500,20) + this.nY_hero + 5;
- if(this.mHero._y > -27 && this.sdRun.position > 300)
- {
- this.sdRun.start();
- }
- break;
- case 3:
- this.mHouse._rotation = _loc0_ = this.nSpeed_y;
- this.mHero._rotation = _loc0_;
- break;
- case 4:
- case 5:
- case 6:
- }
- }
- function moving()
- {
- if(this.nSpeed_x)
- {
- this._x += this.nSpeed_x;
- this.ground();
- !this.bFall && this.setPos();
- }
- }
- function falling()
- {
- if(this.bFall)
- {
- this.nSpeed_y += Game.nG;
- if(Game.hitGround(this._x,this._y + this.nSpeed_y,this._parent,Global.GAME.mClip.mMid))
- {
- this.fallEnd();
- }
- else
- {
- this._y += this.nSpeed_y;
- }
- }
- }
- function setPos()
- {
- this.nY_p1 = Game.getBetween(this._x - this.nW_h,this._y,this._parent,Global.GAME.mClip.mMid);
- this.nY_p2 = Game.getBetween(this._x + this.nW_h,this._y,this._parent,Global.GAME.mClip.mMid);
- this._y = (Game.getBetween(this._x,this._y,this._parent,Global.GAME.mClip.mMid) + this._y) / 2 - 1;
- this.nR = (Math.atan2(this.nY_p1 - this.nY_p2,this.nW_h * 2) + this.nR) / 2;
- this.mHero._rotation = this.mHouse._rotation = (- this.nR) * Common.a2r * this.nDir;
- }
- function ground()
- {
- var _loc3_ = this._x + this._parent._x;
- if(this.nSpeed_x > 0)
- {
- if(_loc3_ > 400)
- {
- if(Global.GAME.mMid.mShape_0._x + Global.GAME.mMid._x < -320)
- {
- Global.GAME.mMid.mShape_0._x += Global.WIDTH * 2 - 20;
- Global.GAME.mMid.mShape_0.mClip.gotoAndStop(random(6) + 1);
- Global.GAME.mMid.mShape_0._name = "mShape_0_";
- Global.GAME.mMid.mShape_1._name = "mShape_0";
- Global.GAME.mMid.mShape_2._name = "mShape_1";
- Global.GAME.mMid.mShape_0_._name = "mShape_2";
- }
- this._parent._x -= this.nSpeed_x;
- this._parent._parent.mMid._x = this._parent._x * 0.5;
- var _loc2_ = (Math.abs(this._parent._x) + Global.WIDTH / 2) / Global.WIDTH;
- if(this.nGn != int(_loc2_))
- {
- this.nGn = int(_loc2_);
- Global.GAME.mClip.mMid.mShape_0.gotoAndStop(random(9) + 1);
- Global.GAME.mClip.mMid.mShape_0._x += Global.WIDTH * 3;
- Global.GAME.mClip.mMid.mShape_0._name = "mShape_0_";
- Global.GAME.mClip.mMid.mShape_1._name = "mShape_0";
- Global.GAME.mClip.mMid.mShape_2._name = "mShape_1";
- Global.GAME.mClip.mMid.mShape_0_._name = "mShape_2";
- }
- }
- }
- else if(_loc3_ < 240)
- {
- if(Global.GAME.mMid.mShape_2._x + Global.GAME.mMid._x > 960)
- {
- Global.GAME.mMid.mShape_2._x -= Global.WIDTH * 2 - 20;
- Global.GAME.mMid.mShape_2.mClip.gotoAndStop(random(6) + 1);
- Global.GAME.mMid.mShape_2._name = "mShape_2_";
- Global.GAME.mMid.mShape_1._name = "mShape_2";
- Global.GAME.mMid.mShape_0._name = "mShape_1";
- Global.GAME.mMid.mShape_2_._name = "mShape_0";
- }
- this._parent._x -= this.nSpeed_x;
- this._parent._parent.mMid._x = this._parent._x * 0.5;
- _loc2_ = (Math.abs(this._parent._x) + Global.WIDTH / 2) / Global.WIDTH;
- if(this.nGn != int(_loc2_))
- {
- this.nGn = int(_loc2_);
- Global.GAME.mClip.mMid.mShape_2.gotoAndStop(random(9) + 1);
- Global.GAME.mClip.mMid.mShape_2._x -= Global.WIDTH * 3;
- Global.GAME.mClip.mMid.mShape_2._name = "mShape_2_";
- Global.GAME.mClip.mMid.mShape_1._name = "mShape_2";
- Global.GAME.mClip.mMid.mShape_0._name = "mShape_1";
- Global.GAME.mClip.mMid.mShape_2_._name = "mShape_0";
- }
- }
- }
- }
-