home *** CD-ROM | disk | FTP | other *** search
- class Father extends MovieClip
- {
- var distance;
- var onEnterFrame;
- var speed;
- var frontFish;
- var dot;
- var road_num;
- function Father()
- {
- super();
- this.distance = 80 + random(5) * 10;
- this.onEnterFrame = function()
- {
- if(_root.game.isGameOver == false)
- {
- if(_root.game.isPause == false)
- {
- this.run();
- }
- }
- else
- {
- _root.game.gotoAndPlay("gameover");
- }
- };
- }
- function run()
- {
- if(this._parent.fish_mc.isFly)
- {
- this._x -= 20;
- this.testHitDiamond();
- }
- else
- {
- this._x -= this.speed;
- this.testHit1();
- }
- if(this._x < - this._width)
- {
- this.removeMovieClip();
- }
- if(this.frontFish._x > 0 && this._x <= this.frontFish._x + this.frontFish._width + this.distance)
- {
- this._x = this.frontFish._x + this.frontFish._width + this.distance;
- this.speed = this.frontFish.speed;
- }
- }
- function testHitDiamond()
- {
- if(this.dot.hitTest(this._parent.fish_mc.dot) && this.road_num == this._parent.fish_mc.road_num && this._parent.fish_mc.isDead == false)
- {
- if(this._currentframe >= 13 && this._currentframe < this._totalframes)
- {
- if(!this._parent.fish_mc.isUnder)
- {
- this.removeMovieClip();
- _root.game.soundManage.playSound("get_s");
- _root.game.score += _root.game.eachScore;
- _root.game.testScore();
- _root.game.score_txt.text = _root.game.score;
- }
- }
- }
- }
- function testHit()
- {
- if(this.dot.hitTest(this._parent.fish_mc.dot) && this.road_num == this._parent.fish_mc.road_num && this._parent.fish_mc.isDead == false)
- {
- if(this._currentframe < 3)
- {
- if(!this._parent.fish_mc.isUnder)
- {
- this._parent.fish_mc.gotoAndPlay("dead");
- this._parent.fish_mc.isDead = true;
- _root.game.soundManage.playSound("over_s");
- }
- }
- else if(this._currentframe >= 3 && this._currentframe < 13)
- {
- this._parent.fish_mc.gotoAndPlay("dead");
- this._parent.fish_mc.isDead = true;
- _root.game.soundManage.playSound("over_s");
- }
- else if(this._currentframe >= 13 && this._currentframe < this._totalframes)
- {
- if(!this._parent.fish_mc.isUnder)
- {
- this._parent.fish_mc.gotoAndPlay("getDiamond");
- _root.game.soundManage.playSound("get_s");
- _root.game.score += 50;
- _root.game.score_txt.text = _root.game.score;
- this.removeMovieClip();
- }
- }
- else if(!this._parent.fish_mc.isUnder)
- {
- this._parent.fish_mc.gotoAndPlay("fly");
- _root.game.soundManage.playSound("move_s");
- }
- }
- }
- function testHit1()
- {
- if(this.dot.hitTest(this._parent.fish_mc.dot) && this.road_num == this._parent.fish_mc.road_num && this._parent.fish_mc.isDead == false)
- {
- if(this._currentframe < 13)
- {
- if(!this._parent.fish_mc.isUnder)
- {
- this._parent.fish_mc.isDead = true;
- this._parent.fish_mc.gotoAndPlay("dead");
- _root.game.soundManage.playSound("over_s");
- }
- }
- else if(this._currentframe >= 13 && this._currentframe < this._totalframes)
- {
- if(!this._parent.fish_mc.isUnder)
- {
- this._parent.fish_mc.gotoAndPlay("getDiamond");
- _root.game.score += _root.game.eachScore;
- _root.game.testScore();
- _root.game.score_txt.text = _root.game.score;
- this.removeMovieClip();
- }
- }
- else if(!this._parent.fish_mc.isUnder)
- {
- this._parent.fish_mc.isFly = true;
- this._parent.fish_mc.gotoAndPlay("fly");
- _root.game.soundManage.playSound("move_s");
- this.removeMovieClip();
- }
- }
- }
- }
-