home *** CD-ROM | disk | FTP | other *** search
- class AirSpace extends MovieClip
- {
- var my_music_vol;
- var my_sfx_vol;
- var master_vol;
- var onEnterFrame;
- var player;
- var current_layout;
- var player_clip;
- var comments;
- var enemies = [];
- var enemy_types = [];
- var enemy_num = 0;
- var enemies_killed = 0;
- var objects = [];
- var clouds = [];
- var layouts = {};
- var timer = 0;
- var timer_num = 0;
- var time_count = 0;
- var pickups = true;
- var obstacle_types = [];
- var particles = true;
- var good = [2,40,80,120,160,200,2];
- var bad = [240,280,320,360,400,440,240];
- var last_comment = 0;
- var count_to_comment = 200;
- function AirSpace()
- {
- super();
- EnemyAI.missiles_out = 0;
- this.my_music_vol = new Sound(_root.music);
- this.my_sfx_vol = new Sound(this);
- this.master_vol = new Sound(_root);
- this.onEnterFrame = function()
- {
- if(this.count_to_comment >= 0)
- {
- this.count_to_comment = this.count_to_comment - 1;
- }
- this.my_music_vol.setVolume(_global.music_vol * 20);
- this.my_sfx_vol.setVolume(_global.sfx_vol * 20);
- if(!_global.game_paused)
- {
- this.master_vol.setVolume(100);
- if(_global.quality_set == "auto")
- {
- this.timer_num = getTimer() - this.timer;
- this.timer = getTimer();
- if(this.timer_num < 46)
- {
- this.time_count = this.time_count + 1;
- }
- else if(this.timer_num > 52)
- {
- this.time_count = this.time_count - 1;
- }
- else
- {
- this.time_count = 0;
- }
- if(this.time_count > 5)
- {
- if(this._quality == "MEDIUM")
- {
- this._quality = "HIGH";
- }
- else if(this._quality == "LOW")
- {
- this._quality = "MEDIUM";
- }
- this.time_count = 0;
- }
- else if(this.time_count < -5)
- {
- if(this._quality == "HIGH")
- {
- this._quality = "MEDIUM";
- }
- else if(this._quality == "MEDIUM")
- {
- this._quality = "LOW";
- }
- this.time_count = 0;
- }
- }
- if(this.pickups)
- {
- this.addPickups();
- this.addObstacles();
- }
- this.addEnemies();
- this.drawAirSpace();
- }
- else
- {
- this.master_vol.setVolume(30);
- }
- };
- }
- function drawAirSpace()
- {
- var _loc2_ = 0;
- while(_loc2_ < this.enemies.length)
- {
- if(this.enemies[_loc2_]._name != undefined)
- {
- this.enemies[_loc2_].drawToScreen();
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc2_ = 0;
- while(_loc2_ < this.objects.length)
- {
- if(this.objects[_loc2_]._name != undefined)
- {
- this.objects[_loc2_].drawToScreen();
- }
- _loc2_ = _loc2_ + 1;
- }
- this.player.usePlayer();
- }
- function shiftToX(p_x)
- {
- var _loc2_ = 0;
- while(_loc2_ < this.enemies.length)
- {
- this.enemies[_loc2_].posX += p_x;
- _loc2_ = _loc2_ + 1;
- }
- _loc2_ = 0;
- while(_loc2_ < this.objects.length)
- {
- this.objects[_loc2_].posX += p_x;
- _loc2_ = _loc2_ + 1;
- }
- this.player.posX += p_x;
- Position.camera_x += p_x;
- }
- function shiftToY(p_y)
- {
- var _loc2_ = 0;
- while(_loc2_ < this.enemies.length)
- {
- this.enemies[_loc2_].posY += p_y;
- _loc2_ = _loc2_ + 1;
- }
- _loc2_ = 0;
- while(_loc2_ < this.objects.length)
- {
- this.objects[_loc2_].posY += p_y;
- _loc2_ = _loc2_ + 1;
- }
- this.player.posY += p_y;
- Position.camera_y += p_y;
- }
- function addLayout(p_layout_name, p_layout)
- {
- this.layouts[p_layout_name] = p_layout;
- }
- function setLayout(p_layout_name)
- {
- this.current_layout = this.layouts[p_layout_name];
- this.emptyAirSpace();
- this.populateAirSpace();
- this.drawAirSpace();
- }
- function addObject(p_object)
- {
- this.objects.push(p_object);
- }
- function emptyAirSpace()
- {
- var _loc2_ = 0;
- while(_loc2_ < this.enemies.length)
- {
- this.enemies[_loc2_].removeMovieClip();
- _loc2_ = _loc2_ + 1;
- }
- this.enemies = [];
- }
- function populateAirSpace()
- {
- if(this.player_clip != this.current_layout.player_clip)
- {
- this.player_clip = this.current_layout.player_clip;
- this.attachMovie(this.current_layout.player_clip,"player",this.getNextHighestDepth());
- }
- var _loc2_ = 0;
- while(_loc2_ < this.current_layout.enemies.length)
- {
- var _loc3_ = this.current_layout.enemies[_loc2_];
- if(_loc3_.pos_z < 3000)
- {
- this.enemy_num = this.enemy_num + 1;
- this.enemies[_loc2_] = this.attachMovie(_loc3_.enemy_clip,"enemy" + _loc2_,this.getNextHighestDepth());
- this.enemies[_loc2_].posX = _loc3_.pos_x;
- this.enemies[_loc2_].posY = _loc3_.pos_y;
- this.enemies[_loc2_].posZ = _loc3_.pos_z;
- }
- _loc2_ = _loc2_ + 1;
- }
- if(this.particles)
- {
- this.addParticles();
- }
- }
- function addParticles()
- {
- var _loc3_ = 0;
- while(_loc3_ < 20)
- {
- var _loc2_ = this.attachMovie("particle","particle" + _loc3_,this.getNextHighestDepth());
- this.objects.push(_loc2_);
- _loc2_.posX = this.player.posX + Math.round(Math.random() * 500) - 250;
- _loc2_.posY = this.player.posY + Math.round(Math.random() * 500) - 250;
- _loc2_.posZ = this.player.posZ + Math.round(Math.random() * 200);
- _loc3_ = _loc3_ + 1;
- }
- }
- function addPickups()
- {
- if(Math.random() < 0.015)
- {
- if(Math.random() > 0.4)
- {
- var _loc2_ = this.attachMovie("health","health" + this.objects.length,this.getNextHighestDepth());
- }
- else
- {
- _loc2_ = this.attachMovie("ammo","ammo" + this.objects.length,this.getNextHighestDepth());
- }
- this.objects.push(_loc2_);
- _loc2_.posX = this.player.posX + Math.round(Math.random() * 1000) - 500;
- _loc2_.posY = this.player.posY + Math.round(Math.random() * 1000) - 500;
- _loc2_.posZ = this.player.posZ + 2000;
- }
- }
- function addObstacles()
- {
- if(Math.random() < 0.009)
- {
- if(this.obstacle_types.length > 0)
- {
- if(Math.random() > 0.5)
- {
- var _loc2_ = this.attachMovie(this.obstacle_types[0],"obstacle" + this.objects.length,this.getNextHighestDepth());
- }
- else
- {
- _loc2_ = this.attachMovie(this.obstacle_types[1],"obstacle" + this.objects.length,this.getNextHighestDepth());
- }
- }
- else
- {
- _loc2_ = this.attachMovie("rock_obstacle","obstacle" + this.objects.length,this.getNextHighestDepth());
- _loc2_.gotoAndStop(Math.ceil(Math.random() * 6));
- }
- this.objects.push(_loc2_);
- _loc2_.posX = this.player.posX + Math.round(Math.random() * 1000) - 500;
- _loc2_.posY = this.player.posY + Math.round(Math.random() * 1000) - 500;
- _loc2_.posZ = this.player.posZ + 2000;
- }
- }
- function addEnemies()
- {
- var _loc2_ = 0;
- while(_loc2_ < this.current_layout.enemies.length)
- {
- var _loc3_ = this.current_layout.enemies[_loc2_];
- if(_loc3_.pos_z <= this.player.posZ + 3000 && _loc3_.pos_z > this.player.posZ + 2990)
- {
- this.enemies[_loc2_] = this.attachMovie(_loc3_.enemy_clip,"enemy" + _loc2_,this.getNextHighestDepth());
- this.enemies[_loc2_].posX = this.player.posX + _loc3_.pos_x;
- this.enemies[_loc2_].posY = this.player.posY + _loc3_.pos_y;
- this.enemies[_loc2_].posZ = _loc3_.pos_z;
- this.enemy_num = this.enemy_num + 1;
- }
- _loc2_ = _loc2_ + 1;
- }
- }
- function goodComment()
- {
- if(this.comments._currentframe == 1 && this.count_to_comment <= 0)
- {
- if(Math.random() < 0.8)
- {
- var _loc2_ = Math.floor(Math.random() * 6);
- if(_loc2_ == this.last_comment)
- {
- _loc2_ = _loc2_ + 1;
- }
- this.comments.gotoAndPlay(this.good[_loc2_]);
- this.last_comment = _loc2_;
- }
- }
- }
- function badComment()
- {
- if(this.comments._currentframe == 1 && this.count_to_comment <= 0)
- {
- if(Math.random() < 0.8)
- {
- var _loc2_ = Math.floor(Math.random() * 6);
- if(_loc2_ == this.last_comment)
- {
- _loc2_ = _loc2_ + 1;
- }
- this.comments.gotoAndPlay(this.bad[_loc2_]);
- this.last_comment = _loc2_;
- }
- }
- }
- }
-