home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / FishyHop.swf / scripts / __Packages / Father.as < prev    next >
Encoding:
Text File  |  2008-09-05  |  4.3 KB  |  138 lines

  1. class Father extends MovieClip
  2. {
  3.    var distance;
  4.    var onEnterFrame;
  5.    var speed;
  6.    var frontFish;
  7.    var dot;
  8.    var road_num;
  9.    function Father()
  10.    {
  11.       super();
  12.       this.distance = 80 + random(5) * 10;
  13.       this.onEnterFrame = function()
  14.       {
  15.          if(_root.game.isGameOver == false)
  16.          {
  17.             if(_root.game.isPause == false)
  18.             {
  19.                this.run();
  20.             }
  21.          }
  22.          else
  23.          {
  24.             _root.game.gotoAndPlay("gameover");
  25.          }
  26.       };
  27.    }
  28.    function run()
  29.    {
  30.       if(this._parent.fish_mc.isFly)
  31.       {
  32.          this._x -= 20;
  33.          this.testHitDiamond();
  34.       }
  35.       else
  36.       {
  37.          this._x -= this.speed;
  38.          this.testHit1();
  39.       }
  40.       if(this._x < - this._width)
  41.       {
  42.          this.removeMovieClip();
  43.       }
  44.       if(this.frontFish._x > 0 && this._x <= this.frontFish._x + this.frontFish._width + this.distance)
  45.       {
  46.          this._x = this.frontFish._x + this.frontFish._width + this.distance;
  47.          this.speed = this.frontFish.speed;
  48.       }
  49.    }
  50.    function testHitDiamond()
  51.    {
  52.       if(this.dot.hitTest(this._parent.fish_mc.dot) && this.road_num == this._parent.fish_mc.road_num && this._parent.fish_mc.isDead == false)
  53.       {
  54.          if(this._currentframe >= 13 && this._currentframe < this._totalframes)
  55.          {
  56.             if(!this._parent.fish_mc.isUnder)
  57.             {
  58.                this.removeMovieClip();
  59.                _root.game.soundManage.playSound("get_s");
  60.                _root.game.score += _root.game.eachScore;
  61.                _root.game.testScore();
  62.                _root.game.score_txt.text = _root.game.score;
  63.             }
  64.          }
  65.       }
  66.    }
  67.    function testHit()
  68.    {
  69.       if(this.dot.hitTest(this._parent.fish_mc.dot) && this.road_num == this._parent.fish_mc.road_num && this._parent.fish_mc.isDead == false)
  70.       {
  71.          if(this._currentframe < 3)
  72.          {
  73.             if(!this._parent.fish_mc.isUnder)
  74.             {
  75.                this._parent.fish_mc.gotoAndPlay("dead");
  76.                this._parent.fish_mc.isDead = true;
  77.                _root.game.soundManage.playSound("over_s");
  78.             }
  79.          }
  80.          else if(this._currentframe >= 3 && this._currentframe < 13)
  81.          {
  82.             this._parent.fish_mc.gotoAndPlay("dead");
  83.             this._parent.fish_mc.isDead = true;
  84.             _root.game.soundManage.playSound("over_s");
  85.          }
  86.          else if(this._currentframe >= 13 && this._currentframe < this._totalframes)
  87.          {
  88.             if(!this._parent.fish_mc.isUnder)
  89.             {
  90.                this._parent.fish_mc.gotoAndPlay("getDiamond");
  91.                _root.game.soundManage.playSound("get_s");
  92.                _root.game.score += 50;
  93.                _root.game.score_txt.text = _root.game.score;
  94.                this.removeMovieClip();
  95.             }
  96.          }
  97.          else if(!this._parent.fish_mc.isUnder)
  98.          {
  99.             this._parent.fish_mc.gotoAndPlay("fly");
  100.             _root.game.soundManage.playSound("move_s");
  101.          }
  102.       }
  103.    }
  104.    function testHit1()
  105.    {
  106.       if(this.dot.hitTest(this._parent.fish_mc.dot) && this.road_num == this._parent.fish_mc.road_num && this._parent.fish_mc.isDead == false)
  107.       {
  108.          if(this._currentframe < 13)
  109.          {
  110.             if(!this._parent.fish_mc.isUnder)
  111.             {
  112.                this._parent.fish_mc.isDead = true;
  113.                this._parent.fish_mc.gotoAndPlay("dead");
  114.                _root.game.soundManage.playSound("over_s");
  115.             }
  116.          }
  117.          else if(this._currentframe >= 13 && this._currentframe < this._totalframes)
  118.          {
  119.             if(!this._parent.fish_mc.isUnder)
  120.             {
  121.                this._parent.fish_mc.gotoAndPlay("getDiamond");
  122.                _root.game.score += _root.game.eachScore;
  123.                _root.game.testScore();
  124.                _root.game.score_txt.text = _root.game.score;
  125.                this.removeMovieClip();
  126.             }
  127.          }
  128.          else if(!this._parent.fish_mc.isUnder)
  129.          {
  130.             this._parent.fish_mc.isFly = true;
  131.             this._parent.fish_mc.gotoAndPlay("fly");
  132.             _root.game.soundManage.playSound("move_s");
  133.             this.removeMovieClip();
  134.          }
  135.       }
  136.    }
  137. }
  138.