home *** CD-ROM | disk | FTP | other *** search
- class CArena extends MovieClip
- {
- var mGravity;
- var gCounter;
- var mState;
- var mFriction;
- var mLineManager;
- var mTimeSlice;
- var mEdgeDraw;
- var _FloorDP;
- var mBackground;
- var mCamera;
- var mMap;
- var mStats;
- var mFirstTime;
- var mWheel;
- var mCollisionDraw;
- var onEnterFrame;
- var mSoundIndex;
- var mSoundList;
- static var mFrameRate = 33.333333333333336;
- static var mMusicVolume = 20;
- function CArena()
- {
- super();
- this.mGravity = new flash.geom.Point(0,3);
- this.gCounter = 0;
- this.mState = "step";
- this.mFriction = 0;
- this.mLineManager = new CLineManager(this);
- this.mTimeSlice = getTimer();
- this.mEdgeDraw = this._FloorDP;
- this.mEdgeDraw._x = 0;
- this.mEdgeDraw._y = 0;
- this.mBackground = this._parent._Background;
- this.mCamera = new CCamera(this,720,406);
- this.mMap = new CMap(this);
- this.mStats = new CStats(this);
- this.mFirstTime = true;
- this.mBackground._visible = this._visible = false;
- _root._HUD._Space._visible = false;
- }
- function Start()
- {
- this.mLineManager.Compile(this.mWheel.mRadius);
- this.mCollisionDraw.clear();
- this.mFirstTime = false;
- this.Process();
- this.mBackground._visible = this._visible = true;
- this.mState = "play";
- this.onEnterFrame = this.Process;
- }
- function AddLineCollection(tNodeList, tObject)
- {
- if(tObject != undefined)
- {
- }
- var _loc2_ = 0;
- while(_loc2_ < tNodeList.length - 1)
- {
- this.AddLine(tNodeList[_loc2_],tNodeList[_loc2_ + 1]);
- _loc2_ = _loc2_ + 1;
- }
- }
- function AddLine(node1, node2)
- {
- this.mLineManager.AddLine(node1,node2);
- }
- function AddWheel(mcWheel)
- {
- this.mWheel = mcWheel;
- this.mWheel.mArena = this;
- this.mCamera.SetTrackObject(this.mWheel);
- }
- function AddObject(tObject, tType)
- {
- this.mMap.AddObject(tObject,tType);
- }
- function Process()
- {
- _root._FPS.Update();
- if(this.mState != "stop" || this.mState == "step")
- {
- while(getTimer() - this.mTimeSlice > CArena.mFrameRate)
- {
- this.gCounter = this.gCounter + 1;
- this.mWheel.Process();
- this.mCamera.Process();
- this.mTimeSlice += CArena.mFrameRate;
- }
- this.UpdateHUD();
- this.mStats.Update();
- }
- else
- {
- this.mTimeSlice = getTimer();
- }
- if(this.mState == "step")
- {
- this.mState = "stop";
- }
- if(_global.mKeyControl && Key.isDown(32) && this.mMap.mOverExit)
- {
- this.ExitArena();
- }
- }
- function ExitArena()
- {
- if(this.mMap.mOverExit)
- {
- _global.mStats.CompareAndUpdate(this.mStats);
- _global.mStats.ArenaComplete();
- this._parent._parent.play();
- }
- this._parent._parent.play();
- }
- function UpdateHUD()
- {
- var _loc3_ = _root._HUD;
- _loc3_.mBarrelCount = this.Pad0(this.mMap.mBarrelCount,2);
- _loc3_.mStarCount = this.Pad0(this.mMap.mStarCount,2);
- if(this.mMap.mOverExit)
- {
- _loc3_._Space._visible = true;
- }
- }
- function Pad0(tNumber, tPAD)
- {
- var _loc1_ = String(tNumber);
- while(_loc1_.length < tPAD)
- {
- _loc1_ = "0" + _loc1_;
- }
- return _loc1_;
- }
- function PlayMusic()
- {
- return undefined;
- }
- function Music_NextLoop()
- {
- this.mSoundIndex = (this.mSoundIndex + 1) % this.mSoundList.length;
- trace(this.mSoundIndex);
- this.mSoundList[this.mSoundIndex].start();
- }
- }
-