////////////////////////////////////////////////////////// // Heist V2.0 By Timothy Randall ////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////// // Global Variables and states declared here ////////////////////////////////////////////////////////// // // Control Variables var score:Number = 0; var coins:Number = 3; var speed:Number = 15; var guardspeed:Number = 3; var steal:Boolean = false; var stealsuccess:Boolean = false; var spot:Boolean = false; var hiding:Boolean = false; var distract:Boolean = false; var distracted:Boolean = false; var pickpocket:Boolean = false; // Level Variables var currentlevel:Number = 1; var guards:Number; var objects:Number; var hidezones:Number; var guard_orientation = new Array(); var guard_inventory = new Array(); // Sounds and Music music = new Sound(_root); music.attachSound("theme"); // Text Formats scoreformat = new TextFormat(); scoreformat.color = 0xFFFFFF; scoreformat.font = "Digital Readout ExpUpright"; // ////////////////////////////////////////////////////////// // End Globral Variable declration ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin currentLevel Function ////////////////////////////////////////////////////////// // // This function sets up the current level including guards, objects, hidezones etc // // 1. If the current level is level 1 // 2. Sets up the level's contents // 3-4. The same as 1 except for level's 2 and 3 respectively // function currentLevel() { switch (currentlevel) { // 1. case 1 : // 2. level.attachMovie("level1", "level", 1); objects = 6; hidezones = 2; guards = 1; guard_orientation[0] = "left"; guard_inventory[0] = "none"; break; // 3. case 2 : level.attachMovie("level2", "level", 1); objects = 0; hidezones = 0; guards = 2; guard_orientation[0] = "right"; guard_inventory[0] = "key"; guard_orientation[1] = "left"; guard_inventory[1] = "none"; break; // 4. case 3 : level.attachMovie("level3", "level", 1); objects = 2; hidezones = 1; guards = 2; guard_orientation[0] = "right"; guard_inventory[0] = "none"; guard_orientation[1] = "left"; guard_inventory[0] = "none"; break; } } ////////////////////////////////////////////////////////// // End currentLevel Function ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// // Begin controlSetup Function ////////////////////////////////////////////////////////// // // The purpose of this function is to setup the controls for the game // function controlSetup() { robber.onEnterFrame = function() { if (spot == true) { robber.gotoAndStop("stand"); } else if (Key.isDown(Key.RIGHT) && !stopMovement()) { attemptWalk("right"); } else if (Key.isDown(Key.LEFT) && !stopMovement()) { attemptWalk("left"); } else if (Key.isDown(Key.SPACE) || steal == true) { attemptSteal(); } else if (Key.isDown(Key.UP)) { attemptHide(); } else if (Key.isDown(Key.CONTROL) || distract == true) { attemptDistract(); } else if (Key.isDown(Key.SHIFT) || pickpocket == true && spot != true) { attemptPickPocket(); } else { hiding = false; robber.gotoAndStop("stand"); } }; } // ////////////////////////////////////////////////////////// // End controlSetup Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Start attemptWalk Function ////////////////////////////////////////////////////////// // // The purpose of this function is to deal with basic movement // // 1. If the user pressed the 'right' arrow // 2. Swap the robbers orientation around so that he is facing the right way // 3. If the robber reaches the end of this stage end the stage // 4. If the robber hits the end of the room load the next room // 5. Calculates a ratio of the map's size in comparion to where the user is standing, // if they have reached the end of the level stop scrolling the level and instead // move the robber // 6. If none of the above scroll the level and guards as the player moves // 7. Same as 1-5 except for the left direction // function attemptWalk(walkdirection:String) { switch (walkdirection) { // 1. case "right" : // 2. robber._xscale = +100; robber.gotoAndStop("walk"); // 3. if (robber.hitTest(level.level.exit)) { endLevel(); // 4. } else if (robber.hitTest(level.level.warppoint_right)) { currentlevel++; setupGame(); // 5. } else if (-level._x>=level._width/1.27 || robber._x<275) { robber._x += speed; break; // 6. } else { level._x -= speed; guardcontainer._x -= speed; break; } // 7. case "left" : robber._xscale = -100; robber.gotoAndStop("walk"); if (robber.hitTest(level.level.blocker_left)) { return false; } else if (robber._x<275 || level._x>=0) { robber._x -= speed; break; } else { level._x += speed; guardcontainer._x += speed; break; } } } // ////////////////////////////////////////////////////////// // End attemptWalk Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin attemptPickPocket Function ////////////////////////////////////////////////////////// // function attemptPickPocket() { for (i=1; i<=guards; i++) { if (guardcontainer["guard"+i].key.hitTest(robber.steal_hitbox)) { pickpocket = true; stopMovement(); robber.gotoAndStop("pickpocket"); beginPickPocket(guardcontainer["guard"+i].key); break; } else if (i == guards) { pickpocket = false; break; } } } // ////////////////////////////////////////////////////////// // End attemptPickPocket Function ////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////// // Start beginPickPocket Function ////////////////////////////////////////////////////////// // function beginPickPocket(objectinstance:MovieClip) { objectinstance.onEnterFrame = function() { if (robber.pickpocket._currentframe == 9) { pickpocket = false; unloadMovie(this); } }; } // ////////////////////////////////////////////////////////// // End beginPickPocket Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin stealObject Function ////////////////////////////////////////////////////////// // // Contains the steal functionality // // 1. If the robber's animation has played through far enough so that he has begun // to push an object into his bag // 2. Cause the object being stolen to play its animation // 3. When the object has played through to its final frame, unload it and tell the robber // to stop stealing // function stealObject(object:MovieClip) { // 1. if (robber.stealstance._currentframe>=10) { // 2. object.play(); object.onEnterFrame = function() { // 3. if (this._currentframe == 18) { score += 200; createScoreboard(); robber.gotoAndStop("stand"); unloadMovie(this); break; } }; } } // ////////////////////////////////////////////////////////// // End stealObject Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin attemptSteal Function ////////////////////////////////////////////////////////// // // The purpose of this function is to determine whether or not a 'steal' can be // // 1. This for loop runs through all the objects in the level and sees if any of them are // in contact with the robber, if so a steal is performed if not return false function attemptSteal() { // 1. for (i=1; i<=objects; i++) { if (level.level["object"+i].hitTest(robber.steal_hitbox)) { steal = true; robber.gotoAndStop("steal"); var object:MovieClip = level.level["object"+i]; stealObject(level.level["object"+i]); break; } else if (i == objects) { steal = false; break; } } } // ////////////////////////////////////////////////////////// // End attemptSteal Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin beginHide Function ////////////////////////////////////////////////////////// // // This is the function that causes the robber to camouflage when hiding // function beginHide() { robber.hidden.body._alpha -= 1; robber.gotoAndStop("hide"); hiding = true; } ////////////////////////////////////////////////////////// // End beginHide Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin attemptHide Function ////////////////////////////////////////////////////////// // // The purpose of this function is to check whether or not a hide can be performed // // 1. This for loop cycles through all the hidezones in the level and checks if the robber // if in contact with any; if he is then a hide is performed function attemptHide() { // 1. for (i=1; i<=hidezones; i++) { if (level.level["hide_zone"+i]["hitbox"].hitTest(robber.hide_hitbox)) { beginHide(); break; } } } // ////////////////////////////////////////////////////////// // End attemptHide Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin attemptDistract Function ////////////////////////////////////////////////////////// // // The purpose of this function is to begin a distract // // 1. If the robber has finished flicking the coin then return movement funcionality // 2. If the robber has yet to finish the distract remove movement functionality until // the distract is complete // 3. The purpose of this variable is to cause the robber to play the distract animation // 4. The purpose of this variable is to control guards and make them 'distracted' function attemptDistract() { // 1. if (coins>0) { if (robber.distract._currentframe == 25) { coins--; createScoreboard(); distract = false; // 2. } else { // 3. distract = true; // 4. distracted = true; robber.gotoAndStop("distract"); } } else { return false; } } // ////////////////////////////////////////////////////////// // End attemptDistract Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin stopMovement Function ////////////////////////////////////////////////////////// // // This is a simple boolean function to determine if movement is allowed to be performed // by the robber // function stopMovement() { if (spot == true || steal == true || hiding == true || distract == true || pickpocket == true) { return true; } else { return false; } } // ////////////////////////////////////////////////////////// // End stopMovement Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin controlSetup Function ////////////////////////////////////////////////////////// // // The purpose of this function is to setup the controls for the game // function controlSetup() { robber.onEnterFrame = function() { if (spot == true) { robber.gotoAndStop("stand"); } else if (Key.isDown(Key.RIGHT) && !stopMovement()) { attemptWalk("right"); } else if (Key.isDown(Key.LEFT) && !stopMovement()) { attemptWalk("left"); } else if (Key.isDown(Key.SPACE) || steal == true) { attemptSteal(); } else if (Key.isDown(Key.UP)) { attemptHide(); } else if (Key.isDown(Key.CONTROL) || distract == true) { attemptDistract(); } else if (Key.isDown(Key.SHIFT) || pickpocket == true && spot != true) { attemptPickPocket(); } else { hiding = false; robber.gotoAndStop("stand"); } }; } ////////////////////////////////////////////////////////// // End controlSetup Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Start attemptWalk Function ////////////////////////////////////////////////////////// // // The purpose of this function is to deal with basic movement // // 1. If the user pressed the 'right' arrow // 2. Swap the robbers orientation around so that he is facing the right way // 3. If the robber reaches the end of this stage end the stage // 4. If the robber hits the end of the room load the next room // 5. Calculates a ratio of the map's size in comparion to where the user is standing, // if they have reached the end of the level stop scrolling the level and instead // move the robber // 6. If none of the above scroll the level and guards as the player moves // 7. Same as 1-5 except for the left direction // function attemptWalk(walkdirection:String) { switch (walkdirection) { // 1. case "right" : // 2. robber._xscale = +100; robber.gotoAndStop("walk"); // 3. if (robber.hitTest(level.level.exit)) { endLevel(); // 4. } else if (robber.hitTest(level.level.warppoint_right)) { currentlevel++; setupGame(); // 5. } else if (-level._x>=level._width/1.27 || robber._x<275) { robber._x += speed; break; // 6. } else { level._x -= speed; guardcontainer._x -= speed; break; } // 7. case "left" : robber._xscale = -100; robber.gotoAndStop("walk"); if (robber.hitTest(level.level.blocker_left)) { return false; } else if (robber._x<275 || level._x>=0) { robber._x -= speed; break; } else { level._x += speed; guardcontainer._x += speed; break; } } } // ////////////////////////////////////////////////////////// // End attemptWalk Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin attemptPickPocket Function ////////////////////////////////////////////////////////// // function attemptPickPocket() { for (i=1; i<=guards; i++) { if (guardcontainer["guard"+i].key.hitTest(robber.steal_hitbox)) { pickpocket = true; stopMovement(); robber.gotoAndStop("pickpocket"); beginPickPocket(guardcontainer["guard"+i].key); break; } else if (i == guards) { pickpocket = false; break; } } } // ////////////////////////////////////////////////////////// // End attemptPickPocket Function ////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////// // Start beginPickPocket Function ////////////////////////////////////////////////////////// // function beginPickPocket(objectinstance:MovieClip) { objectinstance.onEnterFrame = function() { if (robber.pickpocket._currentframe == 9) { pickpocket = false; unloadMovie(this); } }; } // ////////////////////////////////////////////////////////// // End beginPickPocket Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin stealObject Function ////////////////////////////////////////////////////////// // // Contains the steal functionality // // 1. If the robber's animation has played through far enough so that he has begun // to push an object into his bag // 2. Cause the object being stolen to play its animation // 3. When the object has played through to its final frame, unload it and tell the robber // to stop stealing // function stealObject(object:MovieClip) { // 1. if (robber.stealstance._currentframe>=10) { // 2. object.play(); object.onEnterFrame = function() { // 3. if (this._currentframe == 18) { score += 200; createScoreboard(); robber.gotoAndStop("stand"); unloadMovie(this); break; } }; } } // ////////////////////////////////////////////////////////// // End stealObject Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin attemptSteal Function ////////////////////////////////////////////////////////// // // The purpose of this function is to determine whether or not a 'steal' can be // // 1. This for loop runs through all the objects in the level and sees if any of them are // in contact with the robber, if so a steal is performed if not return false function attemptSteal() { // 1. for (i=1; i<=objects; i++) { if (level.level["object"+i].hitTest(robber.steal_hitbox)) { steal = true; robber.gotoAndStop("steal"); var object:MovieClip = level.level["object"+i]; stealObject(level.level["object"+i]); break; } else if (i == objects) { steal = false; break; } } } // ////////////////////////////////////////////////////////// // End attemptSteal Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin beginHide Function ////////////////////////////////////////////////////////// // // This is the function that causes the robber to camouflage when hiding // function beginHide() { robber.hidden.body._alpha -= 1; robber.gotoAndStop("hide"); hiding = true; } ////////////////////////////////////////////////////////// // End beginHide Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin attemptHide Function ////////////////////////////////////////////////////////// // // The purpose of this function is to check whether or not a hide can be performed // // 1. This for loop cycles through all the hidezones in the level and checks if the robber // if in contact with any; if he is then a hide is performed function attemptHide() { // 1. for (i=1; i<=hidezones; i++) { if (level.level["hide_zone"+i]["hitbox"].hitTest(robber.hide_hitbox)) { beginHide(); break; } } } // ////////////////////////////////////////////////////////// // End attemptHide Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin attemptDistract Function ////////////////////////////////////////////////////////// // // The purpose of this function is to begin a distract // // 1. If the robber has finished flicking the coin then return movement funcionality // 2. If the robber has yet to finish the distract remove movement functionality until // the distract is complete // 3. The purpose of this variable is to cause the robber to play the distract animation // 4. The purpose of this variable is to control guards and make them 'distracted' function attemptDistract() { // 1. if (coins>0) { if (robber.distract._currentframe == 25) { coins--; createScoreboard(); distract = false; // 2. } else { // 3. distract = true; // 4. distracted = true; robber.gotoAndStop("distract"); } } else { return false; } } // ////////////////////////////////////////////////////////// // End attemptDistract Function ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// // Begin stopMovement Function ////////////////////////////////////////////////////////// // // This is a simple boolean function to determine if movement is allowed to be performed // by the robber // function stopMovement() { if (spot == true || steal == true || hiding == true || distract == true || pickpocket == true) { return true; } else { return false; } } // ////////////////////////////////////////////////////////// // End stopMovement Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin setupGame Function ////////////////////////////////////////////////////////// // // This function sets up the game and is called at the beginning of each level // function setupGame() { _root.createEmptyMovieClip("level", 1); _root.attachMovie("robber", "robber", 2); _root.createEmptyMovieClip("guardcontainer", 3); _root.attachMovie("musicbutton", "musicbutton", 5); level._x = 0; guardcontainer._x = 0; robber._x = 275; robber._y = 350; spot = false; currentLevel(); createScoreboard(); controlSetup(); guardSetup(); } // ////////////////////////////////////////////////////////// // End setupGame Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Start createScoreboard Function ////////////////////////////////////////////////////////// // // This function displays the scoreboard function createScoreboard() { scoreformat.size = 32; _root.createTextField("scoretext", 5, 10, 10, 300, 200); scoretext.text = "Loot=$"+score; scoretext.setTextFormat(scoreformat); _root.createTextField("coinstext", 6, 10, 50, 300, 200); coinstext.text = "Coins Left="+coins; scoreformat.size = 18; coinstext.setTextFormat(scoreformat); } // ////////////////////////////////////////////////////////// // End createScoreboard Function ////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////// // Start createMusicUI Function ////////////////////////////////////////////////////////// // // This function displays the music on and off button and toggles it on and off when it is clicked // accordingly function createMusicUI() { _root.createTextField("musictext", 7, 550, 10, 300, 200); musictext.text = "Music="; scoreformat.size = 18; musictext.setTextFormat(scoreformat); _root.attachMovie("musicsymbol", "musicsymbol", 8); musicsymbol.stop(); musicsymbol._x = 650; musicsymbol._y = 20; musicsymbol.onRelease = function() { setupMusic(musicsymbol._currentframe); }; } ////////////////////////////////////////////////////////// // End createMusicUI Function ////////////////////////////////////////////////////////// // function setupMusic(musicstate:Number) { switch (musicstate) { case 1 : music.stop(); musicsymbol.gotoAndStop(2); break; case 2 : music.start(0, 999); musicsymbol.gotoAndStop(1); break; } } // ////////////////////////////////////////////////////////// // End setupMusic Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Start displayControls Function ////////////////////////////////////////////////////////// // // This function displays the pages which explain the game's controls // function displayControls() { _root.attachMovie("controls", "controls", 1); controls.stop(); controls.nextbutton.onRelease = function() { if (controls._currentframe == 5) { controls.gotoAndStop(1); } else { controls.gotoAndStop(controls._currentframe+1); } }; controls.menubutton.onRelease = function() { music.stop(); displayMenu(); }; } // ////////////////////////////////////////////////////////// // End displayControls Function ////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////// // Start displayMenu Function ////////////////////////////////////////////////////////// // // This function displays the main menu // function displayMenu() { music.start(0, 999); _root.attachMovie("menu", "menu", 1); menu._x = 350; menu._y = 200; menu.startbutton.onRelease = function() { setupGame(); createMusicUI(); }; menu.controlbutton.onRelease = function() { displayControls(); }; } // ////////////////////////////////////////////////////////// // End displayMenu Function ////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////// // Start gameOver Function ////////////////////////////////////////////////////////// // // Displays the game over screen when the guard has finished his caught animation // function gameOver(guardinstance:MovieClip) { guardinstance.onEnterFrame = function() { if (guardinstance.guard._currentframe == 55) { robber.unloadMovie(); level.unloadMovie(); guardcontainer.unloadMovie(); scoretext.removeTextField(); coinstext.removeTextField(); musictext._visible = false; musicsymbol._visible = false; _root.attachMovie("gameover", "gameover", 1); gameover._x = 350; gameover._y = 200; gameover.stop(); gameover.retrybutton.onRelease = function() { musictext._visible = true; musicsymbol._visible = true; coins = 3; score = 0; currentlevel = 1; setupGame(); }; gameover.menubutton.onRelease = function() { music.stop(); displayMenu(); }; } }; } // ////////////////////////////////////////////////////////// // End gameOver Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Start endLevel Function ////////////////////////////////////////////////////////// // // This function is called when the end of a stage is reached // function endLevel() { robber.unloadMovie(); level.unloadMovie(); guardcontainer.unloadMovie(); scoretext.removeTextField(); coinstext.removeTextField(); musictext._visible = false; musicsymbol._visible = false; _root.attachMovie("wintext", "wintext", 1); wintext.menubutton.onRelease = function() { score = 0; coins = 3; music.stop(); displayMenu(); } } // ////////////////////////////////////////////////////////// // End endLevel Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin beginPatrol Function ////////////////////////////////////////////////////////// // // This function contains the functionality for guards when they are on patrol (default setting), // causing them to walk up and down the level until they are disrupted // // 1. When the guard is facing the left // 2. If the guard reaches the end of the level cause it to stop movement for a short while // 3. When the guard has stood for 39 frames cause it to turn around // 4. Else if the guard hasn't reached the end of the level he will continue to walk in // his current direction // 5. 1-4 except in the right direction // function beginPatrol(guardinstance:MovieClip) { switch (guardinstance._xscale) { // 1. case 100 : // 2. if (guardinstance.hitTest(level.level["blocker_left"])) { guardinstance.gotoAndStop("stand"); // 3. if (guardinstance.guard._currentframe == 39) { guardinstance._xscale = -100; } // 4. } else { guardinstance._x -= guardspeed; guardinstance.gotoAndStop("walk"); } break; // 5. case -100 : if (guardinstance.hitTest(level.level["blocker_right"])) { guardinstance.gotoAndStop("stand"); if (guardinstance.guard._currentframe == 39) { guardinstance._xscale = 100; } } else { guardinstance._x += guardspeed; guardinstance.gotoAndStop("walk"); } } } // ////////////////////////////////////////////////////////// // End beginPatrol Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin guardAi Function ////////////////////////////////////////////////////////// // // This function contains the Ai for the guards, it determines what // the guard should be doing // // 1. If a distract has been performed // 2. When the guard has been distracted for the time allocation (81 frames) end // the distract // 3. If he is still distracted then continue to be distracted // 4. If the robber walks into the guard's beam and he is not hiding then catch // the robber (gameover) // 5. If the robber has been spotted but not by this specific guardinstance then stop and stand // 6. If none of the above are true continue patrol function guardAi(guardinstance:MovieClip) { guardinstance.onEnterFrame = function() { // 1. if (distracted == true) { // 2. if (this.guard._currentframe == 81) { distracted = false; // 3. } else { this.gotoAndStop("distract"); } // 4. } else if (this.guard.beam.hitTest(robber) && hiding != true) { this.gotoAndStop("spot"); spot = true; gameOver(this); break; // 5. } else if (spot == true) { this.gotoAndStop("stand"); // 6. } else { beginPatrol(this); } }; } // ////////////////////////////////////////////////////////// // End guardAi Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin guardOrientation Function ////////////////////////////////////////////////////////// // // The purpose of this function is to determine the guard's initial orientation // function guardOrientation(guardinstance:MovieClip, guarddirection:String) { switch (guarddirection) { case "right" : guardinstance._xscale = -100; break; case "left" : guardinstance._xscale = 100; break; } } // ////////////////////////////////////////////////////////// // End guardOrientation Function ////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////// // Begin guardInventory Function ////////////////////////////////////////////////////////// // function guardInventory(guardinstance:MovieClip, inventory:String) { switch (inventory) { case "key" : guardinstance.attachMovie("key", "key", 2); guardinstance.key.onEnterFrame = function() { guardinstance.key._x = guardinstance.guard.key_spawnpoint._x; guardinstance.key._y = guardinstance.guard.key_spawnpoint._y-125; }; break; case "none" : return false; } } // ////////////////////////////////////////////////////////// // End guardInventory Function ////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// // Begin guardSetup Function ////////////////////////////////////////////////////////// // // This function sets up the guards for the level // // 1. A for loop that creates a guard for each guard in the level // 2. Spawns the guard at the specified spawnpoint // 3. Sets up the guard's AI and orientation function guardSetup() { for (i=1; i<=guards; i++) { guardcontainer.attachMovie("guard", "guard"+i, i); // 2. guardcontainer["guard"+i]._x = level.level["guard_spawnpoint"+i]._x; guardcontainer["guard"+i]._y = level.level["guard_spawnpoint"+i]._y; var guardinstance:MovieClip = guardcontainer["guard"+i]; // 3. guardAi(guardinstance); guardInventory(guardinstance, guard_inventory[i-1]); guardOrientation(guardinstance, guard_orientation[i-1]); } } // ////////////////////////////////////////////////////////// // End guardSetup Function ////////////////////////////////////////////////////////// // // Begin the game by displaying the menu the first time it is loaded displayMenu();