home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Puzzle / PuzzlePuzzle.swf / scripts / frame_448 / DoAction.as
Encoding:
Text File  |  2005-08-05  |  7.8 KB  |  363 lines

  1. function left()
  2. {
  3.    if(0 < manbx)
  4.    {
  5.       manb.gotoandplay("left");
  6.       manbx -= 1;
  7.       manb._x -= 35;
  8.    }
  9. }
  10. function right()
  11. {
  12.    if(manbx < 7)
  13.    {
  14.       manb.gotoandplay("right");
  15.       manbx += 1;
  16.       manb._x += 35;
  17.    }
  18. }
  19. function up()
  20. {
  21.    if(0 < manbnumber)
  22.    {
  23.       manb.gotoandplay("down");
  24.       bscore = scoreb;
  25.       tjs = 10;
  26.       while(tjs >= 0)
  27.       {
  28.          if(b[manbx][tjs] != 0)
  29.          {
  30.             ttb = tjs + 1;
  31.             atb = tjs + 1;
  32.             break;
  33.          }
  34.          tjs--;
  35.       }
  36.       if(b[manbx][0] == 0)
  37.       {
  38.          ttb = 0;
  39.          atb = 0;
  40.       }
  41.       i = 0;
  42.       while(i < manbnumber)
  43.       {
  44.          if(manbcolor == 1)
  45.          {
  46.             duplicateMovieClip("reds","gb" add (ttb * 8 + manbx),16384 + chengb);
  47.             setProperty("gb" add (ttb * 8 + manbx), _X, manbx * 35 + 362);
  48.             setProperty("gb" add (ttb * 8 + manbx), _Y, ttb * 35 + 55);
  49.             b[manbx][ttb] = 1;
  50.          }
  51.          else if(manbcolor == 2)
  52.          {
  53.             duplicateMovieClip("blues","gb" add (ttb * 8 + manbx),16384 + chengb);
  54.             setProperty("gb" add (ttb * 8 + manbx), _X, manbx * 35 + 362);
  55.             setProperty("gb" add (ttb * 8 + manbx), _Y, ttb * 35 + 55);
  56.             b[manbx][ttb] = 2;
  57.          }
  58.          else if(manbcolor == 3)
  59.          {
  60.             duplicateMovieClip("greens","gb" add (ttb * 8 + manbx),16384 + chengb);
  61.             setProperty("gb" add (ttb * 8 + manbx), _X, manbx * 35 + 362);
  62.             setProperty("gb" add (ttb * 8 + manbx), _Y, ttb * 35 + 55);
  63.             b[manbx][ttb] = 3;
  64.          }
  65.          else if(manbcolor == 4)
  66.          {
  67.             duplicateMovieClip("yellows","gb" add (ttb * 8 + manbx),16384 + chengb);
  68.             setProperty("gb" add (ttb * 8 + manbx), _X, manbx * 35 + 362);
  69.             setProperty("gb" add (ttb * 8 + manbx), _Y, ttb * 35 + 55);
  70.             b[manbx][ttb] = 4;
  71.          }
  72.          ttb += 1;
  73.          chengb += 1;
  74.          if(ttb >= 10)
  75.          {
  76.             break;
  77.          }
  78.          i++;
  79.       }
  80.       bloon2 = manbnumber == 1 && b[manbx][ttb - 2] == manbcolor && b[manbx][ttb - 3] == manbcolor;
  81.       if(manbnumber >= 3 || manbnumber == 2 && b[manbx][ttb - 3] == manbcolor || bloon2)
  82.       {
  83.          iib = 1;
  84.          while(iib < 10)
  85.          {
  86.             if(b[manbx][ttb - iib] != manbcolor)
  87.             {
  88.                break;
  89.             }
  90.             this["gb" add ((ttb - iib) * 8 + manbx)].gotoAndPlay("over");
  91.             scoreb += 10;
  92.             b[manbx][ttb - iib] = 0;
  93.             che = 1;
  94.             while(8 >= che)
  95.             {
  96.                if(b[manbx - che][ttb - iib] != manbcolor)
  97.                {
  98.                   break;
  99.                }
  100.                this["gb" add ((ttb - iib) * 8 + manbx - che)].gotoAndPlay("over");
  101.                scoreb += 10;
  102.                b[manbx - che][ttb - iib] = 0;
  103.                si = 1;
  104.                while(11 >= si && b[manbx - che][ttb - iib + si] != 0)
  105.                {
  106.                   this["gb" add ((ttb - iib + si) * 8 + manbx - che)].gotoAndPlay("down");
  107.                   b[manbx - che][ttb - iib + si] = 0;
  108.                   si++;
  109.                }
  110.                che++;
  111.             }
  112.             che = 1;
  113.             while(8 >= che)
  114.             {
  115.                if(b[manbx + che][ttb - iib] != manbcolor)
  116.                {
  117.                   break;
  118.                }
  119.                this["gb" add ((ttb - iib) * 8 + manbx + che)].gotoAndPlay("over");
  120.                scoreb += 10;
  121.                b[manbx + che][ttb - iib] = 0;
  122.                si = 1;
  123.                while(11 >= si && b[manbx + che][ttb - iib + si] != 0)
  124.                {
  125.                   this["gb" add ((ttb - iib + si) * 8 + manbx + che)].gotoAndPlay("down");
  126.                   b[manbx + che][ttb - iib + si] = 0;
  127.                   si++;
  128.                }
  129.                che++;
  130.             }
  131.             iib++;
  132.          }
  133.       }
  134.       bscore = scoreb - bscore;
  135.       if(100 * xb < scoreb && scoreb < xb * 100 + 100 && x[xb] != 1)
  136.       {
  137.          sss();
  138.          char1.gotoandplay("ded");
  139.          x[xb] = 1;
  140.          xb += 1;
  141.       }
  142.       else if(bscore >= 60)
  143.       {
  144.          sss();
  145.          char1.gotoandplay("cry");
  146.          p2k.gotoandplay(2);
  147.          char2.gotoandplay("happy");
  148.       }
  149.       manbnumber = 0;
  150.       manbcolor = 0;
  151.    }
  152. }
  153. function down()
  154. {
  155.    js = 10;
  156.    while(js >= 0)
  157.    {
  158.       if(b[manbx][js] == 1 || b[manbx][js] == 2 || b[manbx][js] == 3 || b[manbx][js] == 4)
  159.       {
  160.          kkb = js;
  161.          break;
  162.       }
  163.       js--;
  164.    }
  165.    ssb = kkb * 8 + manbx;
  166.    if((manbcolor == 0 || manbcolor == b[manbx][kkb]) && (b[manbx][kkb] == 1 || b[manbx][kkb] == 2 || b[manbx][kkb] == 3 || b[manbx][kkb] == 4))
  167.    {
  168.       manb.gotoandplay("down");
  169.       this["gb" add ssb].gotoandplay("down");
  170.       manbcolor = b[manbx][kkb];
  171.       manbnumber += 1;
  172.       b[manbx][kkb] = 0;
  173.       aab = 1;
  174.       while(aab < 12 && kkb - aab >= 0)
  175.       {
  176.          if(b[manbx][kkb - aab] != manbcolor)
  177.          {
  178.             break;
  179.          }
  180.          manbnumber += 1;
  181.          ssb2 = (kkb - aab) * 8 + manbx;
  182.          this["gb" add ssb2].gotoandplay("down");
  183.          b[manbx][kkb - aab] = 0;
  184.          aab++;
  185.       }
  186.    }
  187. }
  188. function pd()
  189. {
  190.    icpu = 0;
  191.    while(7 >= icpu)
  192.    {
  193.       cput = 10;
  194.       while(cput >= 0)
  195.       {
  196.          if(b[icpu][cput] != 0)
  197.          {
  198.             break;
  199.          }
  200.          cput--;
  201.       }
  202.       if(b[icpu][cput] == 1)
  203.       {
  204.          red++;
  205.       }
  206.       else if(b[icpu][cput] == 2)
  207.       {
  208.          blue++;
  209.       }
  210.       else if(b[icpu][cput] == 3)
  211.       {
  212.          green++;
  213.       }
  214.       else if(b[icpu][cput] == 4)
  215.       {
  216.          yellow++;
  217.       }
  218.       icpu++;
  219.    }
  220.    if(red >= blue)
  221.    {
  222.       if(red >= green)
  223.       {
  224.          if(red >= yellow)
  225.          {
  226.             max = 1;
  227.          }
  228.          else
  229.          {
  230.             max = 4;
  231.          }
  232.       }
  233.       else if(green >= yellow)
  234.       {
  235.          max = 3;
  236.       }
  237.       else
  238.       {
  239.          max = 4;
  240.       }
  241.    }
  242.    else if(blue >= green)
  243.    {
  244.       if(blue >= yellow)
  245.       {
  246.          max = 2;
  247.       }
  248.       else
  249.       {
  250.          max = 4;
  251.       }
  252.    }
  253.    else if(green >= yellow)
  254.    {
  255.       max = 3;
  256.    }
  257.    else
  258.    {
  259.       max = 4;
  260.    }
  261.    mcpu = 1;
  262. }
  263. function mpdd()
  264. {
  265.    if(4 >= manbx)
  266.    {
  267.       i = 0;
  268.       while(i < 8)
  269.       {
  270.          cput = 10;
  271.          while(cput >= 0)
  272.          {
  273.             if(b[i][cput] != 0)
  274.             {
  275.                break;
  276.             }
  277.             cput--;
  278.          }
  279.          if(b[i][cput] == max)
  280.          {
  281.             break;
  282.          }
  283.          i++;
  284.       }
  285.       if(i >= 7 && b[i][cput] != max)
  286.       {
  287.          i = manbx;
  288.          upmove = 1;
  289.       }
  290.    }
  291.    else
  292.    {
  293.       i = 7;
  294.       while(i >= 0)
  295.       {
  296.          cput = 10;
  297.          while(cput >= 0)
  298.          {
  299.             if(b[i][cput] != 0)
  300.             {
  301.                break;
  302.             }
  303.             cput--;
  304.          }
  305.          if(b[i][cput] == max)
  306.          {
  307.             break;
  308.          }
  309.          i--;
  310.       }
  311.       if(0 >= i && b[i][cput] != max)
  312.       {
  313.          i = manbx;
  314.          upmove = 1;
  315.       }
  316.    }
  317.    move = i - manbx;
  318.    mcpu = 2;
  319. }
  320. function mm()
  321. {
  322.    if(move == 0)
  323.    {
  324.       if(upmove == 1)
  325.       {
  326.          up();
  327.          pd();
  328.          mcpu = 0;
  329.          upmove = 0;
  330.       }
  331.       else
  332.       {
  333.          down();
  334.          mcpu = 1;
  335.       }
  336.    }
  337.    else if(0 < move)
  338.    {
  339.       move--;
  340.       right();
  341.       if(0 < manbnumber)
  342.       {
  343.          down();
  344.       }
  345.    }
  346.    else if(move < 0)
  347.    {
  348.       move++;
  349.       left();
  350.       if(0 < manbnumber)
  351.       {
  352.          down();
  353.       }
  354.    }
  355. }
  356. rrr();
  357. ggg();
  358. rrrb();
  359. gggb();
  360. c = new Array();
  361. x = new Array();
  362. z = new Array();
  363.