home *** CD-ROM | disk | FTP | other *** search
- class com.neodelight.game.Game
- {
- var id;
- var config;
- var name;
- var title;
- var player;
- var snd;
- var rootFx;
- var stageWidth;
- var stageHeight;
- var hooker;
- var clients;
- var flow;
- var actLevel;
- static var PAUSE_ENGINE = 1;
- static var PAUSE_USER = 2;
- function Game(config)
- {
- com.neodelight.flanix.Kernel.init();
- this.id = "game" + com.neodelight.std.Unique.getId();
- if(config)
- {
- this.config = config;
- }
- else
- {
- this.config = com.neodelight.std.Blueprint.getBlueprint("game");
- if(!this.config)
- {
- trace("!!!blueprint \"game\" not found");
- }
- }
- _global.game = this;
- this.name = this.config.gameName;
- this.title = this.config.gameTitle;
- com.neodelight.std.ClassLib.init();
- if(com.neodelight.std.Blueprint.isBlueprint("player"))
- {
- var _loc6_ = com.neodelight.std.Blueprint.getBlueprint("player");
- if(!_loc6_)
- {
- trace("!!!blueprint \"player\" not found");
- }
- var _loc5_ = com.neodelight.std.ClassLib.getClass("Player");
- if(_loc5_ == undefined)
- {
- trace("!!!class \"Player\" not found in ClassLib");
- }
- else
- {
- var _loc7_ = new _loc5_(_loc6_);
- this.player = _global.player;
- }
- }
- if(this.config.gameHighscores)
- {
- _global.highscores = new com.neodelight.game.Highscores(this.name,this.config.gameHighscoresKey0,this.config.gameHighscoresKey1);
- }
- _global.score = new com.neodelight.game.Score(this.config.gameScoreTypes);
- this.snd = new com.neodelight.std.XSound();
- _global.snd = this.snd;
- _root.snd = this.snd;
- this.rootFx = new com.neodelight.std.ColorFader(_root);
- if(System.capabilities.playerType == "external")
- {
- this.stageWidth = 550;
- this.stageHeight = 400;
- }
- else
- {
- this.stageWidth = Stage.width;
- this.stageHeight = Stage.height;
- }
- if(this.config.gameTimer)
- {
- _global.timer = new com.neodelight.std.Timer(this.config);
- }
- else
- {
- _global.dt = 1;
- }
- this.hooker = _root.createEmptyMovieClip(com.neodelight.std.Unique.getKey(),_root.getNextHighestDepth());
- this.hooker.clients = new Object();
- this.hooker.onEnterFrame = function()
- {
- if(_global.paused)
- {
- return undefined;
- }
- for(var _loc3_ in this.clients)
- {
- this.clients[_loc3_].move();
- }
- };
- com.neodelight.std.Inputs.init();
- this.flow = new com.neodelight.std.Flow();
- this.reset();
- _global.bin.lvl = function(n)
- {
- _global.game.initLevel(n);
- };
- }
- function reset()
- {
- _global.highscores.init();
- _global.score.reset();
- this.hooker.clients = new Object();
- this.actLevel = 0;
- }
- function initLevel(id)
- {
- trace("initLevel(id:" + id + ")");
- if(id != undefined)
- {
- this.actLevel = id;
- }
- delete this.hooker.clients;
- this.hooker.clients = new Object();
- _global.score.initLevel();
- }
- function initGame()
- {
- this.reset();
- }
- function hookIn(o)
- {
- var _loc2_ = !o.id ? com.neodelight.std.Unique.getKey() : o.id;
- if(!_loc2_)
- {
- trace("!!!can\'t assign id to object:" + o);
- }
- trace("o:" + o + ",o.id:" + o.id);
- if(this.hooker.clients[_loc2_])
- {
- trace("!id " + _loc2_ + " already exists in hook");
- return "";
- }
- this.hooker.clients[_loc2_] = o;
- return _loc2_;
- }
- function hookOut(o)
- {
- trace("o:" + o + ",o.id:" + o.id);
- delete this.hooker.clients[o.id];
- }
- function pause(stat, mode)
- {
- _global.paused = stat;
- }
- }
-