home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / FishyHop.swf / scripts / DefineSprite_276_gameManage / frame_162 / DoAction.as
Encoding:
Text File  |  2008-09-05  |  3.7 KB  |  143 lines

  1. function gameInit()
  2. {
  3.    road_num = random(4);
  4.    level = 0;
  5.    second = 0;
  6.    levelShow = level + 1;
  7.    this.level_txt.text = levelShow;
  8.    this.score_txt.text = score;
  9.    trace("timeDelay=" + levelList[level].timeDelay);
  10.    intervalID = setInterval(this,"bigFishOut",levelList[level].timeDelay);
  11.    timeIntervalID = setInterval(this,"timeControl",1000);
  12.    this.mainGame.attachMovie("fish_mc","fish_mc",road_num * 100 + 98);
  13.    this.mainGame.fish_mc._x = 100;
  14.    this.mainGame.fish_mc._y = y_arr[road_num] - 8;
  15.    this.mainGame.fish_mc.road_num = road_num;
  16.    this.mainGame.fish_mc.y_arr = y_arr;
  17.    this.mainGame.sea_0.swapDepths(99);
  18.    this.mainGame.sea_1.swapDepths(199);
  19.    this.mainGame.sea_2.swapDepths(299);
  20.    this.mainGame.sea_3.swapDepths(399);
  21. }
  22. function bigFishOut()
  23. {
  24.    if(_root.game.isGameOver == false)
  25.    {
  26.       if(_root.game.isPause == false)
  27.       {
  28.          fishOut();
  29.       }
  30.    }
  31. }
  32. function fishOut()
  33. {
  34.    var _loc3_ = undefined;
  35.    _loc3_ = lastRoad + (random(3) + 1);
  36.    _loc3_ < 4 ? _loc3_ : (_loc3_ -= 4);
  37.    lastRoad = _loc3_;
  38.    var _loc4_ = undefined;
  39.    fishList[_loc3_] >= 90 ? (fishList[_loc3_] = 0) : fishList[_loc3_]++;
  40.    _loc4_ = fishList[_loc3_];
  41.    this.mainGame.attachMovie("ship","ship_" + (_loc3_ * 100 + _loc4_),_loc3_ * 100 + _loc4_);
  42.    var _loc2_ = undefined;
  43.    _loc2_ = this.mainGame["ship_" + (_loc3_ * 100 + _loc4_)];
  44.    _loc2_.cacheAsBitmap == true;
  45.    if(boxOut == true)
  46.    {
  47.       if(level >= 9)
  48.       {
  49.          _loc2_.gotoAndStop(random(_loc2_._totalframes - 4) + 3);
  50.       }
  51.       else
  52.       {
  53.          _loc2_.gotoAndStop(random(_loc2_._totalframes - 1) + 1);
  54.       }
  55.    }
  56.    else if(level >= 9)
  57.    {
  58.       _loc2_.gotoAndStop(random(_loc2_._totalframes - 3) + 3);
  59.    }
  60.    else
  61.    {
  62.       _loc2_.gotoAndStop(random(_loc2_._totalframes) + 1);
  63.    }
  64.    if(_loc2_._currentframe == _loc2_._totalframes)
  65.    {
  66.       boxOut = true;
  67.    }
  68.    _loc2_._x = 900;
  69.    _loc2_._y = y_arr[_loc3_];
  70.    if(_loc2_._currentframe < 3)
  71.    {
  72.       _loc2_.speed = 8;
  73.    }
  74.    else
  75.    {
  76.       _loc2_.speed = levelList[level].speed + random(5 + level);
  77.    }
  78.    _loc2_.road_num = _loc3_;
  79.    _loc4_ <= 0 ? (_loc2_.frontFish = this.mainGame["ship_" + (_loc2_.road_num * 100 + 90)]) : (_loc2_.frontFish = this.mainGame["ship_" + (_loc2_.road_num * 100 + (_loc4_ - 1))]);
  80. }
  81. function timeControl()
  82. {
  83.    if(_root.game.isGameOver == false)
  84.    {
  85.       if(_root.game.isPause == false)
  86.       {
  87.          time_txt.text = second;
  88.          second++;
  89.       }
  90.    }
  91. }
  92. function testScore()
  93. {
  94.    var _loc3_ = undefined;
  95.    _loc3_ = levelList[level].scoreToUp;
  96.    if(score - oldScore != 0 && (score - oldScore) % _loc3_ == 0)
  97.    {
  98.       level >= 19 ? (level = 19) : level++;
  99.       levelShow++;
  100.       level_txt.text = levelShow;
  101.       oldScore = score;
  102.       trace("levelUp" + level + "___________score+" + score);
  103.       _root.game.gameOver.gotoAndPlay(1);
  104.       boxOut = false;
  105.       _root.game.soundManage.playSound("levelUp_s");
  106.       clearInterval(intervalID);
  107.       intervalID = setInterval(this,"bigFishOut",levelList[level].timeDelay);
  108.    }
  109.    else
  110.    {
  111.       _root.game.soundManage.playSound("get_s");
  112.    }
  113. }
  114. stop();
  115. this.init();
  116. var intervalID;
  117. var timeIntervalID;
  118. var road_num;
  119. var second;
  120. var y_arr = [140,195,250,310];
  121. var fishList = [0,0,0,0];
  122. var levelList = new Array();
  123. var boxOut;
  124. var eachScore = 50;
  125. var oldScore = 0;
  126. var levelShow;
  127. var lastRoad = random(4);
  128. var i = 0;
  129. while(i < 20)
  130. {
  131.    if(i < 8)
  132.    {
  133.       levelList[i] = {levelNum:i + 1,speed:5 + i,scoreToUp:(2 + i) * 50,timeDelay:1200 - i * 120};
  134.    }
  135.    else
  136.    {
  137.       levelList[i] = {levelNum:i + 1,speed:5 + i,scoreToUp:(5 + i) * 50,timeDelay:300};
  138.    }
  139.    i++;
  140. }
  141. gameInit();
  142. stop();
  143.