home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Diversos / fusion_frenzy.swf / scripts / frame_4 / DoAction.as
Encoding:
Text File  |  2007-03-20  |  6.3 KB  |  192 lines

  1. buildMap = function(xLoc, yLoc)
  2. {
  3.    this.container_mc.attachMovie(_global.levelMap,_global.levelMap,_global.levelNumber);
  4.    this.container_mc[levelMap]._x = xLoc - 2;
  5.    this.container_mc[levelMap]._y = yLoc - 2;
  6.    this.container_mc.createEmptyMovieClip("boardMC",50);
  7.    this.container_mc.boardMC._x = xLoc;
  8.    this.container_mc.boardMC._y = yLoc;
  9.    i = 0;
  10.    while(i < mapH)
  11.    {
  12.       j = 0;
  13.       while(j < MapW)
  14.       {
  15.          this.container_mc.boardMC.attachMovie("tile","t_" + i + "_" + j,++d);
  16.          this.container_mc.boardMC["t_" + i + "_" + j]._x = j * tileW;
  17.          this.container_mc.boardMC["t_" + i + "_" + j]._y = i * tileH;
  18.          if(myMap[i][j][0] == "d0")
  19.          {
  20.             _global.dirtCount += 1;
  21.          }
  22.          if(myMap[i][j][0] == "p0")
  23.          {
  24.             this.container_mc.boardMC["t_" + i + "_" + j].x = j;
  25.             this.container_mc.boardMC["t_" + i + "_" + j].y = i;
  26.          }
  27.          if(myMap[i][j][1] == 9)
  28.          {
  29.             this.container_mc.boardMC["t_" + i + "_" + j].xTile = j;
  30.             this.container_mc.boardMC["t_" + i + "_" + j].yTile = i;
  31.             this.container_mc.boardMC["t_" + i + "_" + j].onEnterFrame = exitTile;
  32.          }
  33.          this.container_mc.boardMC["t_" + i + "_" + j].gotoAndStop(myMap[i][j][0]);
  34.          j++;
  35.       }
  36.       i++;
  37.    }
  38. };
  39. buildCharacters = function(xLoc, yLoc)
  40. {
  41.    this.container_mc.createEmptyMovieClip("playersMC",51);
  42.    this.container_mc.playersMC._x = xLoc;
  43.    this.container_mc.playersMC._y = yLoc;
  44.    i = 0;
  45.    while(i < myCharacters.length)
  46.    {
  47.       if(myCharacters[i][0] == "H")
  48.       {
  49.          myMapHeroStartX = myCharacters[i][1];
  50.          myMapHeroStartY = myCharacters[i][2];
  51.          placeHero();
  52.       }
  53.       else if(myCharacters[i][0] == "V")
  54.       {
  55.          placeVillan(myCharacters[i][1],myCharacters[i][2],i);
  56.       }
  57.       i++;
  58.    }
  59. };
  60. placeHero = function()
  61. {
  62.    this.container_mc.playersMC.attachMovie("hero","hero",100);
  63.    this.container_mc.playersMC.hero._x = myMapHeroStartX * tileW + tileW / 2;
  64.    this.container_mc.playersMC.hero._y = myMapHeroStartY * tileH + tileH / 2;
  65.    _global.heroDuration = 18;
  66.    _global.heroState = 3;
  67.    _global.heroStateBaseTime = _global.masterClock;
  68. };
  69. placeVillan = function(startX, startY, number)
  70. {
  71.    this.container_mc.playersMC.attachMovie("villan","villan" + number,number);
  72.    this.container_mc.playersMC["villan" + number]._x = startX * tileW + tileW / 2;
  73.    this.container_mc.playersMC["villan" + number]._y = startY * tileH + tileH / 2;
  74.    _global.dirtCount += 1;
  75.    _global.villanCount += 1;
  76. };
  77. powerUp = function(x, y)
  78. {
  79.    this.attachMovie("hundredpoints","pointspopup" + x,x = x + 1);
  80.    this["pointspopup" + x]._x = x + this.container_mc._x;
  81.    this["pointspopup" + x]._y = y + _global.containerStartY;
  82.    _global.gameScore += 100;
  83.    _global.heroDuration = _global.levelHeroDuration;
  84.    _global.heroState = 1;
  85.    _global.heroStateBaseTime = _global.masterClock;
  86. };
  87. killHero = function(x, y)
  88. {
  89.    this.playSfxHero();
  90.    this.attachMovie("minushundred","pointspopup" + x,x = x + 1);
  91.    this["pointspopup" + x]._x = x + this.container_mc._x;
  92.    this["pointspopup" + x]._y = y + _global.containerStartY;
  93.    _global.gameScore -= 100;
  94.    _global.heroTile = 0;
  95.    if(_global.heroLives > 0)
  96.    {
  97.       _global.heroLives -= 1;
  98.       this.placeHero();
  99.    }
  100.    else
  101.    {
  102.       _global.levelDone = true;
  103.       _global.heroLives -= 1;
  104.       this.levelScore();
  105.       this.container_mc.playersMC.hero.removeMovieClip();
  106.       this.tint.fadeMe = "up";
  107.    }
  108. };
  109. killVillan = function(myName, x, y)
  110. {
  111.    this.playSfxVillan();
  112.    this.attachMovie("fiftypoints","pointspopup" + x,x = x + 1);
  113.    this["pointspopup" + x]._x = x + this.container_mc._x;
  114.    this["pointspopup" + x]._y = y + _global.containerStartY;
  115.    this.container_mc.playersMC[myName].baseTime = _global.masterClock;
  116.    this.container_mc.playersMC[myName].dead = true;
  117.    this.container_mc.playersMC[myName].xtile = heroTile[0];
  118.    this.container_mc.playersMC[myName].ytile = heroTile[1];
  119.    this.container_mc.playersMC[myName]._x = -5000;
  120.    this.container_mc.playersMC[myName]._y = -5000;
  121.    _global.dirtCount -= 1;
  122.    _global.villanCount -= 1;
  123.    _global.levelDust += 1;
  124.    _global.gameScore += 50;
  125. };
  126. _global.pupTile = function()
  127. {
  128.    if(this._global.masterClock - this.baseTime > this._global.cycloneRespon)
  129.    {
  130.       if(this._global.villanCount != 0 && this._global.dirtCount != 0)
  131.       {
  132.          if(this._global.myMap[this.y][this.x][0] != "c0")
  133.          {
  134.             _global.dirtCount -= 1;
  135.          }
  136.          this.gotoAndStop("p0");
  137.          this._global.myMap[this.y][this.x][0] = "p0";
  138.          delete this.onEnterFrame;
  139.       }
  140.    }
  141.    if(_global.levelStarted == true && _global.levelDone == true && _global.fusionExit == true)
  142.    {
  143.       this._global.myMap[this.y][this.x][0] = "p0";
  144.       delete this.onEnterFrame;
  145.    }
  146. };
  147. _global.exitTile = function()
  148. {
  149.    if(_global.dirtCount == 0 && this._global.levelDone != true)
  150.    {
  151.       if(this._global.heroTile[0] == this.xTile && this._global.heroTile[1] == this.yTile)
  152.       {
  153.          this._global.levelDone = true;
  154.          this._parent._parent._parent.stopSfxPup();
  155.          this._parent._parent._parent.playSfxExit();
  156.          this._parent._parent._parent.container_mc.playersMC.hero._x = this._x + _global.tileW / 2;
  157.       }
  158.    }
  159. };
  160. levelBuild = function()
  161. {
  162.    this.setDynamics();
  163.    this.buildMap(xLoc,yLoc);
  164.    this.buildCharacters(xLoc,yLoc);
  165.    _global.levelBaseTime = _global.masterClock;
  166.    _global.levelStarted = true;
  167. };
  168. levelScore = function()
  169. {
  170.    this.scoring.displayDirt = 10 * _global.levelDirt;
  171.    this.scoring.displayDust = 50 * _global.levelDust;
  172.    this.scoring.displayPup = 100 * _global.levelPup;
  173.    if(_global.heroLives >= 0)
  174.    {
  175.       if(_global.levelParTime >= _global.levelSecondsTime)
  176.       {
  177.          this.scoring.displayTime = 50 * (_global.levelParTime - _global.levelSecondsTime);
  178.       }
  179.       else
  180.       {
  181.          this.scoring.displayTime = -5 * (_global.levelSecondsTime - _global.levelParTime);
  182.       }
  183.    }
  184.    else
  185.    {
  186.       this.scoring.displayTime = 0;
  187.    }
  188.    _global.levelTally = this.scoring.displayDirt + this.scoring.displayDust + this.scoring.displayPup + this.scoring.displayTime;
  189.    this.scoring.displayTotal = _global.levelTally;
  190. };
  191. this.levelBuild();
  192.