home *** CD-ROM | disk | FTP | other *** search
- EnergyMeter = function(mc)
- {
- this.mc = mc;
- this.mc.obj = this;
- this.dots = new Array(false);
- this.mc.onEnterComplete = function()
- {
- this.obj.onEnterComplete();
- };
- GAME.addListener(this);
- GAME.fiveGameFrames.addListener(this);
- };
- t = EnergyMeter.prototype;
- t.onEnterComplete = function()
- {
- };
- t.startDraw = function()
- {
- this.mc.onEnterFrame = function()
- {
- this.obj.drawLoop();
- };
- };
- t.startTrack = function()
- {
- this.stopLoop();
- this.tracking = true;
- };
- t.stopTrack = function()
- {
- this.tracking = false;
- this.stopLoop();
- };
- t.startLoop = function()
- {
- this.mc.onEnterFrame = function()
- {
- this.obj.loop();
- };
- };
- t.stopLoop = function()
- {
- delete this.mc.onEnterFrame;
- };
- t.trackLoop = function()
- {
- this.destEnergy += GAME.getCurEnergyOutput() / 6.2;
- this.perEnergy = this.destEnergy / this.totalEnergyRequired;
- this.mc.per_out = this.perEnergy;
- this.draw();
- if(this.perEnergy >= 1)
- {
- this.mc.goal_dot.show();
- this.stopTrack();
- GAME.curLevelComplete();
- }
- };
- t.drawLoop = function()
- {
- this.perEnergy *= 0.8;
- this.mc.per_out = this.perEnergy;
- this.draw();
- };
- t.draw = function()
- {
- var _loc5_ = this.curDot;
- this.curDot = Math.floor(this.perEnergy * this.dots.length);
- this.mc.dot_out = this.curDot;
- if(this.curDot > _loc5_)
- {
- this.fillDots(_loc5_ + 1,this.curDot);
- }
- else if(this.curDot < _loc5_)
- {
- this.removeDots(this.curDot,_loc5_);
- }
- var _loc6_ = GAME.lights.length;
- var _loc4_ = Math.floor(_loc6_ * this.perEnergy);
- var _loc3_ = GAME.lights._on.length;
- _root.light_out = "total:" + _loc6_ + ", dest on:" + _loc4_ + ", are on:" + _loc3_;
- if(_loc3_ < _loc4_)
- {
- _root.light_out += " ON";
- this.turnLightsOn(_loc4_ - _loc3_);
- }
- else if(_loc3_ > _loc4_)
- {
- _root.light_out += " OFF";
- this.turnLightsOff(_loc3_ - _loc4_);
- }
- };
- t.fillDots = function(from, to)
- {
- var _loc2_ = from;
- while(_loc2_ <= to)
- {
- var _loc3_ = this.dots[_loc2_];
- Audio.play("geo_wind_energyup_1_snd");
- _loc3_.gotoAndPlay("poweron");
- _loc2_ = _loc2_ + 1;
- }
- };
- t.removeDots = function(from, to)
- {
- var _loc2_ = from;
- while(_loc2_ <= to)
- {
- var _loc3_ = this.dots[_loc2_];
- _loc3_.gotoAndPlay("poweroff");
- _loc2_ = _loc2_ + 1;
- }
- };
- t.addDot = function(mc)
- {
- this.dots.push(mc);
- };
- t.turnLightsOn = function(num)
- {
- var _loc3_ = 0;
- while(_loc3_ < num)
- {
- var _loc2_ = Math.floor(Math.random() * GAME.lights._off.length);
- var _loc1_ = GAME.lights._off[_loc2_];
- _loc1_.gotoAndPlay("poweron");
- GAME.lights._on.push(_loc1_);
- GAME.lights._off.splice(_loc2_,1);
- _loc3_ = _loc3_ + 1;
- }
- };
- t.turnLightsOff = function(num)
- {
- var _loc3_ = 0;
- while(_loc3_ < num)
- {
- var _loc2_ = Math.floor(Math.random() * GAME.lights._on.length);
- var _loc1_ = GAME.lights._on[_loc2_];
- _loc1_.gotoAndPlay("poweroff");
- GAME.lights._off.push(_loc1_);
- GAME.lights._on.splice(_loc2_,1);
- _loc3_ = _loc3_ + 1;
- }
- };
- t.reset = function()
- {
- this.destEnergy = 0;
- this.startDraw();
- };
- t.onLevelReset = function()
- {
- this.mc.goal_dot.reset();
- this.reset();
- };
- t.onLevelEnter = function()
- {
- this.mc.goal_dot.reset();
- this.reset();
- };
- t.onLevelStart = function(level)
- {
- this.mc.goal_dot.reset();
- this.totalEnergyRequired = level.totalEnergyRequired;
- this.startTrack();
- };
- t.onFiveGameFrames = function()
- {
- if(this.tracking)
- {
- this.trackLoop();
- }
- };
- t.tracking = false;
- t.dots = false;
- t.totalEnergyRequired;
- t.perEnergy = 0;
- t.curDot = 0;
- t.destEnergy = 0;
- t.curEnergy = 0;
- t.mc = false;
-