home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / wone.swf / scripts / __Packages / CArena.as next >
Encoding:
Text File  |  2007-02-20  |  3.7 KB  |  147 lines

  1. class CArena extends MovieClip
  2. {
  3.    var mGravity;
  4.    var gCounter;
  5.    var mState;
  6.    var mFriction;
  7.    var mLineManager;
  8.    var mTimeSlice;
  9.    var mEdgeDraw;
  10.    var _FloorDP;
  11.    var mBackground;
  12.    var mCamera;
  13.    var mMap;
  14.    var mStats;
  15.    var mFirstTime;
  16.    var mWheel;
  17.    var mCollisionDraw;
  18.    var onEnterFrame;
  19.    var mSoundIndex;
  20.    var mSoundList;
  21.    static var mFrameRate = 33.333333333333336;
  22.    static var mMusicVolume = 20;
  23.    function CArena()
  24.    {
  25.       super();
  26.       this.mGravity = new flash.geom.Point(0,3);
  27.       this.gCounter = 0;
  28.       this.mState = "step";
  29.       this.mFriction = 0;
  30.       this.mLineManager = new CLineManager(this);
  31.       this.mTimeSlice = getTimer();
  32.       this.mEdgeDraw = this._FloorDP;
  33.       this.mEdgeDraw._x = 0;
  34.       this.mEdgeDraw._y = 0;
  35.       this.mBackground = this._parent._Background;
  36.       this.mCamera = new CCamera(this,720,406);
  37.       this.mMap = new CMap(this);
  38.       this.mStats = new CStats(this);
  39.       this.mFirstTime = true;
  40.       this.mBackground._visible = this._visible = false;
  41.       _root._HUD._Space._visible = false;
  42.    }
  43.    function Start()
  44.    {
  45.       this.mLineManager.Compile(this.mWheel.mRadius);
  46.       this.mCollisionDraw.clear();
  47.       this.mFirstTime = false;
  48.       this.Process();
  49.       this.mBackground._visible = this._visible = true;
  50.       this.mState = "play";
  51.       this.onEnterFrame = this.Process;
  52.    }
  53.    function AddLineCollection(tNodeList, tObject)
  54.    {
  55.       if(tObject != undefined)
  56.       {
  57.       }
  58.       var _loc2_ = 0;
  59.       while(_loc2_ < tNodeList.length - 1)
  60.       {
  61.          this.AddLine(tNodeList[_loc2_],tNodeList[_loc2_ + 1]);
  62.          _loc2_ = _loc2_ + 1;
  63.       }
  64.    }
  65.    function AddLine(node1, node2)
  66.    {
  67.       this.mLineManager.AddLine(node1,node2);
  68.    }
  69.    function AddWheel(mcWheel)
  70.    {
  71.       this.mWheel = mcWheel;
  72.       this.mWheel.mArena = this;
  73.       this.mCamera.SetTrackObject(this.mWheel);
  74.    }
  75.    function AddObject(tObject, tType)
  76.    {
  77.       this.mMap.AddObject(tObject,tType);
  78.    }
  79.    function Process()
  80.    {
  81.       _root._FPS.Update();
  82.       if(this.mState != "stop" || this.mState == "step")
  83.       {
  84.          while(getTimer() - this.mTimeSlice > CArena.mFrameRate)
  85.          {
  86.             this.gCounter = this.gCounter + 1;
  87.             this.mWheel.Process();
  88.             this.mCamera.Process();
  89.             this.mTimeSlice += CArena.mFrameRate;
  90.          }
  91.          this.UpdateHUD();
  92.          this.mStats.Update();
  93.       }
  94.       else
  95.       {
  96.          this.mTimeSlice = getTimer();
  97.       }
  98.       if(this.mState == "step")
  99.       {
  100.          this.mState = "stop";
  101.       }
  102.       if(_global.mKeyControl && Key.isDown(32) && this.mMap.mOverExit)
  103.       {
  104.          this.ExitArena();
  105.       }
  106.    }
  107.    function ExitArena()
  108.    {
  109.       if(this.mMap.mOverExit)
  110.       {
  111.          _global.mStats.CompareAndUpdate(this.mStats);
  112.          _global.mStats.ArenaComplete();
  113.          this._parent._parent.play();
  114.       }
  115.       this._parent._parent.play();
  116.    }
  117.    function UpdateHUD()
  118.    {
  119.       var _loc3_ = _root._HUD;
  120.       _loc3_.mBarrelCount = this.Pad0(this.mMap.mBarrelCount,2);
  121.       _loc3_.mStarCount = this.Pad0(this.mMap.mStarCount,2);
  122.       if(this.mMap.mOverExit)
  123.       {
  124.          _loc3_._Space._visible = true;
  125.       }
  126.    }
  127.    function Pad0(tNumber, tPAD)
  128.    {
  129.       var _loc1_ = String(tNumber);
  130.       while(_loc1_.length < tPAD)
  131.       {
  132.          _loc1_ = "0" + _loc1_;
  133.       }
  134.       return _loc1_;
  135.    }
  136.    function PlayMusic()
  137.    {
  138.       return undefined;
  139.    }
  140.    function Music_NextLoop()
  141.    {
  142.       this.mSoundIndex = (this.mSoundIndex + 1) % this.mSoundList.length;
  143.       trace(this.mSoundIndex);
  144.       this.mSoundList[this.mSoundIndex].start();
  145.    }
  146. }
  147.