home *** CD-ROM | disk | FTP | other *** search
/ Champak 108 / jogo-disk-108.iso / Games / Titans / robin.swf / scripts / frame_4 / DoAction.as
Text File  |  2010-05-15  |  7KB  |  294 lines

  1. movieclip.prototype.findlane = function()
  2. {
  3.    if(!r.laneposran.length)
  4.    {
  5.       r.laneposran = r.lanepos.copy();
  6.       r.laneposran.randomize();
  7.    }
  8.    var popped = r.laneposran.pop();
  9.    if(popped == r.lastpop)
  10.    {
  11.       var popped = r.laneposran.pop();
  12.    }
  13.    r.lastpop = popped;
  14.    return popped;
  15. };
  16. movieclip.prototype.cekswapdep = function()
  17. {
  18.    if(!r.jump and this._x < 300)
  19.    {
  20.       if(this._y < s._y and this.dep > s.dep or this._y > s._y and this.dep < s.dep)
  21.       {
  22.          this.swapdepths(s);
  23.          var dumm = this.dep;
  24.          this.dep = s.dep;
  25.          s.dep = dumm;
  26.       }
  27.    }
  28. };
  29. movieclip.prototype.cekswapdepenemy = function()
  30. {
  31.    var i = 1;
  32.    while(i < r.enemy.length)
  33.    {
  34.       if(_name != r.enemy[i])
  35.       {
  36.          var e = r[r.enemy[i]];
  37.          if(this._y < e._y and this.dep > e.dep or this._y > e._y and this.dep < e.dep)
  38.          {
  39.             this.swapdepths(e);
  40.             var dumm = this.dep;
  41.             this.dep = e.dep;
  42.             e.dep = dumm;
  43.          }
  44.       }
  45.       i++;
  46.    }
  47. };
  48. movieclip.prototype.ceklimits = function()
  49. {
  50.    if(this.nx < r.xmin)
  51.    {
  52.       this.nx = r.xmin;
  53.    }
  54.    if(this.nx > r.xmax)
  55.    {
  56.       this.nx = r.xmax;
  57.    }
  58.    if(this.ny < r.ymin)
  59.    {
  60.       this.ny = r.ymin;
  61.    }
  62.    if(this.ny > r.ymax)
  63.    {
  64.       this.ny = r.ymax;
  65.    }
  66. };
  67. movieclip.prototype.cekbulletenemy = function()
  68. {
  69.    var i = 0;
  70.    while(i < r.bul.length)
  71.    {
  72.       var b = r[r.bul[i]];
  73.       if(this.z.hittest(b))
  74.       {
  75.          this.hit = 1;
  76.          var n = 100 + random(999999);
  77.          this.attachmovie("sparke","s" + n,n);
  78.          this["s" + n]._x = b._x - this._x;
  79.          this["s" + n]._y = b._y - this._y;
  80.          r.bul.removevalue(r.bul[i]);
  81.          b.removeMovieClip();
  82.          r.score += r.point;
  83.          this.energy--;
  84.          if(this.energy <= 0)
  85.          {
  86.             r.zboom2.start();
  87.             this.gotoAndPlay("exp");
  88.          }
  89.          else
  90.          {
  91.             this.attachmovie("blink2","blink2",99);
  92.          }
  93.          break;
  94.       }
  95.       i++;
  96.    }
  97. };
  98. movieclip.prototype.cekbulletenemy2 = function()
  99. {
  100.    var i = 0;
  101.    while(i < r.bul.length)
  102.    {
  103.       var b = r[r.bul[i]];
  104.       if(this.z.hittest(b._x,b._y,1))
  105.       {
  106.          this.hit = 1;
  107.          var n = 100 + random(999999);
  108.          this.attachmovie("sparke","s" + n,n);
  109.          this["s" + n]._x = b._x - this._x;
  110.          this["s" + n]._y = b._y - this._y;
  111.          r.bul.removevalue(r.bul[i]);
  112.          b.removeMovieClip();
  113.          r.score += r.point;
  114.          this.energy--;
  115.          if(this.energy <= 0)
  116.          {
  117.             r.zboom2.start();
  118.             this.gotoAndPlay("exp");
  119.          }
  120.          else
  121.          {
  122.             this.attachmovie("blink2","blink2",99);
  123.          }
  124.          break;
  125.       }
  126.       i++;
  127.    }
  128. };
  129. movieclip.prototype.cekbulletcar = function()
  130. {
  131.    if(s._x < this._x)
  132.    {
  133.       var i = 0;
  134.       while(i < r.bul.length)
  135.       {
  136.          var b = r[r.bul[i]];
  137.          if(this.c.z.hittest(b._x,b._y,1))
  138.          {
  139.             this.hit = 1;
  140.             var n = 100 + random(999999);
  141.             this.attachmovie("spark","s" + n,n);
  142.             if(this.tipe > 1 and this.tipe <= 6)
  143.             {
  144.                this["s" + n]._x = random(10);
  145.                this["s" + n]._y = b._y - this._y;
  146.             }
  147.             else
  148.             {
  149.                this["s" + n]._x = b._x - this._x;
  150.                this["s" + n]._y = b._y - this._y;
  151.             }
  152.             r.bul.removevalue(r.bul[i]);
  153.             b.removeMovieClip();
  154.             break;
  155.          }
  156.          i++;
  157.       }
  158.    }
  159. };
  160. movieclip.prototype.cekhite = function()
  161. {
  162.    if(this.z2.hittest(s.z2))
  163.    {
  164.       r.hit = 1;
  165.       return true;
  166.    }
  167.    return false;
  168. };
  169. movieclip.prototype.cekhitr = function()
  170. {
  171.    if(s._y < this._y and s._y > this._y - this.hei)
  172.    {
  173.       if(r.sx2 > this._x and r.sx1 < this._x + this.wid)
  174.       {
  175.          return true;
  176.       }
  177.       return false;
  178.    }
  179.    return false;
  180. };
  181. movieclip.prototype.initme = function()
  182. {
  183.    r.enemy.push({name:this.name,x:this._x,y:this._y});
  184. };
  185. Movieclip.prototype.findang = function(dx, dy)
  186. {
  187.    return deg(math.atan2(dy,dx));
  188. };
  189. Movieclip.prototype.rad = function(qdeg)
  190. {
  191.    return qdeg * 0.017453292519943295;
  192. };
  193. Movieclip.prototype.deg = function(qrad)
  194. {
  195.    return qrad * 57.29577951308232;
  196. };
  197. Array.prototype.numsortOn = function(p)
  198. {
  199.    Array.$sortprop = p;
  200.    var sortfunc = function(a, b)
  201.    {
  202.       var p = Array.$sortprop;
  203.       return b[p] < a[p];
  204.    };
  205.    this.sort(sortfunc);
  206.    delete Array.$sortprop;
  207. };
  208. Array.prototype.copy = Array.prototype.slice;
  209. Array.prototype.randomize = function()
  210. {
  211.    return this.sort(function(a, b)
  212.    {
  213.       return Math.floor(Math.random() * 2) != 0 ? -1 : 1;
  214.    }
  215.    );
  216. };
  217. Array.prototype.removeElement = function(i)
  218. {
  219.    if(i == null)
  220.    {
  221.       i = 0;
  222.    }
  223.    var r = this[i];
  224.    var j = i;
  225.    while(j < this.length - 1)
  226.    {
  227.       this[j] = this[j + 1];
  228.       j++;
  229.    }
  230.    this.pop();
  231.    return r;
  232. };
  233. Array.prototype.removeValue = function(a)
  234. {
  235.    var i = 0;
  236.    while(i < this.length)
  237.    {
  238.       if(a == this[i])
  239.       {
  240.          this.removeElement(i);
  241.       }
  242.       i++;
  243.    }
  244. };
  245. Color.prototype.setBrightness = function(value)
  246. {
  247.    this.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
  248.    var trans = this.getTransform();
  249.    var percent = Math.abs(value) / 100;
  250.    var brightnessColor = value <= 0 ? 0 : 255;
  251.    with(trans)
  252.    {
  253.       ra -= ra * percent;
  254.       ga -= ga * percent;
  255.       ba -= ba * percent;
  256.       rb += (brightnessColor - rb) * percent;
  257.       gb += (brightnessColor - gb) * percent;
  258.       bb += (brightnessColor - bb) * percent;
  259.    }
  260.    this.setTransform(trans);
  261. };
  262. Color.prototype.resetcolor = function()
  263. {
  264.    this.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
  265. };
  266. Movieclip.prototype.fadescreen = function(speed)
  267. {
  268.    if(!speed)
  269.    {
  270.       var speed = 5;
  271.    }
  272.    _root.createemptymovieclip("dark",1000001);
  273.    var d = _root.dark;
  274.    with(d)
  275.    {
  276.       lineStyle(1,0,100);
  277.       beginfill(0,100);
  278.       moveto(-5000,-5000);
  279.       lineto(5000,-5000);
  280.       lineto(5000,5000);
  281.       lineto(-5000,5000);
  282.       endfill();
  283.       d.onEnterFrame = function()
  284.       {
  285.          _alpha -= speed;
  286.          if(_alpha <= 0)
  287.          {
  288.             removeMovieClip("");
  289.             stop();
  290.          }
  291.       };
  292.    }
  293. };
  294.