home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / vcleaning.swf / scripts / frame_4 / DoAction.as
Encoding:
Text File  |  2005-08-23  |  16.4 KB  |  672 lines

  1. function Depth()
  2. {
  3.    this.freeDepths = [1];
  4. }
  5. function Fee()
  6. {
  7. }
  8. function Bgr()
  9. {
  10. }
  11. function Enemy_s()
  12. {
  13. }
  14. function Enemy_e()
  15. {
  16. }
  17. function Enemy_x1()
  18. {
  19. }
  20. function Enemy_x2()
  21. {
  22. }
  23. function Pointer()
  24. {
  25. }
  26. EventEngine = function()
  27. {
  28.    this._temp = [];
  29.    this._listeners = [];
  30. };
  31. EventEngine.init = function(mc)
  32. {
  33.    if(Object.broadcaster == undefined)
  34.    {
  35.       Object.broadCaster = mc;
  36.       Object.broadCaster.__proto__ = new EventEngine();
  37.    }
  38. };
  39. EventEngine.prototype._clearListeners = function()
  40. {
  41.    this._sendevent("kleenup");
  42.    this._listeners = [];
  43. };
  44. EventEngine.prototype._addlistener = function(obj)
  45. {
  46.    var lNum = this._listeners.length;
  47.    if(lNum)
  48.    {
  49.       while(lNum)
  50.       {
  51.          if(this._listeners[--lNum] == obj)
  52.          {
  53.             return 0;
  54.          }
  55.       }
  56.    }
  57.    this._listeners.push(obj);
  58. };
  59. EventEngine.prototype._removeListener = function(obj)
  60. {
  61.    var lNum = this._listeners.length;
  62.    if(lNum)
  63.    {
  64.       while(lNum)
  65.       {
  66.          if(this._listeners[--lNum] == obj)
  67.          {
  68.             this._listeners.splice(lNum,1);
  69.          }
  70.       }
  71.    }
  72. };
  73. EventEngine.prototype._sendEvent = function(event, arg)
  74. {
  75.    var lNum = this._listeners.length;
  76.    if(lNum)
  77.    {
  78.       while(lNum)
  79.       {
  80.          this._listeners[--lNum][event](arg);
  81.       }
  82.    }
  83. };
  84. Depth.prototype.getDepth = function()
  85. {
  86.    var long = this.freeDepths.length;
  87.    var i = 1;
  88.    while(long >= i)
  89.    {
  90.       if(this.freeDepths[i] == 0)
  91.       {
  92.          this.freeDepths[i] = 1;
  93.          return i;
  94.       }
  95.       i++;
  96.    }
  97.    this.freeDepths.push(1);
  98.    return long;
  99. };
  100. Depth.prototype.setDepth = function(d)
  101. {
  102.    this.freeDepths[d] = 0;
  103. };
  104. MovieClip.prototype.mcIs = function(┬ºclass┬º)
  105. {
  106.    this.__proto__ = eval("class").prototype;
  107.    this.base = eval("class");
  108. };
  109. Object.prototype["extends"] = function(obj)
  110. {
  111.    obj.prototype.__proto__ = this;
  112. };
  113. Fee.prototype.init = function()
  114. {
  115.    this.oldPos = {x:this._x,y:this._y};
  116.    this.friction = 20;
  117.    this.heading = -1;
  118.    this.reverse = 1;
  119.    this.offsetx = 0;
  120.    this.offsety = 0;
  121.    this.gameIsOver = 0;
  122.    this.hit = 0;
  123.    this.goo = 0;
  124.    this.swapDepths(1000);
  125.    Object.broadcaster._addlistener(this);
  126. };
  127. Fee.prototype.checkHeading = function()
  128. {
  129.    var dir = this.reverse * (-1 + int(this._y < _root._ymouse) * 2);
  130.    if(dir != this.heading)
  131.    {
  132.       Object.heading.setHeading(this.heading = dir);
  133.    }
  134. };
  135. Fee.prototype.isHit = function()
  136. {
  137.    this.gotoAndPlay("hit");
  138.    this.hit = 1;
  139.    this.swapDepths(3000);
  140.    Object.broadcaster._sendEvent("stop_game");
  141. };
  142. Fee.prototype.kleenup = function()
  143. {
  144. };
  145. Fee.prototype.setOver = function()
  146. {
  147.    this.gameIsOver = 1;
  148. };
  149. Fee.prototype.getNuPos = function()
  150. {
  151.    var nux = (_root._xmouse - this._x) * this.reverse;
  152.    var nuy = (_root._ymouse - this._y) * this.reverse;
  153.    var rad = Math.atan2(nuy,nux);
  154.    this.destAng = Math.round(90 + rad / Math.Pi * 180);
  155.    if(180 < this.destAng)
  156.    {
  157.       this.destAng -= 360;
  158.    }
  159.    var r1 = this._rotation - this.destAng;
  160.    var r2 = 360 - Math.abs(r1);
  161.    if(Math.abs(r1) >= Math.abs(r2))
  162.    {
  163.       if(0 >= this._rotation)
  164.       {
  165.          r = r2;
  166.       }
  167.       else
  168.       {
  169.          r = - r2;
  170.       }
  171.    }
  172.    else
  173.    {
  174.       r = r1;
  175.    }
  176.    this.step = r / 2;
  177.    this._rotation -= this.step / Math.ceil((this.goo + 1) / 10);
  178.    var nux = this.oldPos.x - _root._xmouse;
  179.    var nuy = this.oldPos.y - _root._ymouse;
  180.    var nuPos = {x:nux,y:nuy};
  181.    var nux = this._x - nuPos.x / ((this.friction + this.goo) / 2) * this.reverse;
  182.    if(100 < nux)
  183.    {
  184.       if(nux < 600)
  185.       {
  186.          this.oldPos.x = this._x = nux;
  187.       }
  188.       else
  189.       {
  190.          this.oldPos.x = this._x = 600;
  191.       }
  192.    }
  193.    else
  194.    {
  195.       this.oldPos.x = this._x = 100;
  196.    }
  197.    if(Math.abs(nuPos.y) >= 2.5)
  198.    {
  199.       var nuy = this._y - nuPos.y / (this.friction + this.goo) * this.reverse;
  200.       if(150 < nuy)
  201.       {
  202.          if(nuy < 450)
  203.          {
  204.             this.oldPos.y = this._y = nuy;
  205.          }
  206.          else
  207.          {
  208.             this.oldPos.y = this._y = 450;
  209.          }
  210.       }
  211.       else
  212.       {
  213.          this.oldPos.y = this._y = 150;
  214.       }
  215.    }
  216.    this.checkHeading();
  217. };
  218. Fee.prototype.enterframe = function()
  219. {
  220.    if(!this.hit)
  221.    {
  222.       this.getNuPos();
  223.    }
  224. };
  225. Fee.prototype.stop_game = function()
  226. {
  227.    this.enterframe = "";
  228. };
  229. Fee.prototype.kleen = function()
  230. {
  231.    Object.broadcaster._removeListener(this);
  232.    this.removeMovieClip();
  233. };
  234. Fee.prototype.setReverse = function(r)
  235. {
  236.    this.offsetx = this.offsety = 0;
  237.    this.reverse = r;
  238. };
  239. Fee.prototype.setGoo = function(g)
  240. {
  241.    this.goo += g;
  242. };
  243. Fee.prototype.setState = function(f)
  244. {
  245.    this.korper.gotoAndStop(this.korper._currentframe + f);
  246. };
  247. Bgr.prototype.init = function(max, p, pl)
  248. {
  249.    this.point_target = p;
  250.    this.max = max;
  251.    this.player = pl;
  252.    this.reverse = 1;
  253.    this.goo = 0;
  254.    this.friction = 40;
  255.    Object.broadcaster._addlistener(this);
  256.    this.position = 0;
  257.    this.oldForce = 0;
  258.    this.y = this._y;
  259.    o = _root.stuff;
  260.    this.minClip = 0;
  261.    this.maxClip = 7;
  262.    var x = this.minclip;
  263.    i = this.minclip;
  264.    while(i < this.maxclip + 2)
  265.    {
  266.       if(o[i])
  267.       {
  268.          var c = o[i][3];
  269.          _root[c].duplicateMovieClip("stuff" + i,i);
  270.          var clip = _root["stuff" + i];
  271.          clip._x = o[i][0];
  272.          clip._y = o[i][1] + i * 100;
  273.          if(c == "bank")
  274.          {
  275.             clip.swapDepths(1001 + nu);
  276.          }
  277.          clip._rotation = o[i][2];
  278.          clip.mcIs(_root["Enemy_" + o[i][4]]);
  279.          var hitArea = o[i][4] + "_hit";
  280.          if(this.player[hitArea])
  281.          {
  282.             clip.init(i,this.point_target,this.player[hitArea]);
  283.          }
  284.          else
  285.          {
  286.             clip.init(i,this.point_target,this.player.s_hit);
  287.          }
  288.       }
  289.       i++;
  290.    }
  291. };
  292. Bgr.prototype.enterframe = function()
  293. {
  294.    var nuForce = this.reverse * ((300 - _root._ymouse) / (this.friction + this.goo));
  295.    var head = -1 * Object.heading.getHeading();
  296.    var nuf = this.force - nuforce / 30;
  297.    if(0.5 < Math.abs(nuf))
  298.    {
  299.       this.force = nuf;
  300.    }
  301.    else
  302.    {
  303.       this.force = 0;
  304.    }
  305.    if(0 >= nuForce == head < 0)
  306.    {
  307.       this.y += this.force = nuForce;
  308.    }
  309.    else
  310.    {
  311.       this.y += this.force;
  312.    }
  313.    if(0 < this.y)
  314.    {
  315.       this.y -= this.max;
  316.    }
  317.    else if(this.y < - this.max)
  318.    {
  319.       this.y += this.max;
  320.    }
  321.    this._y = this.y;
  322.    var skip = this.max * 100;
  323.    var nupos = this.position - this.force;
  324.    if(0 >= nupos)
  325.    {
  326.       nupos += skip;
  327.    }
  328.    else if(skip < nupos)
  329.    {
  330.       nupos -= skip;
  331.    }
  332.    if(this.force < 0)
  333.    {
  334.       var posOff = nupos / 100;
  335.       var posOff2 = Math.floor(posOff);
  336.       var nuScreen = (posOff2 + 7) % this.max;
  337.       var del = this.minclip - 1;
  338.       var ad = (this.maxClip + 2) % this.max;
  339.       var old = (this.minClip + 1) % this.max;
  340.       var nu = (this.maxClip + 1) % this.max;
  341.       var nudir = 1;
  342.    }
  343.    else
  344.    {
  345.       var posOff = nupos / 100;
  346.       var posOff2 = Math.floor(posOff);
  347.       var del = this.maxclip + 1;
  348.       var ad = Math.abs((this.max + (this.minClip - 2)) % this.max);
  349.       var nuScreen = Math.abs((this.max + posOff2) % this.max);
  350.       var nu = Math.abs((this.max + (this.minClip - 1)) % this.max);
  351.       var old = Math.abs((this.max + (this.maxClip - 1)) % this.max);
  352.       var nudir = -1;
  353.    }
  354.    if(nuScreen == nu)
  355.    {
  356.       var o = _root.stuff;
  357.       if(0 < o[ad].length)
  358.       {
  359.          var c = o[ad][3];
  360.          _root[c].duplicateMovieClip("stuff" + ad,ad);
  361.          var clip = _root["stuff" + ad];
  362.          clip._x = o[ad][0];
  363.          var nuy = o[ad][1] + ad * 100 - nupos;
  364.          if(nuy < -1000)
  365.          {
  366.             nuy += 8600;
  367.          }
  368.          clip._y = nuy;
  369.          if(c == "bank")
  370.          {
  371.             clip.swapDepths(1001 + ad);
  372.          }
  373.          else if(c == "pfutz")
  374.          {
  375.             clip.gotoAndStop(o[ad][5]);
  376.          }
  377.          clip._rotation = o[ad][2];
  378.          clip.mcIs(_root["Enemy_" + o[ad][4]]);
  379.          var hitArea = o[ad][4] + "_hit";
  380.          if(this.player[hitArea])
  381.          {
  382.             clip.init(ad,this.point_target,this.player[hitArea]);
  383.          }
  384.          else
  385.          {
  386.             clip.init(ad,this.point_target,this.player.s_hit);
  387.          }
  388.       }
  389.       var num = (this.max + old - nudir) % this.max;
  390.       if(0 < o[del].length)
  391.       {
  392.          var clip = _root["stuff" + del];
  393.          clip.kleen();
  394.       }
  395.       this.maxClip = 0 >= nudir ? old : nu;
  396.       this.minClip = 0 >= nudir ? nu : old;
  397.    }
  398.    this.position = nuPos;
  399.    Object.broadcaster._sendEvent("move",this.force);
  400. };
  401. Bgr.prototype.stop_game = function()
  402. {
  403.    this.enterframe = "";
  404. };
  405. Bgr.prototype.setReverse = function(r)
  406. {
  407.    this.reverse = r;
  408. };
  409. Bgr.prototype.setGoo = function(g)
  410. {
  411.    this.goo += g;
  412. };
  413. Array.prototype.addObjects = function(place, type, str)
  414. {
  415.    for(i in "place")
  416.    {
  417.       var check = place[i];
  418.       if(typeof check == type)
  419.       {
  420.          var isObject = check._name.indexOf(str) + 1;
  421.          if(isObject)
  422.          {
  423.             this.push(check);
  424.          }
  425.       }
  426.    }
  427. };
  428. Enemy_s.prototype.init = function(num, p, pl)
  429. {
  430.    this.target = p;
  431.    this.player = pl;
  432.    this.y = this._y;
  433.    this.hit = 0;
  434.    this.num = num;
  435.    this.max = 8;
  436.    Object.broadcaster._addListener(this);
  437. };
  438. Enemy_s.prototype.move = function(f)
  439. {
  440.    if(!this.hit)
  441.    {
  442.       this.y += f;
  443.       this._y = this.y;
  444.       if(this.hitTest(this.player))
  445.       {
  446.          this.gotoAndStop(2);
  447.          this.hit = 1;
  448.          _root.stuff[this.num] = [];
  449.          this.target.setPoints();
  450.       }
  451.    }
  452.    else if(this.wolk._currentframe < this.max)
  453.    {
  454.       this.wolk.gotoAndStop(++this.wolk._currentframe);
  455.    }
  456.    else
  457.    {
  458.       this.kleen();
  459.    }
  460. };
  461. Enemy_s.prototype.stop_game = function()
  462. {
  463.    this.enterframe = "";
  464. };
  465. Enemy_s.prototype.kleen = function()
  466. {
  467.    Object.broadcaster._removeListener(this);
  468.    this.removeMovieClip();
  469. };
  470. Enemy_e.prototype.init = function(num, p, pl)
  471. {
  472.    this.target = p;
  473.    this.y = this._y;
  474.    this.hit = 0;
  475.    this.player_hit = pl;
  476.    this.player = pl._parent;
  477.    this.num = num;
  478.    this.max = 8;
  479.    Object.broadcaster._addListener(this);
  480. };
  481. Enemy_e.prototype.kleen = function()
  482. {
  483.    Object.broadcaster._removeListener(this);
  484.    this.removeMovieClip();
  485. };
  486. Enemy_e.prototype.stop_game = function()
  487. {
  488.    this.enterframe = "";
  489. };
  490. Enemy_e.prototype.move = function(f)
  491. {
  492.    if(!this.hit)
  493.    {
  494.       if(this.area.hitTest(this.player_hit))
  495.       {
  496.          this.hit = 1;
  497.       }
  498.    }
  499.    else
  500.    {
  501.       this.player.isHit();
  502.       _root.stuff[this.num] = [];
  503.    }
  504.    this.y += f;
  505.    this._y = this.y;
  506. };
  507. Enemy_x1.prototype.init = function(num, pt, p)
  508. {
  509.    this.target = p;
  510.    this.pointer = pt;
  511.    this.y = this._y;
  512.    this.hit = 0;
  513.    this.cf = this._currentframe;
  514.    this.goo = 0;
  515.    this.num = num;
  516.    this.max = 8;
  517.    Object.broadcaster._addListener(this);
  518. };
  519. Enemy_x1.prototype.stop_game = function()
  520. {
  521.    this.enterframe = "";
  522. };
  523. Enemy_x1.prototype.move = function(f)
  524. {
  525.    if(!this.hit)
  526.    {
  527.       this.y += f;
  528.       this._y = this.y;
  529.       if(this.hitTest(this.target))
  530.       {
  531.          this.goo += this.cf * 10;
  532.          Object.broadcaster._sendevent("setGoo",this.cf * 10);
  533.          this.cf = this.cf + 1;
  534.          this.gotoAndStop(cf);
  535.          _root.stuff[this.num][5] = cf;
  536.       }
  537.       else
  538.       {
  539.          if(4 < this.cf)
  540.          {
  541.             this.player.setState(1);
  542.             this.hit = 1;
  543.             _root.stuff[this.num] = [];
  544.             this._visible = 0;
  545.             this.count = this.max;
  546.             this.pointer.setPoints();
  547.          }
  548.          if(this.goo)
  549.          {
  550.             this.goo--;
  551.             Object.broadcaster._sendevent("setGoo",-1);
  552.          }
  553.       }
  554.    }
  555.    else if(this.goo)
  556.    {
  557.       this.goo--;
  558.       Object.broadcaster._sendevent("setGoo",-1);
  559.    }
  560.    else if(this.hit)
  561.    {
  562.       this.hit = 0;
  563.       Object.broadcaster._sendevent("setGoo",0);
  564.       this.kleen();
  565.    }
  566. };
  567. Enemy_x1.prototype.kleen = function()
  568. {
  569.    Object.broadcaster._removeListener(this);
  570.    this.removeMovieClip();
  571. };
  572. Enemy_x2.prototype.init = function(num, pt, p)
  573. {
  574.    this.target = p;
  575.    this.pointer = pt;
  576.    this.player = p._parent;
  577.    this.y = this._y;
  578.    this.hit = 0;
  579.    this.num = num;
  580.    this.max = 60;
  581.    this.count = 0;
  582.    Object.broadcaster._addListener(this);
  583. };
  584. Enemy_x2.prototype.stop_game = function()
  585. {
  586.    this.enterframe = "";
  587. };
  588. Enemy_x2.prototype.move = function(f)
  589. {
  590.    if(!this.hit)
  591.    {
  592.       this.y += f;
  593.       this._y = this.y;
  594.       if(this.hitTest(this.target))
  595.       {
  596.          this.player.setState(1);
  597.          this.hit = 1;
  598.          _root.stuff[this.num] = [];
  599.          this._visible = 0;
  600.          this.count = this.max;
  601.          this.pointer.setPoints();
  602.          Object.broadcaster._sendevent("setReverse",-1);
  603.       }
  604.    }
  605.    else if(!this.count)
  606.    {
  607.       this.player.setState(-1);
  608.       Object.broadcaster._sendevent("setReverse",1);
  609.       this.kleen();
  610.    }
  611.    else
  612.    {
  613.       this.count--;
  614.    }
  615. };
  616. Enemy_x2.prototype.kleen = function()
  617. {
  618.    Object.broadcaster._removeListener(this);
  619.    this.removeMovieClip();
  620. };
  621. Pointer.prototype.init = function(readout, p)
  622. {
  623.    this.player = p;
  624.    var r = readout;
  625.    var r_n = r.length;
  626.    this.max = 0;
  627.    i = 0;
  628.    while(i < r_n)
  629.    {
  630.       if(1 < r[i].length && r[i][4] != "e")
  631.       {
  632.          this.max = this.max + 1;
  633.       }
  634.       i++;
  635.    }
  636.    this.step = 264 / this.max;
  637.    this._height = 0;
  638. };
  639. Pointer.prototype.setPoints = function()
  640. {
  641.    this._height += this.step;
  642.    this.max--;
  643.    if(!this.max)
  644.    {
  645.       this.player.setOver();
  646.       _root.gotoAndStop(_root._currentframe + 1);
  647.       _root.blende.play();
  648.    }
  649. };
  650. stuff_x = [[503,50,90,"kof1","e"],[166,74,0,"pfutz","x1",1],[344,37,0,"zeito","s"],[618,57,0,"cig2","s"],[482,22,0,"appel","s"],[102,37,0,"banan","s"],[241,37,90,"dose1","s"],[348,45,0,"batteri","x2"],[211,43,90,"kof2","e"],[337,54,0,"dose1","s"],[103,10,90,"kof1","e"],[202,32,135,"papier2","s"],[427,14,180,"bank","e"],[303,50,0,"trash","e"],[452,22,0,"papier1","s"],[303,1,0,"batteri","x2"],[366,74,180,"pfutz","x1",1],[137,54,90,"pfutz","x1",1],[120,35,0,"zeito","s"],[540,7,0,"trash","e"],[279,38,0,"dose2","s"],[149,50,0,"papier2","s"],[556,7,90,"bank","e"],[456,20,0,"pfutz","x1",1],[103,10,0,"kof2","e"],[337,54,-135,"cig2","s"],[37,32,0,"dose2","s"],[256,86,-135,"cig3","s"],[499,70,0,"trash","e"],[535,99,0,"batteri","x2"],[257,74,0,"banan","s"],[274,79,0,"kof2","e"],[89,32,0,"kof1","e"],[503,70,0,"kof2","e"],[324,73,0,"papier2","s"],[82,34,0,"cig2","s"],[520,62,0,"batteri","x2"],[232,68,0,"trash","e"],[382,20,0,"appel","s"],[537,54,0,"dose2","s"],[160,70,0,"papier2","s"],[459,11,90,"kof1","e"],[220,61,0,"pfutz","x1",1],[551,28,0,"dose2","s"],[128,36,0,"cig3","s"],[341,65,0,"bank","e"],[93,20,0,"trash","e"],[461,28,0,"pfutz","x1",1],[504,65,0,"kof2","e"],[275,20,0,"papier2","s"],[134,6,0,"batteri","x2"],[133,57,-90,"kof2","e"],[424,37,0,"appel","s"],[433,1,0,"cig1","s"],[299,85,0,"cig2","s"],[568,60,0,"cig3","s"],[524,46,0,"pfutz","x1",1],[159,7,0,"zeito","s"],[354,17,0,"dose1","s"],[73,35,0,"banan","s"],[222,67,180,"bank","e"],[499,18,0,"batteri","x2"],[567,64,0,"papier2","s"],[276,36,0,"appel","s"],[437,51,0,"dose1","s"],[73,16,0,"zeito","s"],[510,52,90,"kof1","e"],[190,85,0,"batteri","x2"],[249,33,0,"cig1","s"],[188,71,0,"dose2","s"],[303,10,180,"kof2","e"],[441,85,0,"pfutz","x1",1],[124,40,0,"trash","e"],[332,13,0,"cig2","s"],[549,20,0,"cig1","s"],[403,10,0,"bank","e"],[225,91,0,"banan","s"],[86,33,0,"batteri","x2"],[203,23,0,"kof2","e"],[570,48,0,"zeito","s"],[324,7,0,"cig3","s"],[124,37,0,"appel","s"],[492,75,0,"cig2","s"],[215,73,0,"bank","e"],[527,33,0,"papier2","s"],[]];
  651. EVENTengine.init(bc);
  652. MovieClip.prototype["extends"](Fee);
  653. MovieClip.prototype["extends"](Bgr);
  654. MovieClip.prototype["extends"](Enemy_s);
  655. MovieClip.prototype["extends"](Enemy_e);
  656. MovieClip.prototype["extends"](Enemy_x1);
  657. MovieClip.prototype["extends"](Enemy_x2);
  658. MovieClip.prototype["extends"](Pointer);
  659. Object.heading = {setHeading:function(h)
  660. {
  661.    this.heading = h;
  662. },heading:-1,getHeading:function()
  663. {
  664.    return this.heading;
  665. },setForce:function(f)
  666. {
  667.    this.force = f;
  668. },force:0,getForce:function()
  669. {
  670.    return this.force;
  671. }};
  672.