home *** CD-ROM | disk | FTP | other *** search
- package
- {
- import ENGINE.CORE.OCache;
- import ENGINE.CORE.OGlobal;
- import ENGINE.CORE.OSound;
- import ENGINE.CORE.OSystem;
- import ENGINE.INTERFACE.OAlert;
- import ENGINE.INTERFACE.OApplication;
- import ENGINE.INTERFACE.OWindow;
- import ENGINE.SMARTFOX.OMultiplayer;
- import RES.OBJECTS.OBang;
- import RES.OBJECTS.OBubble;
- import RES.WINDOWS.OWChoosePlayer;
- import RES.WINDOWS.OWEnterName;
- import RES.WINDOWS.OWGame;
- import RES.WINDOWS.OWHighScores;
- import RES.WINDOWS.OWInstructions;
- import RES.WINDOWS.OWIntro;
- import RES.WINDOWS.OWMenu;
- import RES.WINDOWS.OWOptions;
- import flash.display.BitmapData;
- import flash.display.DisplayObject;
- import flash.display.GradientType;
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.geom.Matrix;
- import flash.system.Security;
-
- public class Clusterz extends OApplication
- {
-
- public static const stNormal:int = 0;
-
- public static const stInstruction:int = 1;
-
-
- private var iShowDemo:Boolean = true;
-
- private var iSystem:OSystem;
-
- private var iBang:OBang;
-
- private var iWindow:OWindow;
-
- public function Clusterz()
- {
- iShowDemo = true;
- super("Clusterz");
- ClusterzL.iGAME;
- Security.allowDomain("*");
- OSound.PlayListAdd("music.mp3");
- OSound.PlayMusic();
- }
-
- override public function Init() : void
- {
- if(!this.stage || this.stage.stageHeight == 0 || this.stage.stageWidth == 0)
- {
- return;
- }
- this.InitBackground([this.MakeBackgroundImage()],0);
- if(ClusterzL.sDebug)
- {
- this.iSystem = new OSystem();
- this.addChild(this.iSystem);
- }
- this.InitImageCache();
- super.Init();
- this.iBang = new OBang();
- this.addChild(this.iBang);
- if(ClusterzL.iGAME.prPlayerName == "")
- {
- this.prMenuItem = ClusterzL.miIntro;
- }
- else
- {
- this.prMenuItem = ClusterzL.miIntro;
- }
- OnMenuItem();
- }
-
- override protected function OnMenuItem() : void
- {
- var _loc1_:int = 0;
- var _loc2_:DisplayObject = null;
- var _loc3_:OWHighScores = null;
- _loc1_ = this.prMenuItem;
- if(_loc1_ != ClusterzL.miInstructions)
- {
- State = stNormal;
- }
- switch(_loc1_)
- {
- case ClusterzL.miNullWindow:
- return;
- case ClusterzL.miLastWindow:
- _loc2_ = this.getChildAt(this.numChildren - 1);
- this.iWindow = _loc2_ is OWindow ? _loc2_ as OWindow : null;
- if(this.iWindow)
- {
- this.iWindow.prActive = true;
- return;
- }
- this.iWindow = new OWMenu();
- this.prMenuItem = ClusterzL.miNullWindow;
- break;
- case ClusterzL.miIntro:
- this.iWindow = new OWIntro();
- if(ClusterzL.iGAME.prPlayerName == "")
- {
- this.prMenuItem = ClusterzL.miEnterNameFirst;
- }
- else
- {
- this.prMenuItem = ClusterzL.miMenu;
- }
- break;
- case ClusterzL.miEnterNameFirst:
- this.iWindow = new OWEnterName(false);
- this.prMenuItem = ClusterzL.miMenu;
- break;
- case ClusterzL.miEnterNewName:
- this.iWindow = new OWEnterName(true);
- (this.iWindow as OWEnterName).prName = "";
- this.prMenuItem = ClusterzL.miLastWindow;
- break;
- case ClusterzL.miMenu:
- iShowDemo = true;
- switch(ClusterzL.iMP.State)
- {
- case OMultiplayer.stNone:
- ClusterzL.iMP.Init(ClusterzL.sDomain,ClusterzL.sServer,ClusterzL.sZone,ClusterzL.sXTName,ClusterzL.iGAME.prPlayerName);
- break;
- case OMultiplayer.stConnectionError:
- if(ClusterzL.iMP.prErrorsCount < 5)
- {
- ClusterzL.iMP.State = OMultiplayer.stNone;
- ClusterzL.iMP.Init(ClusterzL.sDomain,ClusterzL.sServer,ClusterzL.sZone,ClusterzL.sXTName,ClusterzL.iGAME.prPlayerName);
- }
- }
- this.iWindow = new OWMenu();
- this.prMenuItem = ClusterzL.miNullWindow;
- break;
- case ClusterzL.miCommingSoon:
- this.iWindow = new OAlert(ClusterzL.OWCommingSoon,null);
- this.prMenuItem = ClusterzL.miLastWindow;
- break;
- case ClusterzL.miChoosePlayer:
- this.iWindow = new OWChoosePlayer();
- this.prMenuItem = ClusterzL.miMenu;
- break;
- case ClusterzL.miDeletePlayerConfirm:
- this.iWindow = new OAlert(ClusterzL.OWDeletePlayerConfirm,[ClusterzL.miDeletePlayer,ClusterzL.miLastWindow]);
- this.prMenuItem = ClusterzL.miLastWindow;
- break;
- case ClusterzL.miDeletePlayer:
- ClusterzL.iGAME.DeletePlayer(ClusterzL.iGAME.prPlayerName);
- if(ClusterzL.iGAME.prPlayerName != "")
- {
- this.OnMenuItem();
- return;
- }
- this.iWindow = new OWEnterName(false);
- this.prMenuItem = ClusterzL.miLastWindow;
- break;
- case ClusterzL.miOptions:
- this.iWindow = new OWOptions();
- this.prMenuItem = ClusterzL.miLastWindow;
- break;
- case ClusterzL.miGlobalScores:
- this.iWindow = new OWHighScores();
- this.prMenuItem = ClusterzL.miLastWindow;
- break;
- case ClusterzL.miDeleteScoresConfirm:
- this.iWindow = new OAlert(ClusterzL.OWDeleteScoresConfirm,[ClusterzL.miDeleteScores,ClusterzL.miLastWindow]);
- this.prMenuItem = ClusterzL.miLastWindow;
- break;
- case ClusterzL.miDeleteScores:
- _loc3_ = this.getChildAt(this.numChildren - 1) as OWHighScores;
- this.OnMenuItem();
- return;
- case ClusterzL.miPlayGame:
- if(ClusterzL.iGAME.prLevel > 0 || !iShowDemo)
- {
- ClusterzL.iGAME.Start();
- this.iBang.Clear();
- this.iWindow = new OWGame(this.iBang,this.getChildIndex(this.iBang),false);
- this.prMenuItem = ClusterzL.miMenu;
- }
- else
- {
- this.State = stInstruction;
- this.iWindow = new OWInstructions();
- this.iShowDemo = false;
- this.prMenuItem = ClusterzL.miPlayGame;
- }
- break;
- case ClusterzL.miInstructions:
- this.State = stInstruction;
- this.iWindow = new OWInstructions();
- this.prMenuItem = ClusterzL.miLastWindow;
- }
- this.addChild(this.iWindow);
- }
-
- override public function OnPress(param1:Event, param2:*) : void
- {
- if(param1 == null)
- {
- this.prMenuItem = param2;
- }
- }
-
- private function InitImageCache() : void
- {
- var _loc1_:Number = NaN;
- var _loc2_:int = 0;
- var _loc3_:int = 0;
- ClusterzL.iCache = new OCache();
- _loc3_ = 0;
- _loc1_ = 2;
- while(_loc1_ <= 20)
- {
- _loc2_ = 0;
- while(_loc2_ < OBubble.iColorsCount)
- {
- ClusterzL.iCache.SetArrItem("Bubble",_loc3_,OBubble.MakeBubble([null,_loc1_ * 0.97,_loc1_ / 91 * 3,_loc2_]));
- _loc3_++;
- _loc2_++;
- }
- _loc1_ += 0.5;
- }
- _loc3_ = 0;
- _loc1_ = 2;
- while(_loc1_ <= 20)
- {
- _loc2_ = 0;
- while(_loc2_ < OBubble.iColorsCount)
- {
- ClusterzL.iCache.SetArrItem("Shadow",_loc3_,OBubble.MakeShadow([null,_loc1_,_loc1_ / 91 * 3,_loc2_]));
- _loc3_++;
- _loc2_++;
- }
- _loc1_ += 0.5;
- }
- }
-
- override protected function OnDeactivate(param1:Event) : void
- {
- ClusterzL.iGAME.SaveCache();
- }
-
- override public function OnEnterFrame(param1:Event) : void
- {
- super.OnEnterFrame(param1);
- if(!(this.iWindow is OWGame))
- {
- if(Math.random() < 0.02)
- {
- this.iBang.MakeFirework0();
- }
- }
- ClusterzL.iMP.OnEnterFrame();
- if(ClusterzL.sDebug)
- {
- OSystem.iUserText1 = " : " + ClusterzL.iMP.State.toString() + " : " + ClusterzL.iMP.prActiveRoomID.toString() + " " + ClusterzL.iMP.prPlayerID.toString() + " : " + ClusterzL.iMP.prError + " : " + OGlobal.Domain;
- }
- if(this.iWindow)
- {
- if(this.iWindow.prAnimation)
- {
- return;
- }
- if(!this.iWindow.prVisible)
- {
- this.removeChild(this.iWindow);
- this.iWindow.Free();
- this.iWindow = null;
- this.OnMenuItem();
- }
- else if(!this.iWindow.prActive)
- {
- this.OnMenuItem();
- }
- }
- if(State == stNormal && Boolean(iBang))
- {
- iBang.OnEnterFrame(null);
- }
- }
-
- private function MakeBackgroundImage() : BitmapData
- {
- var _loc1_:Sprite = null;
- var _loc2_:Matrix = null;
- var _loc3_:int = 0;
- var _loc4_:BitmapData = null;
- _loc1_ = new Sprite();
- _loc2_ = new Matrix();
- _loc3_ = OGlobal.StageRect.height;
- _loc2_.createGradientBox(50,_loc3_,Math.PI / 2);
- _loc1_.graphics.beginGradientFill(GradientType.LINEAR,[4954918,12709283],[1,1],[0,255],_loc2_);
- _loc1_.graphics.drawRect(0,0,50,_loc3_);
- (_loc4_ = new BitmapData(50,_loc3_,false,0)).draw(_loc1_);
- return _loc4_;
- }
- }
- }
-