home *** CD-ROM | disk | FTP | other *** search
- class Environment extends MovieClip
- {
- var music;
- var start;
- var hit_center;
- var inside;
- var pos_x;
- var pos_y;
- var strips;
- var objects;
- var ground_bms;
- var camera_offset;
- var camera_depth;
- var map_bm;
- var weather;
- var last_env;
- var environment_map;
- var clickable;
- var distanceTo;
- var environment;
- var radius;
- var pickup;
- var useItemFunc;
- var showPhotoFunc;
- var level_list;
- var low_x;
- var high_x;
- var low_y;
- var high_y;
- var control;
- function Environment(p_camera_offset, p_camera_depth)
- {
- super();
- this.music = new Sound();
- this.music.onSoundComplete = function()
- {
- this.start();
- };
- this.music.setVolume(40);
- this.hit_center = null;
- this.inside = false;
- this.pos_x = 0;
- this.pos_y = 0;
- this.strips = [];
- this.objects = [];
- this.ground_bms = [];
- this.camera_offset = p_camera_offset;
- this.camera_depth = p_camera_depth;
- var _loc6_ = 3.3;
- var _loc7_ = 0;
- _root.attachMovie("grounds","tg",2);
- this.map_bm = new flash.display.BitmapData(_root.tg._width,_root.tg._height,true,16777215);
- this.map_bm.draw(_root.tg);
- _root.tg.removeMovieClip();
- var _loc8_ = 10;
- var _loc5_ = 0;
- while(_loc5_ < 70)
- {
- var _loc4_ = _root.createEmptyMovieClip("strip" + _loc5_,_loc8_ = _loc8_ + 1);
- this.strips[this.strips.length] = _loc4_;
- _loc4_.attachMovie("m_strip","mask_strip",2);
- _loc4_.createEmptyMovieClip("texture_hold",3);
- _loc4_.texture_hold.createEmptyMovieClip("texture_hold2",2);
- _loc4_.texture_hold.texture_hold2.createEmptyMovieClip("texture",2);
- _loc4_.texture_hold.setMask(_loc4_.mask_strip);
- _loc4_._x = 275;
- _loc4_._y = 300 - _loc7_;
- _loc4_.mask_strip._height = _loc6_ + 0.28;
- _loc4_.z_scale = (_loc4_._y - _loc6_ / 2 - 100) / this.camera_offset;
- _loc4_.z = this.camera_depth / _loc4_.z_scale - this.camera_depth;
- _loc4_.texture_hold._yscale = 100 * _loc4_.z_scale;
- _loc4_.texture_hold._xscale = 100 * _loc4_.z_scale;
- _loc4_.texture_hold.texture_hold2._y = _loc4_.z;
- _loc6_ *= 0.991;
- _loc7_ += _loc6_;
- _loc5_ = _loc5_ + 1;
- }
- this.weather = _root.attachMovie("weather","weather",999997);
- }
- function setEnvironmentMap(env_map)
- {
- var _loc7_ = env_map;
- if((env_map == "hotel" || env_map == "hotel_sun") && Story.sun)
- {
- this.music.stop();
- this.music.attachSound("sun");
- this.music.setVolume(40);
- this.music.start();
- _loc7_ = "hotel_sun";
- }
- else if((env_map == "spring" || env_map == "spring_thunder") && Story.thunder)
- {
- this.music.stop();
- this.music.attachSound("thunder");
- this.music.setVolume(40);
- this.music.start();
- _loc7_ = "spring_thunder";
- }
- else if((env_map == "shrine" || env_map == "shrine_snow") && Story.snow)
- {
- this.music.stop();
- this.music.attachSound("snow");
- this.music.setVolume(40);
- this.music.start();
- _loc7_ = "shrine_snow";
- }
- else if((env_map == "tribal" || env_map == "tribal_rain") && Story.rain)
- {
- this.music.stop();
- this.music.attachSound("rain");
- this.music.setVolume(40);
- this.music.start();
- _loc7_ = "tribal_rain";
- }
- else if(env_map == "tunnel")
- {
- this.music.stop();
- }
- else
- {
- this.music.stop();
- this.music.attachSound("main_loop");
- this.music.setVolume(40);
- this.music.start();
- }
- var _loc3_ = Story[_loc7_];
- this.last_env = _loc7_;
- this.environment_map = _loc3_;
- _root.attachMovie("grounds","tg",_root.getNextHighestDepth()).gotoAndStop(_loc3_.ground);
- if(_loc3_.ground == 2 || _loc3_.ground == 6)
- {
- if(!Story.drained)
- {
- _root.tg.map.pond._visible = false;
- }
- if(!Story.dug_up)
- {
- _root.tg.map.hole._visible = false;
- }
- }
- this.map_bm = new flash.display.BitmapData(_root.tg._width,_root.tg._height,true,16777215);
- this.map_bm.draw(_root.tg);
- _root.tg.removeMovieClip();
- var _loc8_ = 0;
- while(_loc8_ < 70)
- {
- this.strips[_loc8_].texture_hold.texture_hold2.texture.attachBitmap(this.map_bm,2,"auto",true);
- _loc8_ = _loc8_ + 1;
- }
- for(_loc8_ in this.objects)
- {
- _root.createEmptyMovieClip("deleter",this.objects[_loc8_].getDepth());
- this.objects[_loc8_].removeMovieClip();
- }
- _root.bg.gotoAndStop(_loc3_.weather_num);
- this.weather.gotoAndStop(_loc3_.weather_num);
- _root.deleter.removeMovieClip();
- this.setLimits(_loc3_.low_x,_loc3_.high_x,_loc3_.low_y,_loc3_.high_y);
- this.objects = [];
- this.clickable = [];
- var _loc5_ = 100;
- for(_loc8_ in _loc3_.objects)
- {
- _loc5_;
- _root.attachMovie(_loc3_.objects[_loc8_].clip,_loc3_.objects[_loc8_].clip + this.objects.length,_loc5_++);
- _root[_loc3_.objects[_loc8_].clip + this.objects.length].photo_name = _loc3_.objects[_loc8_].photo;
- _root[_loc3_.objects[_loc8_].clip + this.objects.length].pos_x = _loc3_.objects[_loc8_].x;
- _root[_loc3_.objects[_loc8_].clip + this.objects.length].pos_y = _loc3_.objects[_loc8_].y;
- _root[_loc3_.objects[_loc8_].clip + this.objects.length].radius = _loc3_.objects[_loc8_].radius;
- _root[_loc3_.objects[_loc8_].clip + this.objects.length].pickup = this.environment_map.objects[_loc8_].pickup;
- _root[_loc3_.objects[_loc8_].clip + this.objects.length].movable = _loc3_.objects[_loc8_].movable;
- if(_loc3_.objects[_loc8_].pickup != undefined)
- {
- _root[_loc3_.objects[_loc8_].clip + this.objects.length].onRelease = function()
- {
- if(this.distanceTo(this.environment.pos_x,this.environment.pos_y) < 40 + this.radius)
- {
- this.pickup(this);
- }
- };
- if(_root[_loc3_.objects[_loc8_].clip + this.objects.length].photo_name == "a rowing boat")
- {
- _root[_loc3_.objects[_loc8_].clip + this.objects.length].onRollOver = function()
- {
- _root.hud.setText("A Rowing Boat");
- };
- _root[_loc3_.objects[_loc8_].clip + this.objects.length].onRollOut = function()
- {
- _root.hud.setText("");
- };
- }
- }
- if(_root[_loc3_.objects[_loc8_].clip + this.objects.length].onRelease != undefined)
- {
- this.clickable[this.clickable.length] = _root[_loc3_.objects[_loc8_].clip + this.objects.length];
- }
- if(_root[_loc3_.objects[_loc8_].clip + this.objects.length].photo_name == "a bucket and spade")
- {
- Story.bucket_link = _root[_loc3_.objects[_loc8_].clip + this.objects.length];
- }
- if(_root[_loc3_.objects[_loc8_].clip + this.objects.length].photo_name == "a very large sea shell")
- {
- if(Story.snow)
- {
- _root[_loc3_.objects[_loc8_].clip + this.objects.length].gotoAndStop(2);
- }
- else
- {
- _root[_loc3_.objects[_loc8_].clip + this.objects.length].gotoAndStop(1);
- }
- }
- this.objects[this.objects.length] = _root[_loc3_.objects[_loc8_].clip + this.objects.length];
- }
- for(_loc8_ in _loc3_.buildings)
- {
- _loc5_;
- _root.attachMovie(_loc3_.buildings[_loc8_].clip,_loc3_.buildings[_loc8_].clip + this.objects.length,_loc5_++);
- _root[_loc3_.buildings[_loc8_].clip + this.objects.length].photo_name = _loc3_.buildings[_loc8_].photo;
- _root[_loc3_.buildings[_loc8_].clip + this.objects.length].pos_x = _loc3_.buildings[_loc8_].x;
- _root[_loc3_.buildings[_loc8_].clip + this.objects.length].pos_y = _loc3_.buildings[_loc8_].y;
- _root[_loc3_.buildings[_loc8_].clip + this.objects.length].room = _loc3_.buildings[_loc8_].room;
- if(_root[_loc3_.buildings[_loc8_].clip + this.objects.length].photo_name == "chief_hut")
- {
- Story.chief_hut = _root[_loc3_.buildings[_loc8_].clip + this.objects.length];
- }
- this.objects[this.objects.length] = _root[_loc3_.buildings[_loc8_].clip + this.objects.length];
- }
- for(_loc8_ in _loc3_.people)
- {
- _loc5_;
- _root.attachMovie(_loc3_.people[_loc8_].clip,_loc3_.people[_loc8_].clip + this.objects.length,_loc5_++);
- _root[_loc3_.people[_loc8_].clip + this.objects.length].photo_name = _loc3_.people[_loc8_].photo;
- _root[_loc3_.people[_loc8_].clip + this.objects.length].pos_x = _loc3_.people[_loc8_].x;
- _root[_loc3_.people[_loc8_].clip + this.objects.length].pos_y = _loc3_.people[_loc8_].y;
- _root[_loc3_.people[_loc8_].clip + this.objects.length].description = _loc3_.people[_loc8_].descript;
- _root[_loc3_.people[_loc8_].clip + this.objects.length].setSpeech(_loc3_.people[_loc8_].speech);
- if(_loc3_.people[_loc8_].use_item != undefined)
- {
- _root[_loc3_.people[_loc8_].clip + this.objects.length].useItemFunc = _loc3_.people[_loc8_].use_item;
- _root[_loc3_.people[_loc8_].clip + this.objects.length].useItem = function(args)
- {
- this.useItemFunc(this,args);
- };
- _root.hud.addListener(_root[_loc3_.people[_loc8_].clip + this.objects.length]);
- }
- if(_loc3_.people[_loc8_].show_photo != undefined)
- {
- _root[_loc3_.people[_loc8_].clip + this.objects.length].showPhotoFunc = _loc3_.people[_loc8_].show_photo;
- _root[_loc3_.people[_loc8_].clip + this.objects.length].showPhoto = function(args)
- {
- this.showPhotoFunc(this,args);
- };
- _root.hud.addListener(_root[_loc3_.people[_loc8_].clip + this.objects.length]);
- }
- this.clickable[this.clickable.length] = _root[_loc3_.people[_loc8_].clip + this.objects.length];
- this.objects[this.objects.length] = _root[_loc3_.people[_loc8_].clip + this.objects.length];
- }
- this.level_list = {};
- for(_loc8_ in this.objects)
- {
- var _loc4_ = this.objects[_loc8_].pos_y;
- while(!this.checkDepthList(_loc4_))
- {
- _loc4_ = _loc4_ + 1;
- }
- this.level_list[this.objects[_loc8_]._name] = _loc4_;
- }
- }
- function checkDepthList(p_d)
- {
- var _loc2_ = true;
- for(var _loc4_ in this.level_list)
- {
- if(this.level_list[_loc4_] == p_d)
- {
- _loc2_ = false;
- }
- }
- return _loc2_;
- }
- function setLimits(p_lx, p_hx, p_ly, p_hy)
- {
- this.low_x = p_lx;
- this.high_x = p_hx;
- this.low_y = p_ly;
- this.high_y = p_hy;
- }
- function setControl(p_control)
- {
- this.control = p_control;
- }
- function stopToTalk()
- {
- this.control.stopToTalk();
- for(var _loc2_ in this.clickable)
- {
- this.clickable[_loc2_].enabled = false;
- }
- }
- function stopTalking()
- {
- this.control.stopTalking();
- if(!this.control.photoing)
- {
- for(var _loc2_ in this.clickable)
- {
- this.clickable[_loc2_].enabled = true;
- }
- }
- }
- function stopToPhoto()
- {
- this.control.stopToPhoto();
- for(var _loc2_ in this.clickable)
- {
- this.clickable[_loc2_].enabled = false;
- }
- }
- function stopPhotoing()
- {
- this.control.stopPhotoing();
- if(!this.control.talking)
- {
- for(var _loc2_ in this.clickable)
- {
- this.clickable[_loc2_].enabled = true;
- }
- }
- }
- function goInside(p_building, p_room)
- {
- this.inside = true;
- for(var _loc3_ in this.clickable)
- {
- this.clickable[_loc3_].enabled = false;
- }
- this.control.stopToTalk();
- if(!Story.umbrella)
- {
- _root.attachMovie("cutscene","cutscene",1000006);
- _root.cutscene.frame = 1;
- _root.cutscene.env = this;
- _root.cutscene.building = p_building;
- }
- else
- {
- _root.attachMovie("building_inside","building_inside",999998);
- _root.building_inside.frame = p_room;
- _root.building_inside.env = this;
- }
- this.render();
- this.hit_center = _root.building_inside;
- }
- function goOutside()
- {
- this.inside = false;
- this.control.stopTalking();
- this.control.stopPhotoing();
- for(var _loc2_ in this.clickable)
- {
- this.clickable[_loc2_].enabled = true;
- }
- this.control.angle = 1;
- this.control.old_angle = 1;
- this.control.character.gotoAndStop(1);
- this.control.character.body.gotoAndStop(1);
- this.pos_y += 20;
- }
- function moveBy(p_x, p_y)
- {
- var _loc4_ = this.pos_x - p_x;
- var _loc3_ = this.pos_y - p_y;
- if(_loc4_ > this.high_x)
- {
- _loc4_ = this.high_x;
- }
- else if(_loc4_ < this.low_x)
- {
- _loc4_ = this.low_x;
- }
- if(_loc3_ > this.high_y)
- {
- _loc3_ = this.high_y;
- }
- else if(_loc3_ < this.low_y)
- {
- _loc3_ = this.low_y;
- }
- for(var _loc5_ in this.objects)
- {
- if(this.objects[_loc5_].distanceTo(this.pos_x,this.pos_y) < this.objects[_loc5_].radius + 150)
- {
- var _loc2_ = this.objects[_loc5_].collide(_loc4_,_loc3_,this.pos_x,this.pos_y);
- _loc4_ = _loc2_[0];
- _loc3_ = _loc2_[1];
- }
- }
- this.pos_x = _loc4_;
- this.pos_y = _loc3_;
- this.render();
- }
- function render()
- {
- var _loc3_ = 0;
- while(_loc3_ < 70)
- {
- this.strips[_loc3_].texture_hold.texture_hold2.texture._x = - this.pos_x;
- this.strips[_loc3_].texture_hold.texture_hold2.texture._y = - this.pos_y;
- _loc3_ = _loc3_ + 1;
- }
- this.hit_center = _root;
- for(_loc3_ in this.objects)
- {
- this.objects[_loc3_].render(this);
- if(this.objects[_loc3_]._visible && this.objects[_loc3_].hitTest(275,176,false) && this.objects[_loc3_].getDepth() > this.hit_center.getDepth())
- {
- this.hit_center = this.objects[_loc3_];
- }
- }
- if(this.last_env == "spring" && !Story.drained && this.pos_y < 850)
- {
- Story.drain();
- }
- if(this.last_env == "tunnel" && this.pos_y < 290)
- {
- Story.leaveTunnel();
- }
- if(this.last_env == "shrine" || this.last_env == "shrine_snow")
- {
- if(this.pos_x > 1400 && this.pos_x < 1430 && this.pos_y > 715 && this.pos_y < 745 && !Story.trapped)
- {
- Story.getTrapped();
- }
- if(this.pos_x > 1440 && this.pos_x < 1480 && this.pos_y > 1220 && this.pos_y < 1250)
- {
- Story.useTunnel(1);
- }
- }
- var _loc4_ = this.environment_map.height_map.getPixel(this.pos_x / 2,(300 + this.pos_y) / 2);
- if(_loc4_ > 500000)
- {
- _root.blue._y = 280 + 30 * (_loc4_ - 500000) / 15205381;
- _root.blue.view._y = -212 - (_root.blue._y - 280) * 100 / 51.2;
- if(Story.drained && this.pos_x > 1300 && this.pos_x < 1600 && this.pos_y > 500 && this.pos_y < 710)
- {
- if(this.pos_x > 1420 && this.pos_x < 1455 && this.pos_y > 615 && this.pos_y < 640)
- {
- Story.useTunnel(0);
- }
- }
- else
- {
- _root.splash._visible = true;
- _root.splash.play();
- _root.blue.setMask(_root.mask);
- _root.blue.shadow._visible = false;
- }
- }
- else
- {
- _root.blue.view._y = -212 - (_root.blue._y - 280) * 100 / 51.2;
- _root.blue.shadow._visible = true;
- _root.blue.setMask(null);
- _root.blue._y = 280;
- _root.splash._visible = false;
- _root.splash.stop();
- }
- }
- }
-