home *** CD-ROM | disk | FTP | other *** search
- WindMill = function(mc)
- {
- this.mc = mc;
- this.id = this.mc._name;
- this.mc.obj = this;
- var _loc3_ = GAME.mapScreenToGame(this.mc._x,this.mc._y);
- this.game_x = _loc3_.game_x;
- this.game_y = _loc3_.game_y;
- this.minGust = this.min_game_x - this.game_x;
- this.mc.min_power_marker = this.mc.hit_area;
- this.maxPowerRadius = this.mc.max_power_marker._width / (100 / this.mc._xscale) / 2;
- this.minPowerRadius = this.mc.min_power_marker._width / (100 / this.mc._xscale) / 2;
- this.difPowerRadius = this.maxPowerRadius - this.minPowerRadius;
- var _loc2_ = GAME.regLimbo[this.id + "_gauge"];
- if(_loc2_ != undefined)
- {
- this.gauge_mc = _loc2_;
- }
- GAME.addListener(this);
- GAME.gameFrame.addListener(this);
- };
- t = WindMill.prototype;
- t.hitByWindGust = function(windGust)
- {
- if(this.status < 2)
- {
- return false;
- }
- var _loc3_ = Math.abs(windGust.game_x - this.game_x);
- var _loc2_ = (_loc3_ - this.minPowerRadius) / this.difPowerRadius;
- if(_loc2_ > 1)
- {
- _loc2_ = 1;
- }
- if(_loc2_ < 0)
- {
- _loc2_ = 0;
- }
- this.increaseSpeed(windGust.power * _loc2_);
- GAME.adjustScore("hitWindMill",this);
- };
- t.increaseSpeed = function(speed)
- {
- if(this.status < 2)
- {
- return false;
- }
- this.destSpeed += speed;
- };
- t.stopLoop = function()
- {
- delete this.mc.onEnterFrame;
- };
- t.shutDown = function()
- {
- this.status = 0;
- this.friction = 0.93;
- this.mc.onEnterFrame = function()
- {
- this.obj.shutDownLoop();
- };
- this.mc.gotoAndStop("idle");
- };
- t.overLoad = function()
- {
- GAME.adjustScore("windMillOverload",this);
- this.status = 1;
- this.friction = 0.95;
- this.shutDownTime = getTimer();
- this.mc.gotoAndPlay("overload");
- this.mc.half_circle.gotoAndPlay("powerdown");
- this.gauge_mc.gotoAndPlay("overload");
- };
- t.startUp = function()
- {
- this.onGameFrame = function()
- {
- this.loop();
- };
- this.friction = GAME.parameters.globalFriction;
- this.status = 2;
- };
- t.reStartUp = function()
- {
- this.startUp();
- this.gauge_mc.gotoAndPlay("ready");
- this.mc.gotoAndPlay("ready");
- };
- t.loop = function()
- {
- this.adjustSpeed();
- this.energyOutput = 0;
- switch(this.status)
- {
- case 0:
- this.drawGauge();
- break;
- case 1:
- if(getTimer() - this.shutDownTime > this.maxShutDownTime)
- {
- this.reStartUp();
- }
- break;
- case 2:
- if(this.energyPer > 0)
- {
- this.status = 3;
- this.mc.half_circle.gotoAndPlay("powerup");
- }
- break;
- case 3:
- if(this.energyPer <= 0)
- {
- this.status = 2;
- break;
- }
- if(this.energyPer > 1)
- {
- this.overLoad();
- break;
- }
- this.energyOutput = this.maxEnergyOutput * this.energyPer;
- this.drawGauge();
- break;
- }
- this.drawContents();
- this.mc.speed_out = this.speed;
- };
- t.shutDownLoop = function()
- {
- this.destSpeed *= this.friction;
- this.speed += (this.destSpeed - this.speed) * 0.1;
- this.energyPer = (this.speed - this.minSpeed) / this.difSpeed;
- if(this.energyPer < 0)
- {
- this.energyPer = 0;
- }
- this.drawContents();
- this.drawGauge();
- };
- t.adjustSpeed = function()
- {
- this.destSpeed += this.baseWind;
- this.destSpeed *= this.friction;
- this.speed += (this.destSpeed - this.speed) * 0.1;
- this.energyPer = (this.speed - this.minSpeed) / this.difSpeed;
- };
- t.drawContents = function()
- {
- var _loc2_ = this.speed * 0.25;
- this.mc.blades._rotation += _loc2_;
- this.mc.shad.blades._rotation = this.mc.blades._rotation;
- };
- t.drawGauge = function()
- {
- var _loc2_ = Math.floor(this.speed);
- if(_loc2_ < 10)
- {
- _loc2_ = "0" + _loc2_;
- }
- this.gauge_mc.display_mph = _loc2_;
- var _loc3_ = Math.round(this.gauge_mc.first_frame + this.energyPer * 100);
- this.gauge_mc.gotoAndStop(_loc3_);
- };
- t.adjustSound = function()
- {
- var _loc2_ = "";
- if(this.speed > 40)
- {
- _loc2_ = "geo_windmill_hi_snd";
- }
- else if(this.speed > 20)
- {
- _loc2_ = "geo_windmill_med_snd";
- }
- else if(this.speed > 10)
- {
- _loc2_ = "geo_windmill_lo_snd";
- }
- else
- {
- _loc2_ = "none";
- }
- if(this.curSound != _loc2_)
- {
- Audio.stop(this.curSound);
- this.curSound = _loc2_;
- Audio.play(this.curSound);
- }
- };
- t.onLevelStart = function()
- {
- if(this.status == 0)
- {
- this.startUp();
- }
- };
- t.onLevelComplete = function()
- {
- this.shutDown();
- };
- t.onLevelIncomplete = function()
- {
- this.shutDown();
- };
- t.shutDownTime = false;
- t.minGust = 0;
- t.maxShutDownTime = 5000;
- t.destSpeed = 0;
- t.speed = 0;
- t.rotationSpeed = 0;
- t.energyOutput = 0;
- t.energyPer = 0;
- t.baseWind = 0.01;
- t.maxEnergyOutput = GAME.parameters.maxEnergyPerWindMill;
- t.status = 0;
- t.friction = GAME.parameters.globalFriction;
- t.gauge_mc = false;
- t.game_x = 0;
- t.game_y = 0;
- t.min_game_x = 0;
- t.max_game_x = 0;
- t.id = "";
- t.minHalfCircleScale = 75;
- t.maxHalfCircleScale = 100;
- t.difHalfCircleScale = t.maxHalfCircleScale - t.minHalfCircleScale;
- t.minSpeed = GAME.parameters.minWindMillMPH;
- t.maxSpeed = GAME.parameters.maxWindMillMPH;
- t.difSpeed = GAME.parameters.maxWindMillMPH - GAME.parameters.minWindMillMPH;
- t.maxPowerRadius = 0;
- t.minPowerRadius = 0;
- t.difPowerRadius = 0;
- t.toString = function()
- {
- return "[WindMill " + this.game_x + "," + this.game_y + "]";
- };
-