home *** CD-ROM | disk | FTP | other *** search
/ Champak 106 / Vol 106.iso / games / global_r.swf / scripts / __Packages / Platform.as < prev    next >
Encoding:
Text File  |  2010-04-12  |  3.0 KB  |  92 lines

  1. class Platform
  2. {
  3.    var sType;
  4.    var position;
  5.    var bOnScreen;
  6.    var bmpCanvas;
  7.    var plaPos;
  8.    var plaWidth;
  9.    var radarPos;
  10.    var arrowPos;
  11.    var bmpPlatform;
  12.    var width;
  13.    var screenPos;
  14.    var frame = 0;
  15.    function Platform(sTypeNew, pos)
  16.    {
  17.       this.sType = sTypeNew;
  18.       this.position = pos.clone();
  19.       this.bOnScreen = false;
  20.       this.bmpCanvas = Game.bmpDead;
  21.       var _loc2_ = undefined;
  22.       if(this.sType == "base")
  23.       {
  24.          _loc2_ = "platform hq";
  25.          this.plaPos = new flash.geom.Point(this.position.x + 17,this.position.y - 87);
  26.          this.plaWidth = 90;
  27.          this.radarPos = new flash.geom.Point(166,0);
  28.       }
  29.       else if(this.sType == "refill")
  30.       {
  31.          _loc2_ = "platform refill";
  32.          this.plaPos = new flash.geom.Point(this.position.x + 7,this.position.y - 29);
  33.          this.plaWidth = 84;
  34.          this.radarPos = new flash.geom.Point(131,0);
  35.       }
  36.       else if(this.sType == "dropZone")
  37.       {
  38.          _loc2_ = "platform drop zone";
  39.          this.plaPos = new flash.geom.Point(this.position.x + 0,this.position.y - 0);
  40.          this.plaWidth = 89;
  41.          this.arrowPos = new flash.geom.Point(45,80);
  42.       }
  43.       this.bmpPlatform = flash.display.BitmapData.loadBitmap(_loc2_);
  44.       this.width = this.bmpPlatform.width;
  45.    }
  46.    function draw(leftEdge)
  47.    {
  48.       var _loc2_ = this.position.x - leftEdge;
  49.       var _loc3_ = this.position.y;
  50.       this.screenPos = new flash.geom.Point(_loc2_,_loc3_);
  51.       if(_loc2_ > - this.bmpPlatform.width && _loc2_ < Game.screenW)
  52.       {
  53.          this.bOnScreen = true;
  54.          if(this.frame >= 13 && this.frame <= 36 && this.sType != "dropZone")
  55.          {
  56.             this.drawRadar();
  57.          }
  58.          this.bmpCanvas.copyPixels(this.bmpPlatform,this.bmpPlatform.rectangle,new flash.geom.Point(this.screenPos.x,Game.screenH - this.screenPos.y),null,null,true);
  59.          if((this.frame < 13 || this.frame > 36) && this.sType != "dropZone")
  60.          {
  61.             this.drawRadar();
  62.          }
  63.          if(this.sType == "dropZone")
  64.          {
  65.             this.drawArrow();
  66.          }
  67.       }
  68.    }
  69.    function drawRadar(Void)
  70.    {
  71.       this.frame = this.frame + 1;
  72.       this.frame %= 50;
  73.       var _loc3_ = _root.attachMovie("radar","radar",993);
  74.       _loc3_.gotoAndStop(this.frame + 1);
  75.       var _loc4_ = new flash.geom.Matrix();
  76.       _loc4_.translate(this.screenPos.x + this.radarPos.x,Game.screenH - (this.screenPos.y + this.radarPos.y));
  77.       this.bmpCanvas.draw(_loc3_,_loc4_,null,null,null,true);
  78.       _loc3_.removeMovieClip();
  79.    }
  80.    function drawArrow(Void)
  81.    {
  82.       this.frame = this.frame + 1;
  83.       this.frame %= 10;
  84.       var _loc3_ = _root.attachMovie("arrow","arrow",994);
  85.       _loc3_.gotoAndStop(this.frame + 1);
  86.       var _loc4_ = new flash.geom.Matrix();
  87.       _loc4_.translate(this.screenPos.x + this.arrowPos.x,Game.screenH - (this.screenPos.y + this.arrowPos.y));
  88.       Game.bmpCanvas.draw(_loc3_,_loc4_,null,null,null,true);
  89.       _loc3_.removeMovieClip();
  90.    }
  91. }
  92.