home *** CD-ROM | disk | FTP | other *** search
Text File | 2007-10-01 | 106.0 KB | 2,736 lines |
- class CGame
- {
- var buble_id;
- var redt;
- var _checkpoint_x;
- var _checkpoint_y;
- var _ie;
- var _lvls;
- var _lvls_type;
- var _lvls_rot;
- var _lvls_gfxbg;
- var _lvls_flip;
- var _lvls_tip;
- var _current_map;
- var _map_xml;
- var _levels_xml;
- var last_lvl;
- var _monsters_xml;
- var maxtiles_x;
- var maxtiles_y;
- var _diams;
- var _max_diams;
- var _ready;
- var _tile_size;
- var _tile_sizeh;
- var _game_width;
- var _game_height;
- var _char_x;
- var _char_y;
- var _chp_max;
- var _cmp_max;
- var _chp;
- var _cmp;
- var _cund;
- var _char_alpha;
- var _canim;
- var _csx;
- var _char_xaspeed;
- var _char_xaspeed_max;
- var _csy;
- var _char_ygspeed;
- var _char_run;
- var _char_jump;
- var _scores;
- var _char_lives;
- var _map_x;
- var _map_y;
- var _map_x_max;
- var _exps;
- var _level_start_time;
- var _char_xscale;
- var x;
- var y;
- var _arrowto_x;
- var _arrowto_y;
- static var LEVELS_ID;
- static var _total_monsters_count;
- static var _total_bonuses_count;
- static var MONSTER_ULITKA_SPEED = 1;
- static var MONSTER_FISH3_SPEED = 3;
- static var MONSTER_FISH1_SPEED = 2;
- static var MONSTER_FISH3_KEY = "~";
- static var MONSTER_FISH1_KEY = "_";
- static var MONSTER_FISH1_ZONE_H = 2;
- static var MONSTER_FISH1_ZONE_W = 2;
- static var MONSTER_DEADFALL_YSPEED = -7;
- static var GAME_GRAVITY = 0.8;
- static var TILES_ALL_MONSTERS = "asdu~_";
- static var TILES_ALL_BONUSES = "6789kf2";
- static var IS_LEVEL_EDITOR = false;
- var map_drawed_x = -10000;
- var map_drawed_y = -10000;
- var ELEVATOR_E_SPEED = 2;
- static var ELEVATOR_STATE_WAIT = 0;
- static var ELEVATOR_STATE_GO = 1;
- static var ELEVATOR_STATE_TIMESTOP = 2;
- static var ELEVATOR_STATE_GOBACK = 3;
- static var ELEVATOR_STOP_TIME = 60;
- static var MONSTERS_ID = 1;
- static var ELEVATORS_ID = 2;
- static var TIPS_ID = 3;
- static var COCONUTS_ID = 4;
- var waterlevel_tiley = 0;
- var _stars_collecled = 0;
- static var _level_total_time = 0;
- var _ts = 32;
- var _tsh = 24;
- var _ts2 = 16;
- var _tsh2 = 12;
- var _char_on_elev = false;
- var _char_on_elev_id = 0;
- var _first_turn = 0;
- var TILEW = CGame.prototype._ts;
- var TILEH = CGame.prototype._tsh;
- var DRAW_ZONE_W = 11.5;
- var DRAW_ZONE_H = 13.5;
- var DRAW_ZONE_X0 = -3;
- var DRAW_ZONE_Y0 = -2;
- var _prev_drawed_x = -1;
- var _prev_drawed_y = -1;
- var _prev_drawed_xpix = -1;
- var _prev_drawed_ypix = -1;
- var monsters_to_die = new Array();
- static var COCONUT_STATE_WAIT = 0;
- static var COCONUT_STATE_STRESS = 1;
- static var COCONUT_STATE_FALL = 2;
- static var COCONUT_STATE_LIE = 3;
- static var COCONUT_STATE_FIRE = 4;
- static var COCONUT_STATE_DIE = 5;
- static var COCONUT_FALL_ZONE = 100;
- static var COCONUT_STRESS_TIME = 30;
- static var COCONUT_GRAVITY = CGame.GAME_GRAVITY;
- static var COCONUT_FIRE_X_SPEED = 10;
- static var COCONUT_FIRE_Y_SPEED = -4;
- function CGame(map_xml, cmap, scores, lives, checkpoint_x, checkpoint_y, lvls, diams, stars)
- {
- trace("<CGame>");
- this._stars_collecled = stars;
- this.buble_id = 0;
- _global._game_paused = false;
- this.redt = true;
- if(checkpoint_x == -1 || checkpoint_x == undefined)
- {
- this._checkpoint_x = -1;
- this._checkpoint_y = -1;
- }
- else
- {
- this._checkpoint_x = checkpoint_x;
- this._checkpoint_y = checkpoint_y;
- }
- this._ie = false;
- this._lvls = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]];
- this._lvls_type = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]];
- this._lvls_rot = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]];
- this._lvls_gfxbg = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]];
- this._lvls_flip = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]];
- this._lvls_tip = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]];
- CGame.LEVELS_ID = 0;
- CGame.MONSTERS_ID = 1;
- CGame.ELEVATORS_ID = 2;
- CGame.TIPS_ID = 3;
- this._current_map = cmap;
- this._map_xml = map_xml;
- this._levels_xml = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.LEVELS_ID];
- if(this._current_map == 4)
- {
- this.last_lvl = true;
- }
- else
- {
- this.last_lvl = false;
- }
- this._monsters_xml = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID];
- this.maxtiles_x = this._levels_xml.childNodes[0].attributes.params.length;
- this.maxtiles_y = this._levels_xml.childNodes.length;
- if(diams == undefined || diams == 0)
- {
- this._diams = 0;
- }
- else
- {
- this._diams = diams;
- }
- if(this._diams >= this._max_diams)
- {
- this._ready = false;
- }
- var _loc11_ = true;
- if(lvls != undefined)
- {
- this._lvls = lvls;
- _loc11_ = false;
- }
- var _loc5_ = 0;
- while(_loc5_ < this.maxtiles_x)
- {
- var _loc4_ = 0;
- while(_loc4_ < this.maxtiles_y)
- {
- this._lvls_gfxbg[_loc5_][_loc4_] = 0;
- if(_loc11_)
- {
- this._lvls[_loc5_][_loc4_] = this._levels_xml.childNodes[_loc4_].attributes.params.charAt(_loc5_);
- }
- _loc4_ = _loc4_ + 1;
- }
- _loc5_ = _loc5_ + 1;
- }
- this._max_diams = 5;
- if(this._diams >= this._max_diams)
- {
- this._ready = true;
- }
- else
- {
- this._ready = false;
- }
- this.set_tiles_angle();
- var _loc13_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.TIPS_ID];
- var _loc7_ = 0;
- while(_loc7_ < _loc13_.childNodes.length)
- {
- var _loc6_ = _loc13_.childNodes[_loc7_];
- var _loc9_ = _loc6_.attributes.xpos;
- var _loc8_ = _loc6_.attributes.ypos;
- var _loc10_ = _loc6_.attributes.tipid;
- this._lvls[_loc9_][_loc8_] = "h";
- this._lvls_tip[_loc9_][_loc8_] = _loc10_;
- _loc7_ = _loc7_ + 1;
- }
- _global._tc = 1;
- this._tile_size = this._ts;
- this._tile_sizeh = this._tsh;
- this._game_width = 400;
- this._game_height = 300;
- this._char_x = 0;
- this._char_y = 0;
- this._chp_max = 7;
- this._cmp_max = 50;
- this._chp = 5;
- this._cmp = this._cmp_max;
- this._cund = 0;
- this._char_alpha = 100;
- this._canim = 1;
- this._csx = 0;
- this._char_xaspeed = 0;
- this._char_xaspeed_max = this._ts * 2 / 3;
- this._csy = 0;
- this._char_ygspeed = (- this._tsh) / 9;
- this._char_run = this._ts / 5;
- this._char_jump = this._ts * 0.95;
- this._scores = 0;
- this._add_scores(scores);
- _root.main.face_scr.cur_scores = scores;
- this._char_lives = lives;
- this._map_x = 0;
- this._map_y = 0;
- this._map_x_max = this.get_x_scr(this.maxtiles_x) - this._game_width - this._ts;
- _root.main.createEmptyMovieClip("gfx_scr",_root.gfx_depth);
- this.show_tiles(0,0);
- this.add_turtle();
- this.show_bg();
- this.add_hp(0);
- _root.main.face_scr.mcDimonds.SetValue(this._diams);
- _root.main.face_scr.lives = this._char_lives;
- this.get_nearest_diam();
- _root.main.face_scr.attachMovie("arrow","arrow_mc",_root.arrow_depth);
- this.show_arrow();
- this._exps = 0;
- _root.anykey_pressed = true;
- _root.anykey_count = 0;
- if(_global.keyboard_control)
- {
- if(Helper.TIPS_BY_EVENT)
- {
- _root.show_tip(8);
- }
- }
- else if(Helper.TIPS_BY_EVENT)
- {
- _root.show_tip(9);
- }
- var _loc12_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID];
- var _loc19_ = _loc12_.childNodes.length;
- while(_loc12_.childNodes.length > 0)
- {
- _loc12_.childNodes[0].removeNode();
- }
- _loc5_ = 0;
- while(_loc5_ < this.maxtiles_x)
- {
- _loc4_ = 0;
- while(_loc4_ < this.maxtiles_y)
- {
- if(this._lvls[_loc5_][_loc4_] == "E")
- {
- this._lvls[_loc5_][_loc4_] = "e";
- }
- else if(this._lvls[_loc5_][_loc4_] == "O")
- {
- this._lvls[_loc5_][_loc4_] = "o";
- }
- else if(this._lvls[_loc5_][_loc4_] == "T")
- {
- this._lvls[_loc5_][_loc4_] = "t";
- }
- _loc4_ = _loc4_ + 1;
- }
- _loc5_ = _loc5_ + 1;
- }
- var _loc15_ = this._checkpoint_x == -1;
- if(_loc15_)
- {
- CGame._total_monsters_count = this.GetCountTilesOfType(CGame.TILES_ALL_MONSTERS,this._lvls);
- CGame._total_bonuses_count = this.GetCountTilesOfType(CGame.TILES_ALL_BONUSES,this._lvls);
- CGame._level_total_time = 0;
- }
- this._level_start_time = getTimer();
- this.waterlevel_tiley = Math.round(Number(XMLNode(this._map_xml.firstChild.childNodes[this._current_map]).attributes.waterlevel));
- this.waterlevel_tiley *= this._tsh;
- this.UpdateWaterLevel();
- this.generate_gfxbg();
- trace("</CGame>");
- }
- function GetCountTilesOfType(types, search_in_array)
- {
- var _loc4_ = 0;
- var _loc3_ = 0;
- while(_loc3_ < this.maxtiles_x)
- {
- var _loc2_ = 0;
- while(_loc2_ < this.maxtiles_y)
- {
- if(types.indexOf(search_in_array[_loc3_][_loc2_]) != -1)
- {
- _loc4_ = _loc4_ + 1;
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- return _loc4_;
- }
- function kick_char(side)
- {
- _root.hero_dmg.start();
- _root.main.char._alpha = 40;
- this._cund = 60;
- this._csy = this._char_jump * 0.5;
- this._char_xaspeed -= this._char_run * 3 * side;
- this._canim = 3;
- }
- function move_char(to_x, to_y)
- {
- var _loc3_ = 40;
- var _loc2_ = 0;
- if(to_x - _loc3_ > this._char_x)
- {
- _loc2_ = 1;
- }
- if(to_x + _loc3_ < this._char_x)
- {
- _loc2_ = -1;
- }
- this.move(_loc2_);
- }
- function move(side)
- {
- _root.anykey_count = 0;
- _root.anykey_pressed = true;
- this._csx = side;
- if(this._canim != 3)
- {
- this._canim = 2;
- }
- if(side != 0)
- {
- _root.main.char._xscale = this._char_xscale * side;
- }
- }
- function jump_char()
- {
- var _loc3_ = Math.round((this._char_x + this._map_x + this._ts2) / this._ts) - 1;
- var _loc2_ = Math.round((this._char_y + this._map_y + this._tsh2) / this._tsh);
- if((this._levels_xml.childNodes[_loc2_ - 1].attributes.params.charAt(_loc3_) == 0 || this._char_on_elev) && this._csy == 0)
- {
- this._jump_char();
- }
- }
- function _jump_from_mon_char()
- {
- _root.anykey_pressed = true;
- _root.hero_mon.start();
- this._csy = this._char_jump;
- this._canim = 3;
- }
- function _jump_char()
- {
- _root.anykey_count = 0;
- _root.anykey_pressed = true;
- _root.hero_jump.start();
- this._csy += this._char_jump;
- this._canim = 3;
- }
- function TestMonsterWithChar(monst_mc, charx, chary)
- {
- return monst_mc.hitTest(charx,chary,true) || monst_mc.hitTest(charx,chary - this._tsh,true);
- }
- function turn()
- {
- if(this._first_turn > 5 && this._first_turn < 7)
- {
- _root.main.face_scr.mcShells.SetValue(this._chp);
- this._first_turn = this._first_turn + 1;
- }
- else if(this._first_turn < 7)
- {
- this._first_turn = this._first_turn + 1;
- }
- if(_global._tc > 30)
- {
- _global._tc = 1;
- }
- else
- {
- _global._tc = _global._tc + 1;
- }
- var _loc16_ = Math.round;
- var _loc6_ = _loc16_((this._char_x + this._map_x + this._ts2) / this._ts) - 1;
- var _loc7_ = _loc16_((this._char_y + this._map_y + this._tsh2) / this._tsh);
- var _loc45_ = this._lvls[_loc6_][_loc7_];
- var _loc30_ = false;
- var _loc27_ = _root.main.gfx_scr.monsters_scr;
- if((this.TestMonsterWithChar(_loc27_,_root.main.char._x + 5,_root.main.char._y) || this.TestMonsterWithChar(_loc27_,_root.main.char._x - 5,_root.main.char._y)) && this._csy < -0.5)
- {
- trace("_csy==" + this._csy);
- this._jump_from_mon_char();
- var _loc17_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes.length;
- var _loc10_ = 0;
- while(_loc10_ < _loc17_)
- {
- if(this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[_loc10_].attributes.type != "s")
- {
- if(this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[_loc10_].attributes.type != "d")
- {
- var _loc8_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[_loc10_].attributes;
- var _loc26_ = "monster" + _loc10_;
- var _loc13_ = _loc27_[_loc26_];
- if(this.TestMonsterWithChar(_loc13_,_root.main.char._x + 5,_root.main.char._y) || this.TestMonsterWithChar(_loc13_,_root.main.char._x - 5,_root.main.char._y))
- {
- this.add_explosion(_loc13_._x,_loc13_._y,2);
- var _loc20_ = Math.random();
- if(_loc20_ >= 0.7)
- {
- if(this._lvls[_loc6_][_loc7_ - 1] == 1)
- {
- var _loc18_ = 3;
- if(Math.random() > 0.5)
- {
- _loc18_ = 4;
- }
- this._lvls[_loc6_][_loc7_ - 1] = _loc18_;
- }
- this.redt = true;
- }
- if(_loc8_.type == "u")
- {
- _root.snd_snain_die.start();
- }
- else if(_loc8_.type == CGame.MONSTER_FISH3_KEY)
- {
- _root.snd_fish3_die.start();
- }
- else if(_loc8_.type == CGame.MONSTER_FISH1_KEY)
- {
- _root.snd_fish1_die.start();
- }
- else if(_loc8_.type == "a")
- {
- _root.snd_octopus_die.start();
- }
- this.kill_monster(_loc10_);
- _loc30_ = true;
- }
- }
- }
- _loc10_ = _loc10_ + 1;
- }
- }
- if(this._cund == 0 && !_loc30_)
- {
- if(this.TestMonsterWithChar(_loc27_,_root.main.char._x + 5,_root.main.char._y))
- {
- this.add_hp(-1);
- this.kick_char(1);
- }
- else if(this.TestMonsterWithChar(_loc27_,_root.main.char._x - 5,_root.main.char._y))
- {
- this.add_hp(-1);
- this.kick_char(-1);
- }
- }
- if(_root.main.gfx_scr.coconuts_scr.hitTest(_root.main.char._x,_root.main.char._y,true))
- {
- trace(111);
- var _loc33_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes.length;
- _loc10_ = 0;
- while(_loc10_ < _loc33_)
- {
- trace("222 " + _loc10_);
- _loc26_ = "coconut" + _loc10_;
- trace(_root.main.char._x);
- if(_root.main.gfx_scr.coconuts_scr[_loc26_].hitTest(_root.main.char._x,_root.main.char._y,true))
- {
- trace("333 " + _loc10_);
- var _loc19_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes[_loc10_].attributes;
- if(_loc19_.state == CGame.COCONUT_STATE_LIE && this._csy == 0)
- {
- trace("coconut FIRE");
- _loc19_.state = CGame.COCONUT_STATE_FIRE;
- _loc19_.xspeed = CGame.COCONUT_FIRE_X_SPEED * (this._csx < 0 ? -1 : 1);
- _loc19_.yspeed = CGame.COCONUT_FIRE_Y_SPEED;
- }
- else if(_loc19_.state == CGame.COCONUT_STATE_FALL)
- {
- this.add_hp(-1);
- this.kick_char(_loc19_.xspeed <= 0 ? 1 : -1);
- }
- break;
- }
- _loc10_ = _loc10_ + 1;
- }
- }
- _loc33_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes.length;
- _loc10_ = 0;
- while(_loc10_ < _loc33_)
- {
- _loc26_ = "coconut" + _loc10_;
- _loc19_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes[_loc10_].attributes;
- if(!(_loc19_.state != CGame.COCONUT_STATE_FIRE && _loc19_.state != CGame.COCONUT_STATE_FALL))
- {
- var _loc9_ = new Object();
- _loc9_.x = _root.main.gfx_scr.coconuts_scr[_loc26_]._x;
- _loc9_.y = _root.main.gfx_scr.coconuts_scr[_loc26_]._y;
- _root.main.gfx_scr.localToGlobal(_loc9_);
- var _loc15_ = _loc9_.x;
- var _loc14_ = _loc9_.y;
- if(_root.main.gfx_scr.monsters_scr.hitTest(_loc15_,_loc14_,true))
- {
- _loc17_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes.length;
- var _loc4_ = 0;
- while(_loc4_ < _loc17_)
- {
- var _loc12_ = "monster" + _loc4_;
- if(_root.main.gfx_scr.monsters_scr[_loc12_].hitTest(_loc15_,_loc14_,true))
- {
- var _loc5_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[_loc4_].attributes.type;
- if(_loc5_ == "u")
- {
- _root.snd_snain_die.start();
- }
- else if(_loc5_ == CGame.MONSTER_FISH3_KEY)
- {
- _root.snd_fish3_die.start();
- }
- else if(_loc5_ == CGame.MONSTER_FISH1_KEY)
- {
- _root.snd_fish1_die.start();
- }
- else if(_loc8_.type == "a")
- {
- _root.snd_octopus_die.start();
- }
- this.kill_monster(_loc4_);
- }
- _loc4_ = _loc4_ + 1;
- }
- }
- }
- _loc10_ = _loc10_ + 1;
- }
- if(_loc45_ == "v")
- {
- _root.savepoint.start();
- this._checkpoint_x = _loc6_;
- this._checkpoint_y = _loc7_;
- this._lvls[_loc6_][_loc7_] = "b";
- this.redt = true;
- }
- if(this._csy < 0)
- {
- if(this._lvls[_loc6_][_loc7_ - 1] == "x")
- {
- this._jump_char();
- this._jump_char();
- this._lvls[_loc6_][_loc7_ - 1] = 1;
- this.add_explosion(this.get_x_scr(_loc6_),this.get_y_scr(_loc7_ - 1),2);
- this.add_explosion(this.get_x_scr(_loc6_),this.get_y_scr(_loc7_ - 1),2);
- this.add_explosion(this.get_x_scr(_loc6_ + 1),this.get_y_scr(_loc7_ - 1),2);
- this.add_explosion(this.get_x_scr(_loc6_ + 1),this.get_y_scr(_loc7_ - 1),2);
- this.redt = true;
- }
- if(this._lvls[_loc6_ - 1][_loc7_ - 1] == "x")
- {
- this._jump_char();
- this._jump_char();
- this._lvls[_loc6_ - 1][_loc7_ - 1] = 1;
- this.add_explosion(this.get_x_scr(_loc6_),this.get_y_scr(_loc7_ - 1),2);
- this.add_explosion(this.get_x_scr(_loc6_),this.get_y_scr(_loc7_ - 1),2);
- this.add_explosion(this.get_x_scr(_loc6_ - 1),this.get_y_scr(_loc7_ - 1),2);
- this.add_explosion(this.get_x_scr(_loc6_ - 1),this.get_y_scr(_loc7_ - 1),2);
- this.redt = true;
- }
- if(this._lvls[_loc6_][_loc7_ - 1] == "m")
- {
- this._jump_char();
- this._jump_char();
- this.add_explosion(this.get_x_scr(_loc6_),this.get_y_scr(_loc7_ - 1),2);
- this.add_explosion(this.get_x_scr(_loc6_),this.get_y_scr(_loc7_ - 1),2);
- this.add_explosion(this.get_x_scr(_loc6_ + 1),this.get_y_scr(_loc7_ - 1),2);
- this.add_explosion(this.get_x_scr(_loc6_ + 1),this.get_y_scr(_loc7_ - 1),2);
- }
- }
- this.elevators_move();
- var _loc11_ = 0;
- var _loc35_ = _loc16_((this._char_x + (this._csx + this._char_xaspeed) * this._ts2 + this._map_x + this._ts2) / this._ts) - 1;
- if(!(this._lvls[_loc35_][_loc7_] == 0 && this._lvls[_loc35_][_loc7_ + 1] == 0 || this._lvls[_loc35_][_loc7_] == 0 && this._lvls[_loc35_][_loc7_ - 1] == 0 || this._lvls[_loc35_][_loc7_] == undefined))
- {
- _loc11_ = this._csx * this._char_run + this._char_xaspeed;
- }
- var _loc42_ = 0;
- var _loc38_ = 0;
- if(this._csy < 0 && !this._char_on_elev)
- {
- var _loc31_ = this._char_y + this._csy;
- var _loc32_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes.length;
- var _loc24_ = false;
- _loc10_ = 0;
- while(_loc10_ < _loc32_)
- {
- _loc26_ = "elevator" + _loc10_;
- var _loc28_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes[_loc10_];
- var _loc44_ = _loc28_.attributes.x - this._map_x;
- var _loc46_ = this._game_height - _loc28_.attributes.y - this._map_y + this._tsh2;
- var _loc43_ = _loc28_.attributes.wide2;
- var _loc40_ = Math.abs(_loc28_.attributes.speed) + 2;
- if(this._char_x >= _loc44_ - _loc43_ && this._char_x <= _loc44_ + _loc43_ && this._char_y > _loc46_ && _loc31_ - _loc40_ <= _loc46_)
- {
- this._char_on_elev = true;
- this._char_on_elev_id = _loc10_;
- this._char_y = _loc46_;
- this._csy = 0;
- _loc24_ = true;
- break;
- }
- if(!_loc24_)
- {
- this._char_on_elev = false;
- }
- _loc10_ = _loc10_ + 1;
- }
- }
- else if(this._char_on_elev)
- {
- _loc28_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes[this._char_on_elev_id];
- _loc44_ = _loc28_.attributes.x - this._map_x;
- _loc46_ = this._game_height - _loc28_.attributes.y - this._map_y + this._tsh2;
- _loc43_ = _loc28_.attributes.wide2;
- var _loc39_ = _loc28_.attributes.side;
- _loc40_ = _loc28_.attributes.speed;
- if(this._char_x < _loc44_ - _loc43_ || this._char_x > _loc44_ + _loc43_)
- {
- this._char_on_elev = false;
- }
- if(this._char_on_elev)
- {
- this._char_y = _loc46_;
- if(_loc28_.attributes.type == "o")
- {
- this._char_x += _loc40_ * (- _loc39_);
- _loc38_ = _loc40_ * (- _loc39_);
- }
- else if(_loc28_.attributes.type == "e")
- {
- _loc42_ = _loc40_ * _loc39_;
- }
- else if(_loc28_.attributes.type == "t")
- {
- switch(_loc28_.attributes.state)
- {
- case CGame.ELEVATOR_STATE_GO:
- case CGame.ELEVATOR_STATE_GOBACK:
- _loc42_ = _loc40_ * _loc39_;
- }
- }
- }
- }
- var _loc41_ = this._csy;
- if(!this._char_on_elev)
- {
- if(this._lvls[_loc6_][_loc7_ - 1] != 0 || this._lvls[_loc6_][_loc7_ - 1] == 0 && this._csy > 0)
- {
- this._csy += this._char_ygspeed;
- _loc41_ = this._csy;
- }
- else if(this._csy <= 0)
- {
- if(Math.abs(_loc11_) > 0.2)
- {
- this._canim = 2;
- }
- else
- {
- this._canim = 1;
- }
- if(this._csy < 0)
- {
- this._csy = 0;
- }
- }
- }
- else if(this._csy > 0)
- {
- this._csy += this._char_ygspeed;
- _loc41_ = this._csy;
- this._char_on_elev = false;
- }
- if(this._char_on_elev)
- {
- if(Math.abs(_loc11_) > 0.2)
- {
- this._canim = 2;
- }
- else
- {
- this._canim = 1;
- }
- }
- if(!this._char_on_elev)
- {
- var _loc21_ = _loc16_((this._char_y + this._map_y + this._tsh2 + 2) / this._tsh);
- if(this._lvls[_loc6_][_loc21_ - 1] == 0 && this._csy == 0)
- {
- var _loc23_ = 0;
- var _loc25_ = 0;
- var _loc22_ = 0;
- var _loc36_ = undefined;
- var _loc34_ = undefined;
- var _loc29_ = 0;
- while(this._lvls[_loc6_][_loc21_ - 1] == 0)
- {
- _loc29_ = 1;
- _loc22_ = _loc22_ + 1;
- _loc23_ -= _loc11_ / 3;
- _loc25_ += _loc11_ / 3;
- _loc21_ = _loc16_((this._char_y + _loc22_ + this._map_y + 2 + this._tsh2) / this._tsh);
- _loc36_ = _loc16_((this._char_x + _loc23_ + this._map_x + this._ts2) / this._ts) - 1;
- _loc34_ = _loc16_((this._char_x + _loc25_ + this._map_x + this._ts2) / this._ts) - 1;
- }
- switch(_loc29_)
- {
- case 0:
- this._char_x += _loc23_ * 2;
- this._char_xaspeed = (- this._char_run) * 2;
- this._csy = _loc41_;
- _loc11_ = 0;
- _loc6_ = _loc16_((this._char_x + this._map_x + this._ts2) / this._ts) - 1;
- break;
- case 1:
- this._char_y += _loc22_;
- _root.hero_step.start();
- _loc7_ = _loc16_((this._char_y + this._map_y + this._tsh2) / this._tsh);
- }
- }
- }
- if(this._lvls[_loc6_][_loc7_ + 1] == 0 && this._lvls[_loc6_][_loc7_ + 2] == 0)
- {
- if(this._csy > 0)
- {
- this._csy = 0;
- }
- }
- if(Math.abs(this._char_xaspeed) < 4)
- {
- this._char_xaspeed = 0;
- }
- else
- {
- this._char_xaspeed *= 0.86;
- }
- if(_loc11_ > this._char_run)
- {
- _loc11_ = this._char_run;
- }
- if(_loc11_ < - this._char_run)
- {
- _loc11_ = - this._char_run;
- }
- if(_loc7_ < 0)
- {
- _root.hero_fall.start();
- this.lose_game(0);
- return true;
- }
- if(this._lvls[_loc6_][_loc7_ + 1] > 1)
- {
- this.add_scores(_loc6_,_loc7_ + 1);
- this.redt = true;
- }
- if(this._lvls[_loc6_][_loc7_] > 1)
- {
- this.add_scores(_loc6_,_loc7_);
- this.redt = true;
- }
- if(this._lvls[_loc6_][_loc7_] == "z")
- {
- if(Helper.TIPS_BY_EVENT)
- {
- _root.show_tip(5);
- }
- if(this._ready)
- {
- if(this.last_lvl)
- {
- this.OpenWinnerWindow();
- }
- else
- {
- this.OpenWinnerWindow();
- }
- return true;
- }
- }
- if(_loc45_ == "h")
- {
- if(this._lvls_tip[_loc6_][_loc7_] != undefined)
- {
- trace("show_tip: " + this._lvls_tip[_loc6_][_loc7_]);
- if(_root.show_tip(this._lvls_tip[_loc6_][_loc7_]))
- {
- if(this._canim == 2)
- {
- this._canim = 1;
- }
- }
- }
- this._lvls[_loc6_][_loc7_] = "H";
- this.redt = true;
- }
- if(this._char_x > 220 && _loc11_ > 0 && this._map_x <= this._map_x_max || this._char_x < 140 && _loc11_ < 0 && this._map_x >= 0)
- {
- this._map_x += _loc11_;
- this.move_bg(_loc11_);
- this.redt = true;
- }
- else if(this._char_x > 200 && _loc11_ > 0 && this._map_x <= this._map_x_max || this._char_x < 160 && _loc11_ < 0 && this._map_x >= 0)
- {
- this._char_x += _loc11_ * 0.33;
- this._map_x += _loc11_ * 0.66;
- this.move_bg(_loc11_ * 0.66);
- this.redt = true;
- }
- else if(this._char_x > 180 && _loc11_ > 0 && this._map_x <= this._map_x_max || this._char_x < 180 && _loc11_ < 0 && this._map_x >= 0)
- {
- _loc11_ /= 2;
- this._char_x += _loc11_;
- this._map_x += _loc11_;
- this.move_bg(_loc11_);
- this.redt = true;
- }
- else if(this._char_on_elev && _loc38_ != 0 && (this._char_x > 200 || this._char_x < 160))
- {
- this._char_x += _loc11_ - _loc38_;
- this._map_x += _loc38_;
- this.move_bg(_loc38_);
- this.redt = true;
- }
- else
- {
- this._char_x += _loc11_;
- }
- if(Math.abs(this._csy) < 0.2)
- {
- this._csy = 0;
- }
- else
- {
- this._csy *= 0.92;
- }
- var _loc37_ = !!this._char_on_elev ? - _loc42_ : this._csy;
- if(this._char_y > 180 && (this._csy > 0 || this._char_on_elev) || this._char_y < 100 && (this._csy < 0 || this._char_on_elev) && this._map_y > 0)
- {
- this._map_y += _loc37_;
- this.redt = true;
- }
- else if(this._char_y > 150 && (this._csy > 0 || this._char_on_elev) || this._char_y < 150 && (this._csy < 0 || this._char_on_elev) && this._map_y > 0)
- {
- _loc37_ /= 2;
- this._map_y += _loc37_;
- this._char_y += _loc37_;
- this.redt = true;
- }
- else
- {
- this._char_y += _loc37_;
- }
- if(this._map_y < 0)
- {
- this._map_y = 0;
- }
- if(this.redt)
- {
- this.show_tiles();
- this.redt = false;
- }
- _root.main.char._x = this._char_x;
- _root.main.char._y = this._game_height - this._char_y;
- _root.main.char.gotoAndStop(this._canim);
- _root.main.gfx_scr._x = - this._map_x;
- _root.main.gfx_scr._y = this._map_y;
- this.monsters_move();
- this.coconuts_move();
- this.UpdateWaterLevel();
- this.show_arrow();
- if(this._cund > 0)
- {
- this._cund = this._cund - 1;
- if(this._char_alpha < 100)
- {
- this._char_alpha = 100;
- }
- else
- {
- this._char_alpha = 30;
- }
- _root.main.char._alpha = this._char_alpha;
- }
- }
- function add_scores(x, y)
- {
- var _loc3_ = Number(this._lvls[x][y] / 1);
- switch(_loc3_)
- {
- case 2:
- _root.pick_hp.start();
- this._char_lives = this._char_lives + 1;
- _root.main.face_scr.lives = this._char_lives;
- break;
- case 3:
- _root.pick_hp.start();
- this._add_hp();
- break;
- case 4:
- break;
- case 5:
- _root.pick_diam.start();
- this._add_diam();
- break;
- case 6:
- _root.pick_gsmall.start();
- this._add_scores(10);
- break;
- case 7:
- _root.pick_gbig.start();
- this._add_scores(50);
- break;
- case 8:
- _root.pick_gbig.start();
- this._add_scores(100);
- break;
- case 9:
- _root.pick_gbig.start();
- this._add_scores(300);
- break;
- case 11:
- _root.pick_gbig.start();
- this._add_scores(500);
- break;
- case 12:
- _root.pick_gbig.start();
- this._add_scores(1000);
- this._stars_collecled = this._stars_collecled + 1;
- break;
- default:
- trace("Get UNKNOWN bonus: " + _loc3_);
- }
- this.add_explosion(this.get_x_scr(x),this.get_y_scr(y),1);
- this._lvls[x][y] = 1;
- this.get_nearest_diam();
- }
- function _add_mp()
- {
- this.add_mp(this._cmp_max * 0.5);
- }
- function _add_hp()
- {
- this.add_hp(1);
- }
- function _add_diam()
- {
- if(this._diams == 0 && this._current_map == 0)
- {
- if(Helper.TIPS_BY_EVENT)
- {
- _root.show_tip(1);
- }
- }
- if(this._diams == 2 && this._current_map == 0)
- {
- if(Helper.TIPS_BY_EVENT)
- {
- _root.show_tip(2);
- }
- }
- this._diams = this._diams + 1;
- this.redt = true;
- _root.main.face_scr.diamshine_mc.play();
- if(this._diams >= this._max_diams && !this._ready)
- {
- _root.main.face_scr.win_scr._visible = true;
- _root.main.face_scr.attachMovie("win_txt","win_txt",_root.win_depth,{_x:40,_y:60});
- this._ready = true;
- }
- _root.main.face_scr.mcDimonds.SetValue(this._diams);
- }
- function _add_scores(scores)
- {
- if(this._scores > 0)
- {
- if(Helper.TIPS_BY_EVENT)
- {
- _root.show_tip(0);
- }
- }
- this._scores += scores;
- _level0.swHighScoreObject.player1Score = this._scores;
- _root.main.face_scr.scores = this._scores;
- _root.main.face_scr.moneyshine_mc.play();
- }
- function get_x_scr(x)
- {
- return x * this._ts + this._ts2;
- }
- function get_y_scr(y)
- {
- return this._game_height - (y * this._tsh + this._tsh2);
- }
- function move_bg(step)
- {
- }
- function show_bg()
- {
- _root.main.createEmptyMovieClip("bg_scr",_root.bg_depth);
- _root.main.bg_scr.attachMovie("bg_scr","bg_scr",_root.bg_depth + 1);
- }
- function show_tiles()
- {
- var _loc33_ = this.DRAW_ZONE_W - this.DRAW_ZONE_X0;
- var _loc34_ = this.DRAW_ZONE_H - this.DRAW_ZONE_Y0;
- var _loc4_ = 0;
- var _loc5_ = "";
- var _loc7_ = undefined;
- var _loc29_ = Math.round(this._map_x / this.TILEW);
- var _loc28_ = Math.round(this._map_y / this.TILEH);
- var _loc36_ = true;
- var _loc22_ = true;
- if(this._prev_drawed_x == _loc29_ && this._prev_drawed_y == _loc28_)
- {
- var _loc31_ = this.get_x_scr(this._prev_drawed_x) - this._map_x;
- var _loc30_ = this.get_y_scr(this._prev_drawed_y) - this._map_y;
- var _loc12_ = _loc31_ - this._prev_drawed_xpix;
- var _loc32_ = _loc30_ - this._prev_drawed_ypix;
- _root.main.ts_mc_static._x += _loc12_;
- _root.main.ts_mc_static._y -= _loc32_;
- this._prev_drawed_xpix = _loc31_;
- this._prev_drawed_ypix = _loc30_;
- _loc22_ = false;
- }
- else
- {
- this._prev_drawed_x = _loc29_;
- this._prev_drawed_y = _loc28_;
- this._prev_drawed_xpix = this.get_x_scr(this._prev_drawed_x) - this._map_x;
- this._prev_drawed_ypix = this.get_y_scr(this._prev_drawed_y) - this._map_y;
- _root.main.createEmptyMovieClip("ts_mc_static",-600);
- }
- var _loc23_ = _root.main.ts_mc_static;
- var _loc6_ = _root.main.createEmptyMovieClip("ts_mc",-300);
- var _loc35_ = _root.main.createEmptyMovieClip("ts2_mc",8000);
- var x;
- var y;
- var _loc26_ = this.DRAW_ZONE_Y0 + _loc28_;
- var _loc25_ = this.DRAW_ZONE_X0 + _loc29_;
- var _loc27_ = _loc34_ + _loc28_;
- var _loc24_ = _loc33_ + _loc29_;
- y = _loc26_;
- while(y < _loc27_)
- {
- x = _loc25_;
- for(; x < _loc24_; x++)
- {
- var _loc9_ = this._lvls[x][y];
- var _loc8_ = this._lvls_gfxbg[x][y];
- if(_loc8_[0] != 0)
- {
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- var _loc13_ = _loc8_[1];
- _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y + _loc8_[3],_xscale:_loc8_[1],_yscale:_loc13_});
- if(_loc8_[2] != 2)
- {
- _loc6_.attachMovie("tiles_decor" + _loc8_[0],_loc5_,_root["decor_depth" + _loc8_[2]] / 1 + _loc4_,_loc7_);
- }
- else
- {
- _root.main.ts2_mc.attachMovie("tiles_decor" + _loc8_[0],_loc5_,_root["decor_depth" + _loc8_[2]] / 1 + _loc4_,_loc7_);
- }
- }
- var _loc11_ = _loc9_ / 1 + 1;
- if(_loc22_ && this._lvls_type[x][y] != 0)
- {
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- var _loc15_ = Math.floor(this.get_x_scr(x) - this._map_x);
- var _loc14_ = Math.floor(this.get_y_scr(y) + this._map_y);
- _loc7_ = new Object({_x:_loc15_,_y:_loc14_});
- var _loc10_ = _loc23_.attachMovie("tiles_ground" + this._lvls_type[x][y],_loc5_,_root.tiles_depth + _loc4_,_loc7_);
- if(this._lvls_rot[x][y] > 0)
- {
- _loc10_._rotation -= 90 * this._lvls_rot[x][y];
- }
- if(this._lvls_flip[x][y] > 0)
- {
- if(this._lvls_flip[x][y] == 1)
- {
- _loc10_._xscale = -100;
- }
- else if(this._lvls_flip[x][y] == 2)
- {
- _loc10_._yscale = -100;
- }
- }
- continue;
- }
- if(_loc9_ == undefined || _loc9_ == 1)
- {
- continue;
- }
- switch(_loc9_)
- {
- case "e":
- this.add_elevator("e",x,y,_loc4_);
- break;
- case "t":
- this.add_elevator("t",x,y,_loc4_);
- break;
- case "o":
- this.add_elevator("o",x,y,_loc4_);
- break;
- case "r":
- case "p":
- case "y":
- case "E":
- case "T":
- case "O":
- if(Helper.DEBUG_MAP)
- {
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(12);
- }
- break;
- case "a":
- _loc4_ = _loc4_ + 1;
- this.add_monster("a",x,y,_loc4_);
- break;
- case "s":
- _loc4_ = _loc4_ + 1;
- this.add_monster("s",x,y,_loc4_);
- break;
- case "d":
- _loc4_ = _loc4_ + 1;
- this.add_monster("d",x,y,_loc4_);
- break;
- case "u":
- _loc4_ = _loc4_ + 1;
- this.add_monster("u",x,y,_loc4_);
- break;
- case CGame.MONSTER_FISH3_KEY:
- _loc4_ = _loc4_ + 1;
- this.add_monster(CGame.MONSTER_FISH3_KEY,x,y,_loc4_);
- break;
- case CGame.MONSTER_FISH1_KEY:
- _loc4_ = _loc4_ + 1;
- this.add_monster(CGame.MONSTER_FISH1_KEY,x,y,_loc4_);
- break;
- case "g":
- _loc4_ = _loc4_ + 1;
- this.add_coconut("g",x,y,_loc4_);
- break;
- case "j":
- _loc4_ = _loc4_ + 1;
- this.add_coconut("j",x,y,_loc4_);
- break;
- case "@":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(13);
- break;
- case "-":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(21);
- break;
- case "#":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(14);
- break;
- case "=":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(22);
- break;
- case "$":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(15);
- break;
- case "(":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(19);
- break;
- case ")":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(20);
- break;
- case "%":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(17);
- break;
- case "^":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(18);
- break;
- case "z":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y + this.TILEH / 2});
- _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
- if(this._ready)
- {
- _loc6_[_loc5_].gotoAndStop(3);
- }
- else
- {
- _loc6_[_loc5_].gotoAndStop(2);
- _loc6_[_loc5_].body.indicator.Value = this._diams;
- }
- break;
- case "x":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(4);
- _loc6_[_loc5_].body.gotoAndPlay(_global._tc);
- break;
- case "m":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(5);
- _loc6_[_loc5_].body.gotoAndPlay(_global._tc);
- break;
- case "n":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(8);
- _loc6_[_loc5_].onEnterFrame = function()
- {
- var _loc3_ = Math.random() * this.TILEW - this.TILEW / 2;
- _root.main.game.add_buble(this.x + _loc3_,this.y + this.TILEH / 2);
- };
- break;
- case "q":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
- _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(9);
- break;
- case "w":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
- _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(10);
- break;
- case "v":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y + this.TILEH / 1.5});
- _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(6);
- break;
- case "b":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y + this.TILEH / 1.5});
- _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(7);
- break;
- case "h":
- if(_global.show_tips)
- {
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(11);
- _loc6_[_loc5_].body.gotoAndPlay(_global._tc);
- }
- break;
- case "k":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("tiles1_bonuses",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(10);
- _loc6_[_loc5_].body2.gotoAndPlay(_global._tc);
- break;
- case "f":
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("tiles1_bonuses",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(11);
- _loc6_[_loc5_].body2.gotoAndPlay(_global._tc);
- break;
- default:
- if(_loc11_ > 2)
- {
- _loc4_ = _loc4_ + 1;
- _loc5_ = "tiles" + _loc4_;
- _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _loc6_.attachMovie("tiles1_bonuses",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
- _loc6_[_loc5_].gotoAndStop(_loc11_ - 2);
- _loc6_[_loc5_].body2.gotoAndPlay(_global._tc);
- }
- break;
- }
- }
- y++;
- }
- }
- function show_last_screen()
- {
- var _loc19_ = 400 / this.TILEW;
- var _loc20_ = 300 / this.TILEH;
- _root.createEmptyMovieClip("ts_mc",_root.last_bg_depth);
- var _loc5_ = 0;
- var _loc4_ = "";
- var _loc6_ = undefined;
- var _loc12_ = -1;
- while(_loc12_ < _loc20_ + 1)
- {
- var _loc9_ = -1;
- while(_loc9_ < _loc19_ + 1)
- {
- var x = _loc9_ + Math.round(this._map_x / this.TILEW);
- var y = _loc12_ + Math.round(this._map_y / this.TILEH);
- var _loc7_ = this._lvls[x][y];
- var _loc8_ = this._lvls_gfxbg[x][y];
- if(_loc8_[0] != 0)
- {
- _loc5_ = _loc5_ + 1;
- _loc4_ = "tiles" + _loc5_;
- _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y - 10 + _loc8_[3],_xscale:_loc8_[1],_yscale:_loc8_[1]});
- if(_loc8_[2] != 2)
- {
- _root.main.ts_mc.attachMovie("tiles_decor" + _loc8_[0],_loc4_,_root["decor_depth" + _loc8_[2]] / 1 + _loc5_,_loc6_);
- }
- else
- {
- _root.main.ts2_mc.attachMovie("tiles_decor" + _loc8_[0],_loc4_,_root["decor_depth" + _loc8_[2]] / 1 + _loc5_,_loc6_);
- }
- }
- var _loc10_ = _loc7_ / 1 + 1;
- if(this._lvls_type[x][y] != 0)
- {
- _loc5_ = _loc5_ + 1;
- _loc4_ = "tiles" + _loc5_;
- _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
- _root.ts_mc.attachMovie("tiles_ground" + this._lvls_type[x][y],_loc4_,_root.tiles_depth + _loc5_,_loc6_);
- if(this._lvls_rot[x][y] > 0)
- {
- _root.ts_mc[_loc4_]._rotation -= 90 * this._lvls_rot[x][y];
- }
- }
- else if(_loc7_ == "a")
- {
- this.add_monster("a",x,y);
- }
- else if(_loc7_ == "s")
- {
- this.add_monster("s",x,y);
- }
- else if(_loc7_ == "d")
- {
- this.add_monster("d",x,y);
- }
- else if(_loc7_ == "z")
- {
- _loc5_ = _loc5_ + 1;
- _loc4_ = "tiles" + _loc5_;
- _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y + this.TILEH / 2,_width:this.TILEW,_height:this.TILEH});
- _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
- if(this._ready)
- {
- _root.ts_mc[_loc4_].gotoAndStop(3);
- }
- else
- {
- _root.ts_mc[_loc4_].gotoAndStop(2);
- }
- }
- else if(_loc7_ == "x")
- {
- _loc5_ = _loc5_ + 1;
- _loc4_ = "tiles" + _loc5_;
- _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
- _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
- _root.ts_mc[_loc4_].gotoAndStop(4);
- _root.ts_mc[_loc4_].body.gotoAndPlay(_global._tc);
- }
- else if(_loc7_ == "m")
- {
- _loc5_ = _loc5_ + 1;
- _loc4_ = "tiles" + _loc5_;
- _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
- _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
- _root.ts_mc[_loc4_].gotoAndStop(5);
- _root.ts_mc[_loc4_].body.gotoAndPlay(_global._tc);
- }
- else if(_loc7_ == "n")
- {
- _loc5_ = _loc5_ + 1;
- _loc4_ = "tiles" + _loc5_;
- _loc6_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
- _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
- _root.ts_mc[_loc4_].gotoAndStop(8);
- _root.ts_mc[_loc4_].onEnterFrame = function()
- {
- var _loc3_ = Math.random() * this.TILEW - this.TILEW / 2;
- _root.game.add_buble(this.x + _loc3_,this.y + this.TILEH / 2);
- };
- }
- else if(_loc7_ == "q")
- {
- _loc5_ = _loc5_ + 1;
- _loc4_ = "tiles" + _loc5_;
- _loc6_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
- _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
- _root.ts_mc[_loc4_].gotoAndStop(9);
- }
- else if(_loc7_ == "w")
- {
- _loc5_ = _loc5_ + 1;
- _loc4_ = "tiles" + _loc5_;
- _loc6_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
- _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
- _root.ts_mc[_loc4_].gotoAndStop(10);
- }
- else if(_loc7_ == "v")
- {
- _loc5_ = _loc5_ + 1;
- _loc4_ = "tiles" + _loc5_;
- _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y + this.TILEH / 1.5,_width:this.TILEW,_height:this.TILEH});
- _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
- _root.ts_mc[_loc4_].gotoAndStop(6);
- _root.show_tip(6);
- }
- else if(_loc7_ == "b")
- {
- _loc5_ = _loc5_ + 1;
- _loc4_ = "tiles" + _loc5_;
- _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y + this.TILEH / 1.5,_width:this.TILEW,_height:this.TILEH});
- _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
- _root.ts_mc[_loc4_].gotoAndStop(7);
- }
- else if(_loc10_ > 2)
- {
- _loc5_ = _loc5_ + 1;
- _loc4_ = "tiles" + _loc5_;
- _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
- _root.ts_mc.attachMovie("tiles1_bonuses",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
- _root.ts_mc[_loc4_].gotoAndStop(_loc10_ - 2);
- _root.ts_mc[_loc4_].body2.gotoAndPlay(_global._tc);
- }
- _loc9_ = _loc9_ + 1;
- }
- _loc12_ = _loc12_ + 1;
- }
- this.redt = false;
- }
- function get_max_diams()
- {
- var _loc4_ = 0;
- var _loc3_ = 0;
- while(_loc3_ < this.maxtiles_x)
- {
- var _loc2_ = 0;
- while(_loc2_ < this.maxtiles_y)
- {
- if(this._lvls[_loc3_][_loc2_] == "5")
- {
- _loc4_ = _loc4_ + 1;
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- return _loc4_;
- }
- function get_start_x()
- {
- var _loc3_ = 0;
- while(_loc3_ < this.maxtiles_x)
- {
- var _loc2_ = 0;
- while(_loc2_ < this.maxtiles_y)
- {
- if(this._lvls[_loc3_][_loc2_] == "q")
- {
- return _loc3_;
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- }
- function get_start_y()
- {
- var _loc3_ = 0;
- while(_loc3_ < this.maxtiles_x)
- {
- var _loc2_ = 0;
- while(_loc2_ < this.maxtiles_y)
- {
- if(this._lvls[_loc3_][_loc2_] == "q")
- {
- return _loc2_;
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- }
- function set_tiles_angle(onlyvisible)
- {
- if(onlyvisible == undefined)
- {
- onlyvisible = false;
- }
- var _loc9_ = this.DRAW_ZONE_W;
- var _loc10_ = this.DRAW_ZONE_H;
- var _loc7_ = 0;
- var _loc5_ = 0;
- var _loc8_ = this.maxtiles_x;
- var _loc6_ = this.maxtiles_y;
- if(onlyvisible && CGame.IS_LEVEL_EDITOR)
- {
- _loc7_ = -1 + Math.round(this._map_x / this._tile_size);
- _loc5_ = -1 + Math.round(this._map_y / this._tile_sizeh);
- _loc8_ = _loc7_ + _loc9_ + 5;
- _loc6_ = _loc5_ + _loc10_ + 5;
- }
- var _loc4_ = _loc7_;
- while(_loc4_ < _loc8_)
- {
- var _loc2_ = _loc5_;
- while(_loc2_ < _loc6_)
- {
- if(this._lvls[_loc4_][_loc2_] == 0)
- {
- var _loc3_ = this.get_tile_angle(_loc4_,_loc2_);
- this._lvls_type[_loc4_][_loc2_] = _loc3_[0];
- this._lvls_rot[_loc4_][_loc2_] = _loc3_[1] / 1 - 1;
- this._lvls_flip[_loc4_][_loc2_] = _loc3_[2] == undefined ? 0 : _loc3_[2];
- }
- else
- {
- this._lvls_type[_loc4_][_loc2_] = 0;
- if(!CGame.IS_LEVEL_EDITOR)
- {
- if(this._lvls[_loc4_][_loc2_] == "k")
- {
- this._lvls[_loc4_][_loc2_] = 11;
- }
- else if(this._lvls[_loc4_][_loc2_] == "f")
- {
- this._lvls[_loc4_][_loc2_] = 12;
- }
- }
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- _loc4_ = _loc7_;
- while(_loc4_ < _loc8_)
- {
- _loc2_ = _loc5_;
- while(_loc2_ < _loc6_)
- {
- if(this._lvls_type[_loc4_][_loc2_] == 1 && this._lvls_type[_loc4_][_loc2_ + 1] == 7)
- {
- this._lvls_type[_loc4_][_loc2_] = 15;
- }
- else if(this._lvls_type[_loc4_][_loc2_] == 2 && this._lvls_type[_loc4_][_loc2_ + 1] == 8 && this._lvls_type[_loc4_ - 1][_loc2_] == 0)
- {
- this._lvls_type[_loc4_][_loc2_] = 19;
- }
- else if(this._lvls_type[_loc4_][_loc2_] == 2 && this._lvls_type[_loc4_][_loc2_ + 1] == 9 && this._lvls_type[_loc4_ + 1][_loc2_] == 0)
- {
- this._lvls_type[_loc4_][_loc2_] = 19;
- this._lvls_flip[_loc4_][_loc2_] = 1;
- this._lvls_rot[_loc4_][_loc2_] = 0;
- }
- else if(this._lvls_type[_loc4_][_loc2_] == 7 && this._lvls_type[_loc4_ - 1][_loc2_] != 0 && this._lvls_type[_loc4_][_loc2_ + 1] == 0 && this._lvls_type[_loc4_ + 1][_loc2_ + 1] != 0)
- {
- this._lvls_type[_loc4_][_loc2_] = 17;
- }
- else if(this._lvls_type[_loc4_][_loc2_] == 7 && this._lvls_type[_loc4_ + 1][_loc2_] != 0 && this._lvls_type[_loc4_][_loc2_ + 1] == 0 && this._lvls_type[_loc4_ - 1][_loc2_ + 1] != 0)
- {
- this._lvls_type[_loc4_][_loc2_] = 17;
- this._lvls_flip[_loc4_][_loc2_] = 1;
- this._lvls_rot[_loc4_][_loc2_] = 0;
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- _loc4_ = _loc7_;
- while(_loc4_ < _loc8_)
- {
- _loc2_ = _loc5_;
- while(_loc2_ < _loc6_)
- {
- if(this._lvls_type[_loc4_][_loc2_] == 1 && this._lvls_type[_loc4_][_loc2_ + 1] != 0 && this._lvls_type[_loc4_ - 1][_loc2_ + 1] == 0 && this._lvls_type[_loc4_ - 1][_loc2_] == 17)
- {
- this._lvls_type[_loc4_][_loc2_] = 16;
- }
- else if(this._lvls_type[_loc4_][_loc2_] == 1 && this._lvls_type[_loc4_][_loc2_ + 1] != 0 && this._lvls_type[_loc4_ + 1][_loc2_ + 1] == 0 && this._lvls_type[_loc4_ + 1][_loc2_] == 17)
- {
- this._lvls_type[_loc4_][_loc2_] = 16;
- this._lvls_flip[_loc4_][_loc2_] = 1;
- this._lvls_rot[_loc4_][_loc2_] = 0;
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- _loc4_ = _loc7_;
- while(_loc4_ < _loc8_)
- {
- _loc2_ = _loc5_;
- while(_loc2_ < _loc6_)
- {
- if(this._lvls_type[_loc4_][_loc2_] == 1 && this._lvls_type[_loc4_][_loc2_ + 1] == 16 && this._lvls_type[_loc4_ - 1][_loc2_ + 1] == 17 && this._lvls_type[_loc4_ - 1][_loc2_] == 15)
- {
- this._lvls_type[_loc4_][_loc2_] = 18;
- }
- else if(this._lvls_type[_loc4_][_loc2_] == 1 && this._lvls_type[_loc4_][_loc2_ + 1] == 16 && this._lvls_type[_loc4_ + 1][_loc2_ + 1] == 17 && this._lvls_type[_loc4_ + 1][_loc2_] == 15)
- {
- this._lvls_type[_loc4_][_loc2_] = 18;
- this._lvls_flip[_loc4_][_loc2_] = 1;
- this._lvls_rot[_loc4_][_loc2_] = 0;
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- _loc4_ = _loc7_;
- while(_loc4_ < _loc8_)
- {
- _loc2_ = _loc5_;
- while(_loc2_ < _loc6_)
- {
- if(this._lvls_type[_loc4_][_loc2_] == 1 && this._lvls_type[_loc4_][_loc2_ - 1] == 1)
- {
- this._lvls_type[_loc4_][_loc2_] = 13;
- this._lvls_type[_loc4_][_loc2_ - 1] = 0;
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- }
- function get_tile_angle(x, y)
- {
- if(this._lvls[x - 1][y] == 0 || this._lvls[x - 1][y] == undefined)
- {
- if(this._lvls[x + 1][y] == 0 || this._lvls[x + 1][y] == undefined)
- {
- if(this._lvls[x][y + 1] == 0 || this._lvls[x][y + 1] == undefined)
- {
- if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
- {
- return [1,1];
- }
- return [20,1];
- }
- if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
- {
- if(this._lvls[x - 1][y - 1] != 0 && this._lvls[x - 1][y - 1] != undefined)
- {
- return [8,1];
- }
- if(this._lvls[x + 1][y - 1] != 0)
- {
- return [9,1];
- }
- return [7,1];
- }
- if(this._lvls[x - 1][y - 1] == 0)
- {
- return [11,1];
- }
- if(this._lvls[x + 1][y - 1] == 0)
- {
- return [12,1];
- }
- return [10,1];
- }
- if(this._lvls[x][y + 1] == 0 || this._lvls[x][y + 1] == undefined)
- {
- if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
- {
- return [2,3];
- }
- return [21,1,1];
- }
- if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
- {
- return [9,1];
- }
- return [12,1];
- }
- if(this._lvls[x + 1][y] == 0 || this._lvls[x + 1][y] == undefined)
- {
- if(this._lvls[x][y + 1] == 0 || this._lvls[x][y + 1] == undefined)
- {
- if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
- {
- return [2,1];
- }
- return [21,1];
- }
- if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
- {
- return [8,1];
- }
- return [11,1];
- }
- if(this._lvls[x][y + 1] == 0 || this._lvls[x][y + 1] == undefined)
- {
- if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
- {
- return [3,1];
- }
- return [1,1];
- }
- if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
- {
- return [1,1];
- }
- return [1,1];
- }
- function generate_gfxbg()
- {
- var _loc11_ = new Array(1,2,3);
- var _loc10_ = new Array(4,5,6);
- var _loc7_ = 0;
- var _loc4_ = undefined;
- var _loc5_ = undefined;
- var _loc6_ = undefined;
- var _loc8_ = undefined;
- var _loc9_ = undefined;
- var _loc3_ = 0;
- while(_loc3_ < this.maxtiles_y)
- {
- _loc9_ = _loc3_ < this.waterlevel_tiley / this._tsh;
- var _loc2_ = 0;
- while(_loc2_ < this.maxtiles_x)
- {
- _loc4_ = 0;
- _loc5_ = 1;
- _loc6_ = 0;
- _loc8_ = 1;
- if(Math.random() > 0.8 && this._lvls[_loc2_ + 1][_loc3_] == 0 && this._lvls[_loc2_ - 1][_loc3_] == 0 && this._lvls[_loc2_][_loc3_] == 0 && this._lvls[_loc2_][_loc3_ + 1] != 0 && this._lvls[_loc2_][_loc3_ + 1] != "z")
- {
- if(Math.random() > 0.7)
- {
- _loc5_ = 1;
- }
- else
- {
- _loc5_ = 2;
- _loc6_ = 4;
- }
- }
- if(this._lvls[_loc2_][_loc3_ - 1] == 0)
- {
- if(Math.random() > 0.3 && this._lvls[_loc2_][_loc3_] == 0 && this._lvls[_loc2_][_loc3_ + 1] != 0 && this._lvls[_loc2_][_loc3_ + 1] != "z")
- {
- if(Math.random() > 0.3 && this._lvls[_loc2_ + 1][_loc3_] == 0 && this._lvls[_loc2_ - 1][_loc3_] == 0 && this._lvls_gfxbg[_loc2_ - 1][_loc3_][0] == 0)
- {
- _loc4_ = Helper.GetRandomFromArray(!!_loc9_ ? _loc10_ : _loc11_);
- }
- }
- }
- if(_loc7_ == _loc4_)
- {
- _loc4_ = 0;
- }
- if(_loc4_ != 0)
- {
- _loc7_ = _loc4_;
- }
- this._lvls_gfxbg[_loc2_][_loc3_] = [_loc4_,(100 - random(20)) * _loc8_,_loc5_,_loc6_];
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- }
- function monsters_move()
- {
- var _loc20_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes.length;
- var _loc5_ = 0;
- for(; _loc5_ < _loc20_; _loc5_ = _loc5_ + 1)
- {
- var _loc2_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[_loc5_].attributes;
- if(_loc2_.x - this._map_x < -100 || _loc2_.x - this._map_x > 500)
- {
- if(this.hide_monster(_loc5_,_loc2_.x / 1,_loc2_.y / 1))
- {
- continue;
- }
- }
- switch(_loc2_.type)
- {
- case "a":
- case "d":
- case "u":
- case CGame.MONSTER_FISH3_KEY:
- var _loc3_ = Number(_loc2_.side / 1);
- var _loc8_ = _loc2_.x / 1 + _loc3_ * _loc2_.speed;
- var _loc11_ = _loc2_.y / 1;
- var _loc7_ = Math.round((_loc8_ - this._tile_size / 2 - _loc3_ * this._tile_size / 2) / this._tile_size);
- var _loc6_ = Math.round((- _loc11_ - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
- if(_loc8_ - this._map_x < -100)
- {
- this.hide_monster(_loc5_,_loc7_,_loc6_);
- }
- else
- {
- if((_loc0_ = _loc2_.type) !== CGame.MONSTER_FISH3_KEY)
- {
- if(this._lvls[_loc7_ + _loc3_][_loc6_] == 0 || this._lvls[_loc7_ + _loc3_][_loc6_ - 1] != 0)
- {
- _loc2_.side *= -1;
- return false;
- }
- }
- else if(this._lvls[_loc7_ + _loc3_][_loc6_] == 0)
- {
- _loc2_.side *= -1;
- return false;
- }
- _loc2_.x = _loc8_;
- _loc2_.y = _loc11_;
- }
- break;
- case CGame.MONSTER_FISH1_KEY:
- if(_loc2_.targetx == undefined)
- {
- _loc2_.targetx = Math.random() * CGame.MONSTER_FISH1_ZONE_W * 2 - CGame.MONSTER_FISH1_ZONE_W;
- _loc2_.targety = Math.random() * CGame.MONSTER_FISH1_ZONE_H * 2 - CGame.MONSTER_FISH1_ZONE_H;
- }
- var _loc18_ = Math.round((_loc2_.x - this._tile_size / 2) / this._tile_size);
- var _loc17_ = Math.round((- _loc2_.y - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
- var _loc15_ = _loc2_.targetx;
- var _loc13_ = _loc2_.targety;
- var _loc9_ = Math.atan2(_loc13_,_loc15_);
- var _loc10_ = _loc2_.speed * Math.cos(_loc9_);
- var _loc14_ = (- _loc2_.speed) * Math.sin(_loc9_);
- _loc2_.side = _loc10_ < 0 ? -1 : 1;
- _loc8_ = _loc2_.x / 1 + _loc10_;
- _loc11_ = _loc2_.y / 1 + _loc14_;
- _loc7_ = Math.round((_loc8_ - this._tile_size / 2) / this._tile_size);
- _loc6_ = Math.round((- _loc11_ - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
- if(_loc8_ - this._map_x < -100)
- {
- this.hide_monster(_loc5_,_loc7_,_loc6_);
- }
- else if(this._lvls[_loc7_][_loc6_] == 0 || Math.abs(_loc7_ - _loc2_.init_tx) >= CGame.MONSTER_FISH1_ZONE_W || Math.abs(_loc6_ - _loc2_.init_ty) >= CGame.MONSTER_FISH1_ZONE_H)
- {
- _loc2_.targetx = undefined;
- }
- else
- {
- _loc2_.x = _loc8_;
- _loc2_.y = _loc11_;
- }
- break;
- case "s":
- if(_loc2_.speed > 60)
- {
- _loc2_.speed = 1;
- }
- else
- {
- _loc2_.speed = _loc2_.speed + 1;
- }
- break;
- }
- }
- _loc5_ = 0;
- while(_loc5_ < this.monsters_to_die.length)
- {
- var _loc4_ = this.monsters_to_die[_loc5_];
- _loc4_.y += CGame.GAME_GRAVITY * 12;
- var _loc12_ = _loc4_.x - this._map_x;
- var _loc16_ = _loc4_.y - this._map_y;
- if(_loc12_ < -100 || _loc12_ > 500 || _loc16_ > 350)
- {
- _loc4_.killed = true;
- }
- _loc5_ = _loc5_ + 1;
- }
- var _loc19_ = new Array();
- _loc5_ = 0;
- while(_loc5_ < this.monsters_to_die.length)
- {
- if(!this.monsters_to_die[_loc5_].killed)
- {
- _loc19_.push(this.monsters_to_die[_loc5_]);
- }
- _loc5_ = _loc5_ + 1;
- }
- this.monsters_to_die = _loc19_;
- this.show_monsters();
- }
- function show_monsters()
- {
- _root.main.gfx_scr.createEmptyMovieClip("monsters_scr",_root.monsters_depth);
- _root.main.gfx_scr.createEmptyMovieClip("monsters2_scr",_root.monsters_hiden_depth);
- var _loc13_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes.length;
- var _loc6_ = 0;
- for(; _loc6_ < _loc13_; _loc6_ = _loc6_ + 1)
- {
- var _loc4_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[_loc6_].attributes;
- var _loc9_ = "monster" + _loc6_;
- var _loc10_ = new Object({_x:_loc4_.x,_y:_loc4_.y + this._tile_sizeh / 4});
- var _loc5_ = 2;
- if(_loc4_.type == "s")
- {
- _loc5_ = 3;
- if(_loc4_.speed > 12)
- {
- _root.main.gfx_scr.monsters2_scr.attachMovie("tiles_monsters",_loc9_,_root.monsters_depth + 1 + _loc6_,_loc10_);
- _root.main.gfx_scr.monsters2_scr[_loc9_].gotoAndStop(_loc5_);
- _root.main.gfx_scr.monsters2_scr[_loc9_].body.gotoAndStop(1);
- continue;
- }
- }
- else if(_loc4_.type == "d")
- {
- _loc5_ = 4;
- }
- else if(_loc4_.type == "u")
- {
- _loc5_ = 5;
- }
- else if(_loc4_.type == CGame.MONSTER_FISH3_KEY)
- {
- _loc5_ = 6;
- }
- else if(_loc4_.type == CGame.MONSTER_FISH1_KEY)
- {
- _loc5_ = 7;
- }
- else if(_loc4_.type == "a")
- {
- _loc5_ = 2;
- }
- _root.main.gfx_scr.monsters_scr.attachMovie("tiles_monsters",_loc9_,_root.monsters_depth + 1 + _loc6_,_loc10_);
- _root.main.gfx_scr.monsters_scr[_loc9_].gotoAndStop(_loc5_);
- if(_loc5_ == 3)
- {
- _root.main.gfx_scr.monsters_scr[_loc9_].body.gotoAndStop(_loc4_.speed);
- }
- else
- {
- _root.main.gfx_scr.monsters_scr[_loc9_]._xscale = 100 * _loc4_.side;
- _root.main.gfx_scr.monsters_scr[_loc9_].body.gotoAndPlay(_global._tc);
- }
- }
- _root.main.gfx_scr.createEmptyMovieClip("monsters_killed_scr",_root.monsters_killed_depth);
- _loc6_ = 0;
- while(_loc6_ < this.monsters_to_die.length)
- {
- var _loc8_ = this.monsters_to_die[_loc6_];
- _loc5_ = 2;
- switch(_loc8_.type)
- {
- case "s":
- _loc5_ = 3;
- break;
- case "d":
- _loc5_ = 4;
- break;
- case "u":
- _loc5_ = 5;
- break;
- case CGame.MONSTER_FISH3_KEY:
- _loc5_ = 6;
- break;
- case CGame.MONSTER_FISH1_KEY:
- _loc5_ = 7;
- break;
- case "a":
- _loc5_ = 2;
- }
- _loc9_ = "monster_killed" + _loc6_;
- _root.main.gfx_scr.monsters_killed_scr.attachMovie("tiles_monsters",_loc9_,_root.monsters_killed_depth + 1 + _loc6_,{_x:_loc8_.x,_y:_loc8_.y + this._tile_sizeh / 4});
- var _loc7_ = _root.main.gfx_scr.monsters_killed_scr[_loc9_];
- _loc7_.gotoAndStop(_loc5_);
- _loc7_._yscale = -100;
- _loc7_._xscale = 100 * _loc8_.side;
- _loc7_.body.gotoAndPlay(_global._tc);
- _loc6_ = _loc6_ + 1;
- }
- }
- function add_monster(type_id, x, y)
- {
- var _loc6_ = new XML();
- var _loc3_ = _loc6_.createElement("mon");
- _loc3_.attributes.type = type_id;
- _loc3_.attributes.x = this.get_x_scr(x);
- _loc3_.attributes.y = this.get_y_scr(y);
- _loc3_.attributes.side = -1;
- _loc3_.attributes.speed = 1;
- if(type_id == "a")
- {
- _loc3_.attributes.speed = 0.5;
- }
- else if(type_id == "d")
- {
- _loc3_.attributes.speed = 3;
- if(Helper.TIPS_BY_EVENT)
- {
- _root.show_tip(7);
- }
- }
- else if(type_id == "u")
- {
- _loc3_.attributes.speed = CGame.MONSTER_ULITKA_SPEED;
- }
- else if(type_id == CGame.MONSTER_FISH3_KEY)
- {
- _loc3_.attributes.speed = CGame.MONSTER_FISH3_SPEED;
- }
- else if(type_id == CGame.MONSTER_FISH1_KEY)
- {
- _loc3_.attributes.speed = CGame.MONSTER_FISH1_SPEED;
- _loc3_.attributes.init_tx = x;
- _loc3_.attributes.init_ty = y;
- }
- this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].appendChild(_loc3_);
- if(Helper.TIPS_BY_EVENT)
- {
- _root.show_tip(4);
- }
- this._lvls[x][y] = 1;
- this.show_monsters();
- }
- function remove_monster(id)
- {
- var _loc2_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[id];
- _loc2_.removeNode();
- this.show_monsters();
- }
- function kill_monster(id)
- {
- trace("kill_monster " + id);
- var _loc3_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[id].attributes;
- var _loc2_ = new Object();
- _loc2_.x = _loc3_.x;
- _loc2_.y = _loc3_.y;
- _loc2_.side = _loc3_.side;
- _loc2_.type = _loc3_.type;
- _loc2_.yspeed = CGame.MONSTER_DEADFALL_YSPEED;
- _loc2_.killed = false;
- this.monsters_to_die.push(_loc2_);
- this.remove_monster(id);
- }
- function hide_monster(id, mx, my)
- {
- var _loc4_ = Math.round((mx - this._tile_size / 2) / this._tile_size);
- var _loc3_ = Math.round((- my - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
- if(this._lvls[_loc4_][_loc3_] == 1)
- {
- var _loc2_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[id].attributes;
- if(_loc2_.type == CGame.MONSTER_FISH1_KEY)
- {
- if(this._lvls[_loc2_.init_tx][_loc2_.init_ty] != 1)
- {
- return false;
- }
- this._lvls[_loc2_.init_tx][_loc2_.init_ty] = _loc2_.type;
- }
- else
- {
- this._lvls[_loc4_][_loc3_] = _loc2_.type;
- }
- this.remove_monster(id);
- return true;
- }
- return false;
- }
- function get_nearest_diam()
- {
- var _loc5_ = -1;
- var _loc4_ = -1;
- var _loc3_ = 0;
- while(_loc3_ < this.maxtiles_x)
- {
- var _loc2_ = this.maxtiles_y;
- while(_loc2_ > 0)
- {
- if(this._diams >= this._max_diams)
- {
- if(this._lvls[_loc3_][_loc2_] == "z")
- {
- _loc5_ = _loc3_;
- _loc4_ = _loc2_ + 1;
- }
- }
- else if(this._lvls[_loc3_][_loc2_] == 5)
- {
- _loc5_ = _loc3_;
- _loc4_ = _loc2_;
- this._arrowto_x = this.get_x_scr(_loc5_);
- this._arrowto_y = this.get_y_scr(_loc4_);
- return true;
- }
- _loc2_ = _loc2_ - 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- this._arrowto_x = this.get_x_scr(_loc5_);
- this._arrowto_y = this.get_y_scr(_loc4_);
- return true;
- }
- function show_arrow()
- {
- var _loc4_ = this._arrowto_x - this._map_x;
- var _loc3_ = this._arrowto_y + this._map_y;
- if(_loc4_ > 400)
- {
- _loc4_ = 380;
- }
- if(_loc4_ < 0)
- {
- _loc4_ = 20;
- }
- if(_loc3_ > 300)
- {
- _loc3_ = 280;
- }
- if(_loc3_ < 0)
- {
- _loc3_ = 20;
- }
- var _loc5_ = Math.atan2(_loc4_ - this._char_x,300 - _loc3_ - this._char_y) * 180 / 3.141592653589793;
- _root.main.face_scr.arrow_mc._x = _loc4_;
- _root.main.face_scr.arrow_mc._y = _loc3_;
- _root.main.face_scr.arrow_mc._rotation = _loc5_;
- }
- function elevators_move()
- {
- var _loc9_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes.length;
- var _loc3_ = 0;
- for(; _loc3_ < _loc9_; _loc3_ = _loc3_ + 1)
- {
- var _loc2_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes[_loc3_].attributes;
- switch(_loc2_.type)
- {
- case "e":
- var _loc8_ = Number(_loc2_.side / 1);
- var _loc5_ = _loc2_.x / 1;
- var _loc4_ = _loc2_.y / 1 + _loc8_ * _loc2_.speed;
- var _loc7_ = Math.round((_loc5_ - this._tile_size / 2 - this._tile_size / 2) / this._tile_size);
- var _loc6_ = Math.round((- _loc4_ - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
- if((this._lvls[_loc7_][_loc6_ - _loc8_] == "r" || this._lvls[_loc7_][_loc6_ - _loc8_] == "E") && Number(_loc2_.state) == 0)
- {
- _loc2_.state = 1;
- }
- else if(_loc2_.state == 1 && (this._lvls[_loc7_][_loc6_] == "r" || this._lvls[_loc7_][_loc6_] == "E"))
- {
- _loc2_.side *= -1;
- _loc2_.state = 2;
- }
- else if(_loc2_.state == 2)
- {
- _loc2_.state = 0;
- }
- _loc2_.x = _loc5_;
- _loc2_.y = _loc4_;
- break;
- case "o":
- _loc8_ = Number(_loc2_.side / 1);
- _loc5_ = _loc2_.x / 1 - _loc8_ * _loc2_.speed;
- _loc4_ = _loc2_.y / 1;
- _loc7_ = Math.round((_loc5_ - this._tile_size / 2 - this._tile_size / 2) / this._tile_size);
- _loc6_ = Math.round((- _loc4_ - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
- if(this._lvls[_loc7_ - _loc8_][_loc6_] == "p" || this._lvls[_loc7_ - _loc8_][_loc6_] == "O")
- {
- _loc2_.side *= -1;
- }
- _loc2_.x = _loc5_;
- _loc2_.y = _loc4_;
- break;
- case "t":
- switch(_loc2_.state)
- {
- case CGame.ELEVATOR_STATE_WAIT:
- if(this._char_on_elev && this._char_on_elev_id == _loc3_)
- {
- _loc2_.side = -1;
- _loc2_.state = CGame.ELEVATOR_STATE_GO;
- }
- break;
- case CGame.ELEVATOR_STATE_GO:
- _loc8_ = Number(_loc2_.side / 1);
- _loc5_ = _loc2_.x / 1;
- _loc4_ = _loc2_.y / 1 + _loc8_ * _loc2_.speed;
- _loc7_ = Math.round((_loc5_ - this._tile_size / 2 - this._tile_size / 2) / this._tile_size);
- _loc6_ = Math.round((- _loc4_ - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
- if(this._lvls[_loc7_][_loc6_] != "y")
- {
- _loc2_.x = _loc5_;
- _loc2_.y = _loc4_;
- break;
- }
- _loc2_.stoptime = CGame.ELEVATOR_STOP_TIME;
- _loc2_.state = CGame.ELEVATOR_STATE_TIMESTOP;
- continue;
- case CGame.ELEVATOR_STATE_TIMESTOP:
- _loc2_.stoptime = _loc2_.stoptime - 1;
- if(_loc2_.stoptime <= 0)
- {
- _loc2_.side = 1;
- _loc2_.state = CGame.ELEVATOR_STATE_GOBACK;
- }
- break;
- case CGame.ELEVATOR_STATE_GOBACK:
- _loc8_ = Number(_loc2_.side / 1);
- _loc5_ = _loc2_.x / 1;
- _loc4_ = _loc2_.y / 1 + _loc8_ * _loc2_.speed;
- _loc7_ = Math.round((_loc5_ - this._tile_size / 2 - this._tile_size / 2) / this._tile_size);
- _loc6_ = Math.round((- _loc4_ - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
- if(this._lvls[_loc7_][_loc6_] != "T")
- {
- _loc2_.x = _loc5_;
- _loc2_.y = _loc4_;
- break;
- }
- _loc2_.state = CGame.ELEVATOR_STATE_WAIT;
- continue;
- }
- break;
- }
- }
- this.show_elevators();
- }
- function show_elevators()
- {
- _root.main.gfx_scr.createEmptyMovieClip("elevators_scr",_root.elevators_depth);
- var _loc9_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes.length;
- var _loc3_ = 0;
- while(_loc3_ < _loc9_)
- {
- var _loc4_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes[_loc3_].attributes;
- var _loc5_ = "elevator" + _loc3_;
- var _loc6_ = new Object({_x:_loc4_.x,_y:_loc4_.y});
- _root.main.gfx_scr.elevators_scr.attachMovie("mapEvelator",_loc5_,_root.elevators_depth + 1 + _loc3_,_loc6_);
- _loc4_.wide2 = _root.main.gfx_scr.elevators_scr[_loc5_]._width / 2;
- _loc3_ = _loc3_ + 1;
- }
- }
- function add_elevator(type_id, x, y)
- {
- var _loc10_ = new XML();
- var _loc5_ = _loc10_.createElement("elev");
- _loc5_.attributes.type = type_id;
- _loc5_.attributes.x = this.get_x_scr(x);
- _loc5_.attributes.y = this.get_y_scr(y);
- _loc5_.attributes.side = -1;
- _loc5_.attributes.speed = this.ELEVATOR_E_SPEED;
- _loc5_.attributes.wide2 = this._tile_size / 2;
- _loc5_.attributes.state = 0;
- if(type_id == "e")
- {
- _loc5_.attributes.speed = this.ELEVATOR_E_SPEED;
- this._lvls[x][y] = "E";
- var _loc7_ = 200;
- var _loc6_ = 200;
- var _loc3_ = y - 1;
- while(_loc3_ > y - 100)
- {
- if(this._lvls[x][_loc3_] == "r")
- {
- _loc7_ = y - _loc3_;
- break;
- }
- _loc3_ = _loc3_ - 1;
- }
- _loc3_ = y + 1;
- while(_loc3_ < y + 100)
- {
- if(this._lvls[x][_loc3_] == "r")
- {
- _loc6_ = _loc3_ - y;
- break;
- }
- _loc3_ = _loc3_ + 1;
- }
- if(_loc6_ == 200 && _loc7_ != 200)
- {
- _loc5_.attributes.speed = - this.ELEVATOR_E_SPEED;
- }
- }
- else if(type_id == "t")
- {
- _loc5_.attributes.speed = this.ELEVATOR_E_SPEED;
- _loc5_.attributes.state = CGame.ELEVATOR_STATE_WAIT;
- _loc5_.attributes.stoptime = 0;
- this._lvls[x][y] = "T";
- _loc7_ = 200;
- _loc6_ = 200;
- _loc3_ = y - 1;
- while(_loc3_ > y - 100)
- {
- if(this._lvls[x][_loc3_] == "y")
- {
- _loc7_ = y - _loc3_;
- break;
- }
- _loc3_ = _loc3_ - 1;
- }
- _loc3_ = y + 1;
- while(_loc3_ < y + 100)
- {
- if(this._lvls[x][_loc3_] == "y")
- {
- _loc6_ = _loc3_ - y;
- break;
- }
- _loc3_ = _loc3_ + 1;
- }
- if(_loc6_ == 200 && _loc7_ != 200)
- {
- _loc5_.attributes.speed = - this.ELEVATOR_E_SPEED;
- }
- }
- else if(type_id == "o")
- {
- _loc5_.attributes.speed = this.ELEVATOR_E_SPEED;
- this._lvls[x][y] = "O";
- }
- if(this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID] == undefined)
- {
- var _loc9_ = this._map_xml.createElement("elevators");
- this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID] = _loc9_;
- }
- this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].appendChild(_loc5_);
- this.show_elevators();
- }
- function remove_elevator(id)
- {
- var _loc2_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes[id];
- _loc2_.removeNode();
- this.show_elevators();
- }
- function hide_elevator(id, mx, my)
- {
- var _loc3_ = Math.round((mx - this._tile_size / 2) / this._tile_size);
- var _loc2_ = Math.round((- my - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
- if(this._lvls[_loc3_][_loc2_] == 1)
- {
- this._lvls[_loc3_][_loc2_] = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes[id].attributes.type;
- this.remove_elevator(id);
- return true;
- }
- return false;
- }
- function coconuts_move()
- {
- var _loc12_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes.length;
- var _loc4_ = 0;
- for(; _loc4_ < _loc12_; _loc4_ = _loc4_ + 1)
- {
- var _loc3_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes[_loc4_].attributes;
- if((_loc3_.state == CGame.COCONUT_STATE_WAIT || _loc3_.state == CGame.COCONUT_STATE_STRESS) && (_loc3_.x - this._map_x < -100 || _loc3_.x - this._map_x > 500))
- {
- if(this.hide_coconut(_loc4_,_loc3_.x / 1,_loc3_.y / 1))
- {
- continue;
- }
- }
- if(_loc3_.state == CGame.COCONUT_STATE_FIRE && (_loc3_.x - this._map_x < -100 || _loc3_.x - this._map_x > 500))
- {
- this.remove_coconut(_loc4_);
- continue;
- }
- if(!(_loc3_.type == "g" || _loc3_.type == "j"))
- {
- continue;
- }
- switch(_loc3_.state)
- {
- case CGame.COCONUT_STATE_WAIT:
- var _loc5_ = this._char_x + this._map_x;
- var _loc11_ = this._char_y + this._map_y;
- if(_loc5_ > _loc3_.x - CGame.COCONUT_FALL_ZONE && _loc5_ < _loc3_.x + CGame.COCONUT_FALL_ZONE)
- {
- _loc3_.timer = CGame.COCONUT_STRESS_TIME;
- _loc3_.state = CGame.COCONUT_STATE_STRESS;
- _root.snd_fruit_shake.start();
- }
- break;
- case CGame.COCONUT_STATE_STRESS:
- _loc3_.timer = _loc3_.timer - 1;
- if(_loc3_.timer <= 0)
- {
- _loc3_.diffx = 0;
- _loc3_.diffy = 0;
- _loc3_.state = CGame.COCONUT_STATE_FALL;
- _root.snd_fruit_fall.start();
- }
- else
- {
- _loc3_.diffx = 3 - 6 * Math.random();
- _loc3_.diffy = 3 - 6 * Math.random();
- }
- break;
- case CGame.COCONUT_STATE_FALL:
- _loc3_.yspeed += CGame.COCONUT_GRAVITY;
- var _loc10_ = _loc3_.x / 1 + _loc3_.xspeed;
- var _loc9_ = _loc3_.y / 1 + _loc3_.yspeed;
- var _loc8_ = Math.round((_loc10_ - this._tile_size / 2 - this._tile_size / 2) / this._tile_size);
- var _loc6_ = Math.round((- _loc9_ - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
- if(this._lvls[_loc8_][_loc6_] == 0)
- {
- var _loc7_ = this.get_y_scr(_loc6_);
- _loc9_ = _loc7_ - this._tile_sizeh / 2;
- _loc3_.state = CGame.COCONUT_STATE_LIE;
- }
- _loc3_.x = _loc10_;
- _loc3_.y = _loc9_;
- break;
- case CGame.COCONUT_STATE_LIE:
- break;
- case CGame.COCONUT_STATE_FIRE:
- _loc3_.yspeed += CGame.COCONUT_GRAVITY;
- _loc10_ = _loc3_.x / 1 + _loc3_.xspeed;
- _loc9_ = _loc3_.y / 1 + _loc3_.yspeed;
- _loc3_.x = _loc10_;
- _loc3_.y = _loc9_;
- break;
- }
- }
- this.show_coconuts();
- }
- function show_coconuts()
- {
- _root.main.gfx_scr.createEmptyMovieClip("coconuts_scr",_root.coconuts_depth);
- var _loc9_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes.length;
- var _loc4_ = 0;
- while(_loc4_ < _loc9_)
- {
- var _loc3_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes[_loc4_].attributes;
- var _loc5_ = "coconut" + _loc4_;
- var _loc6_ = new Object({_x:_loc3_.x + _loc3_.diffx,_y:_loc3_.y + _loc3_.diffy});
- _root.main.gfx_scr.coconuts_scr.attachMovie("mapCoconut",_loc5_,_root.coconuts_depth + 1 + _loc4_,_loc6_);
- if(_loc3_.type == "j")
- {
- _root.main.gfx_scr.coconuts_scr[_loc5_].gotoAndStop(2);
- }
- _loc4_ = _loc4_ + 1;
- }
- }
- function add_coconut(type_id, x, y)
- {
- var _loc5_ = new XML();
- var _loc2_ = _loc5_.createElement("coconut");
- _loc2_.attributes.type = type_id;
- _loc2_.attributes.state = CGame.COCONUT_STATE_WAIT;
- _loc2_.attributes.x = this.get_x_scr(x);
- _loc2_.attributes.y = this.get_y_scr(y);
- _loc2_.attributes.diffx = 0;
- _loc2_.attributes.diffy = 0;
- _loc2_.attributes.timer = 0;
- _loc2_.attributes.yspeed = 1;
- if(type_id == "g")
- {
- _loc2_.attributes.xspeed = -2;
- }
- else if(type_id == "j")
- {
- _loc2_.attributes.xspeed = 2;
- }
- this._lvls[x][y] = 1;
- if(this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID] == undefined)
- {
- var _loc3_ = this._map_xml.createElement("coconuts");
- this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID] = _loc3_;
- }
- this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].appendChild(_loc2_);
- this.show_coconuts();
- }
- function remove_coconut(id)
- {
- var _loc2_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes[id];
- _loc2_.removeNode();
- this.show_coconuts();
- }
- function hide_coconut(id, mx, my)
- {
- var _loc3_ = Math.round((mx - this._tile_size / 2) / this._tile_size);
- var _loc2_ = Math.round((- my - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
- if(this._lvls[_loc3_][_loc2_] == 1)
- {
- this._lvls[_loc3_][_loc2_] = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes[id].attributes.type;
- this.remove_coconut(id);
- return true;
- }
- return false;
- }
- function add_hp(hp)
- {
- this._chp += hp;
- if(this._chp > this._chp_max)
- {
- this._chp = this._chp_max;
- }
- var _loc3_ = this._chp / this._chp_max;
- if(_loc3_ <= 0.25)
- {
- _root.main.face_scr.hp_bar.shine_mc.play();
- }
- _root.main.face_scr.mcShells.SetValue(this._chp);
- if(this._chp <= 0)
- {
- _root.hero_death.start();
- this.lose_game(1);
- return false;
- }
- }
- function add_mp(mp)
- {
- return undefined;
- }
- function add_explosion(x, y, type_id)
- {
- this._exps = this._exps + 1;
- var _loc3_ = "z_exps" + this._exps;
- var _loc4_ = new Object({_x:x,_y:y});
- _root.main.gfx_scr.attachMovie("z_exps",_loc3_,_root.stars_depth + this._exps,_loc4_);
- _root.main.gfx_scr[_loc3_].gotoAndStop(type_id);
- if(this._exps > 50)
- {
- this._exps = 0;
- }
- }
- function add_buble(x, y)
- {
- _root.main.gfx_scr.attachMovie("bubble2","bubles" + this.buble_id,_root.bubles_depth + this.buble_id,{_x:x,_y:y});
- if(this.buble_id > 8)
- {
- this.buble_id = 0;
- }
- else
- {
- this.buble_id = this.buble_id + 1;
- }
- }
- function add_turtle()
- {
- var _loc6_ = this.get_start_x();
- var _loc5_ = this.get_start_y();
- if(this._checkpoint_x != -1)
- {
- _loc6_ = this._checkpoint_x;
- _loc5_ = this._checkpoint_y;
- }
- this._char_x = _loc6_ * this._ts / 1 + this._ts2;
- this._char_y = _loc5_ * this._tsh / 1;
- if(this._char_x > this._game_width / 2)
- {
- this._map_x = this._char_x - this._game_width / 2;
- this._char_x = this._game_width / 2;
- }
- if(this._char_y > this._game_height / 2)
- {
- this._map_y = this._char_y - this._game_height / 2;
- this._char_y = this._game_height / 2;
- }
- _root.main.attachMovie("char","char",_root.char_depth);
- MovieClip(_root.main.char).hitArea = _root.main.char.mcHitArea;
- _root.main.char.mcHitArea._visible = false;
- var _loc4_ = new Object();
- _loc4_.onKeyDown = function()
- {
- _root.anykey_pressed = true;
- if(!_global._game_paused)
- {
- switch(Key.getCode())
- {
- case 39:
- _root.main.game.move(1);
- break;
- case 37:
- _root.main.game.move(-1);
- break;
- case 27:
- _root.show_escmenu();
- break;
- case 17:
- case 32:
- _root.main.game.jump_char();
- }
- }
- };
- _loc4_.onKeyUp = function()
- {
- _root.anykey_pressed = true;
- switch(Key.getCode())
- {
- case 39:
- case 37:
- _root.main.game._csx = 0;
- }
- };
- if(Key._listeners.length == 0)
- {
- Key.addListener(_loc4_);
- }
- _root.main.char.onEnterFrame = function()
- {
- if(!_global._game_paused)
- {
- if(Key.isDown(32) || Key.isDown(17) || Key.isDown(38))
- {
- _root.main.game.jump_char();
- }
- if(Key.isDown(37) || Key.isDown(39))
- {
- if(Key.isDown(37))
- {
- _root.main.game.move(-1);
- }
- else
- {
- _root.main.game.move(1);
- }
- if(!this._ie)
- {
- this._ie = true;
- }
- }
- else if(this._ie)
- {
- _root.main.game._csx = 0;
- }
- }
- if(!_global._game_paused)
- {
- _root.anykey_count = _root.anykey_count + 1;
- _root.main.game.turn();
- if(_root.anykey_count > 140)
- {
- _root.show_tip(100);
- }
- }
- };
- this._char_xscale = _root.main.char._xscale;
- }
- function OpenWinnerWindow()
- {
- var _loc3_ = this.GetCountTilesOfType(CGame.TILES_ALL_MONSTERS,this._lvls);
- var _loc4_ = this.GetCountTilesOfType(CGame.TILES_ALL_BONUSES,this._lvls);
- CGame._level_total_time += getTimer() - this._level_start_time;
- _root.show_win_menu(this._current_map,this._scores,this._char_lives,this._stars_collecled,CGame._total_monsters_count,CGame._total_monsters_count - _loc3_,CGame._total_bonuses_count,CGame._total_bonuses_count - _loc4_,CGame._level_total_time);
- }
- function lose_game(reason_id)
- {
- CGame._level_total_time += getTimer() - this._level_start_time;
- this._char_lives = this._char_lives - 1;
- _global._game_paused = true;
- _root.main.tiles_scr.unloadMovie();
- _root.show_lose_menu(this._current_map,this._scores,reason_id,this._char_lives,this._checkpoint_x,this._checkpoint_y,this._lvls,this._diams);
- }
- function UpdateWaterLevel()
- {
- var _loc3_ = this._game_height + this._map_y - this.waterlevel_tiley;
- if(_loc3_ < 0)
- {
- _loc3_ = 0;
- }
- _root.main.mcWater._y = _loc3_;
- }
- }
-