public void update(float elapsed) { this.time = MathHelper.Clamp(this.time - elapsed, 0f, this.time); // add the elapsed to the timer but ensure we do not negate past 0 if (this.time <= 0f) { if (!AIManager.getInstance().PlayerDetected) { SoundManager.getInstance().sfxEngine.playSoundEffect(this.guardsAlertedSfx, loop: true); } //Alert the authorities AIManager.getInstance().PlayerDetected = true; this.timeText.WrittenText = formatTimer(); } else { float seconds = this.time / 1000f; this.timeText.WrittenText = formatTimer(); float factor = this.initialTime / this.time; if (factor >= 3f) { this.activeTimeColour = LOW_TIME; this.timeText.LightColour = this.activeTimeColour; } else if (factor >= 1.5f) { this.activeTimeColour = MEDIUM_TIME; this.timeText.LightColour = this.activeTimeColour; } else { this.activeTimeColour = HIGH_TIME; this.timeText.LightColour = this.activeTimeColour; } } }
private static MapWalls loadMapWalls(Color wallColour, LoadResult loadResult) { int height = loadResult.Height; int width = loadResult.Width; int wallLayer = 1; MapTile[,] mapWallTiles = loadResult.Layers[wallLayer].Tiles; // load visual aspect of the walls Tile[,] wallTiles = GWNorthEngine.Tools.TilePlacer.MapLoader.initTiles <Tile>(mapWallTiles, delegate(MapTile tile) { if (Tile.COLOUR_OVERRIDE_TILES.Contains <string>(tile.Texture.Name)) { return(new Tile(tile.Texture, tile.Index, Color.White, tile.TileValue)); } else { return(new Tile(tile.Texture, tile.Index, wallColour, tile.TileValue)); } }); // load the AI for the map BasePathFinder.TypeOfSpace[,] aiSpaceTypes = new BasePathFinder.TypeOfSpace[height, width]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { // override so the AI can walk the outter wall if (wallTiles[y, x] != null && mapAsUnwalkable(wallTiles[y, x].Texture.Name, y, x, height, width)) { aiSpaceTypes[y, x] = Translator.translateTileValueToAStarType(wallTiles[y, x].TileValue); } else { aiSpaceTypes[y, x] = BasePathFinder.TypeOfSpace.Walkable; } } } AIManager.getInstance().init(height, width); AIManager.getInstance().Board = aiSpaceTypes; // generate the collision detection Placement tilesPlacement; List <BoundingBox> tileBBoxes = new List <BoundingBox>(); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (mapWallTiles[y, x] != null) { tilesPlacement = new Placement(new Point(x, y)); tileBBoxes.AddRange(CollisionDetectionGenerator.generateBoundingBoxesForTexture(mapWallTiles[tilesPlacement.index.Y, tilesPlacement.index.X].Texture, tilesPlacement)); } } } CollisionManager.getInstance().MapBoundingBoxes = tileBBoxes; return(new MapWalls(wallTiles, wallColour)); }
protected virtual void updateLocation(float elapsed) { // update our placement and bounding box this.Placement = new Placement(Placement.getIndex(this.activeSprite.Position)); this.BoundingBox = Helper.getPersonBBox(this.activeSprite.Position); if (this.previousPlacement.index != this.Placement.index) { AIManager.getInstance().Board[this.previousPlacement.index.Y, this.previousPlacement.index.X] = this.previousTypeOfSpace; this.previousTypeOfSpace = AIManager.getInstance().Board[this.Placement.index.Y, this.Placement.index.X]; } }
/// <summary> /// UnloadContent will be called once per game and is the place to unload /// all content. /// </summary> protected override void UnloadContent() { this.gameDisplay.dispose(); this.mainMenu.dispose(); this.modeSelectMenu.dispose(); this.inGameMenu.dispose(); this.instructionMenu.dispose(); this.mapSelectionMenu.dispose(); this.gameOverDisplay.dispose(); this.activeDisplay.dispose(); SoundManager.getInstance().dispose(); AIManager.getInstance().dispose(); ResourceManager.getInstance().dispose(); base.UnloadContent(); }
protected override void updateLocation(float elapsed) { if (!this.Hiding) { if (this.direction != Direction.None) { float moveDistance = (this.movementSpeed * elapsed); Vector2 newPos = this.activeSprite.Position; if (this.direction == Direction.Up) { newPos = new Vector2(this.activeSprite.Position.X, this.activeSprite.Position.Y - moveDistance); } else if (this.direction == Direction.Right) { newPos = new Vector2(this.activeSprite.Position.X + moveDistance, this.activeSprite.Position.Y); } else if (this.direction == Direction.Down) { newPos = new Vector2(this.activeSprite.Position.X, this.activeSprite.Position.Y + moveDistance); } else if (this.direction == Direction.Left) { newPos = new Vector2(this.activeSprite.Position.X - moveDistance, this.activeSprite.Position.Y); } // check if the new position would result in a collision, if not, assign the sprite the position if (!CollisionManager.getInstance().wallCollisionFound(Helper.getPersonBBox(newPos))) { this.activeSprite.Position = newPos; } } } // call the generic code before continuing base.updateLocation(elapsed); if (AIManager.getInstance().PlayerDetected) // if we aren't moving we still need to report where we are if we are detected // if we have been detected we need to tell the AI where we are { AIManager.getInstance().Board[base.Placement.index.Y, base.Placement.index.X] = BasePathFinder.TypeOfSpace.End; } }
private void generateMove() { if (AIManager.getInstance().PlayerDetected) { updateState(State.Chase); } // patrol can just generate the waypoint once if (this.currentState == State.Patrol) { if (base.Placement.index == this.destinationWayPoint) { this.destinationWayPoint = AIManager.getInstance().getNextWayPoint(base.Placement.index, this.movementDirection); AIManager.getInstance().requestPath(base.Placement.index, this.destinationWayPoint, this.callBackDelegate); } else if (base.Placement.index == this.closestsPoint) { if (this.path.Count >= 1) { this.closestsPoint = path.Pop(); } } } else if (this.currentState == State.Chase) { // chase should regenerate the waypoint all the time if (this.closestsPoint == base.Placement.index) { AIManager.getInstance().requestPath(base.Placement.index, delegate(Stack <Point> path) { this.callBackDelegate.Invoke(path); if (this.path.Count >= 1) { this.closestsPoint = path.Pop(); } }); } } }
public Person(ContentManager content, string fileStartsWith, Placement startingLocation, float movementSpeed) { BaseAnimationManagerParams animationParams = new BaseAnimationManagerParams(); animationParams.AnimationState = AnimationState.PlayForward; animationParams.FrameRate = FRAME_RATE; animationParams.TotalFrameCount = 4; BaseAnimated2DSpriteParams spriteParams = new Animated2DSpriteLoadSingleRowBasedOnTexture(); spriteParams.Origin = new Vector2(ResourceManager.TILE_SIZE / 2, ResourceManager.TILE_SIZE / 2); spriteParams.Texture = LoadingUtils.load <Texture2D>(content, fileStartsWith + "Right"); spriteParams.AnimationParams = animationParams;; // we actually want his feet in the middle, not his chest which is where the origin is spriteParams.Position = new Vector2(startingLocation.worldPosition.X + spriteParams.Origin.X, startingLocation.worldPosition.Y); this.rightSprite = new Animated2DSprite(spriteParams); spriteParams.SpriteEffect = SpriteEffects.FlipHorizontally; this.leftSprite = new Animated2DSprite(spriteParams); this.Placement = startingLocation; this.direction = Direction.None; this.movementSpeed = movementSpeed; this.activeSprite = this.rightSprite; this.BoundingBox = Helper.getPersonBBox(this.activeSprite.Position); this.previousTypeOfSpace = AIManager.getInstance().Board[this.Placement.index.Y, this.Placement.index.X]; }
public Guard(ContentManager content, Placement startingLocation, string state, string movementDirection) : base(content, "Guard", startingLocation, MOVEMENT_SPEED_WALK) { this.callBackDelegate = delegate(Stack <Point> path) { if (this != null) { this.path = path; } }; // figure out our direction if (movementDirection == MovementDirection.Clockwise.ToString()) { this.movementDirection = MovementDirection.Clockwise; } else { this.movementDirection = MovementDirection.CounterClockwise; } // figure out our starting state State initalState; if (state == State.Chase.ToString()) { initalState = State.Chase; } else if (state == State.Patrol.ToString()) { initalState = State.Patrol; } else if (state == State.Standing.ToString()) { initalState = State.Standing; } else { initalState = State.NotSpawned; } updateState(initalState); if (this.currentState == State.Patrol && !AIManager.getInstance().PlayerDetected) { this.destinationWayPoint = AIManager.getInstance().getNextWayPoint(base.Placement.index, this.movementDirection); AIManager.getInstance().requestPath(base.Placement.index, this.destinationWayPoint, delegate(Stack <Point> path) { this.callBackDelegate.Invoke(path); if (this.path != null && this.path.Count >= 1) { this.closestsPoint = this.path.Pop(); } }); } else if (this.currentState == State.Chase || AIManager.getInstance().PlayerDetected) { AIManager.getInstance().requestPath(base.Placement.index, delegate(Stack <Point> path) { this.callBackDelegate.Invoke(path); if (this.path != null && this.path.Count >= 1) { this.closestsPoint = this.path.Pop(); } }); } else if (this.currentState == State.Standing || this.currentState == State.NotSpawned) { // set the closest point to our guards location this.closestsPoint = base.Placement.index; } this.ring = new RadiusRing(content, base.activeSprite.Position); this.openDoorSfx = LoadingUtils.load <SoundEffect>(content, "OpenDoor"); this.prisonCellSfx = LoadingUtils.load <SoundEffect>(content, "CellDoor"); }
protected override void updateLocation(float elapsed) { this.ring.updatePosition(base.activeSprite.Position); Point endNode = AIManager.getInstance().findEndNode(); if (this.closestsPoint == endNode) { StateManager.getInstance().CurrentGameState = StateManager.GameState.GameOver; StateManager.getInstance().TypeOfGameOver = StateManager.GameOverType.Guards; SoundManager.getInstance().sfxEngine.playSoundEffect(this.prisonCellSfx); } if (this.direction != Direction.None) { float moveDistanceX = (this.movementSpeed * elapsed); float moveDistanceY = (this.movementSpeed * elapsed); if (withinDestinationSquare()) { // check if the center is less of a distance than the default via the elapsed * moevment speed Vector2 currentSquaresMid = getMiddleOfCurrentSquare(); Vector2 middleOfSprite = getMiddleOfSprite(); Vector2 max = Vector2.Max(currentSquaresMid, middleOfSprite); Vector2 min = Vector2.Min(currentSquaresMid, middleOfSprite); Vector2 difference = Vector2.Subtract(max, min); if (base.direction == Direction.Up) { if (difference.Y < moveDistanceY) { moveDistanceY = difference.Y; } } else if (base.direction == Direction.Down) { if (difference.Y < moveDistanceY) { moveDistanceY = difference.Y; } } else if (base.direction == Direction.Left) { if (difference.X < moveDistanceX) { moveDistanceX = difference.X; } } else if (base.direction == Direction.Right) { if (difference.X < moveDistanceX) { moveDistanceX = difference.X; } } } Vector2 newPos = base.activeSprite.Position; if (this.direction == Direction.Up) { newPos = new Vector2(this.activeSprite.Position.X, this.activeSprite.Position.Y - moveDistanceY); } else if (this.direction == Direction.Right) { newPos = new Vector2(this.activeSprite.Position.X + moveDistanceX, this.activeSprite.Position.Y); } else if (this.direction == Direction.Down) { newPos = new Vector2(this.activeSprite.Position.X, this.activeSprite.Position.Y + moveDistanceY); } else if (this.direction == Direction.Left) { newPos = new Vector2(this.activeSprite.Position.X - moveDistanceX, this.activeSprite.Position.Y); } base.activeSprite.Position = newPos; } // call the generic code before continuing base.updateLocation(elapsed); if (base.previousPlacement.index != base.Placement.index) { // if we are a door tile play the sfx if (AIManager.getInstance().Board[base.Placement.index.Y, base.Placement.index.X] == BasePathFinder.TypeOfSpace.VariableTerrainLowCost) { SoundManager.getInstance().sfxEngine.playSoundEffect(this.openDoorSfx); } } }
public override void dispose() { if (this.mapWalls != null) { this.mapWalls.dispose(); } if (this.mapFloor != null) { this.mapFloor.dispose(); } if (this.player != null) { this.player.dispose(); } if (this.guards != null) { foreach (Guard guard in this.guards) { guard.dispose(); } } if (this.treasures != null) { foreach (Treasure treasure in this.treasures) { treasure.dispose(); } } if (this.dumpsters != null) { foreach (Dumpster dumpster in this.dumpsters) { dumpster.dispose(); } } if (this.treasure != null) { this.treasure.dispose(); } this.timer.dispose(); this.dustEmitter.dispose(); // sfxs /* * if (this.introSfx != null) { * this.introSfx.Dispose(); * } * if (this.payDaySfx != null) { * this.payDaySfx.Dispose(); * } * if (this.treasureSfx != null) { * this.treasureSfx.Dispose(); * } * if (this.guardDetectedSfx != null) { * this.guardDetectedSfx.Dispose(); * } * if (this.dumpsterCrashSfx != null) { * this.dumpsterCrashSfx.Dispose(); * } * if (this.dumpsterCloseSfx != null) { * this.dumpsterCloseSfx.Dispose(); * }*/ // AI AIManager.getInstance().dispose(); }
public override void render(SpriteBatch spriteBatch) { // render the floor, treasure, than walls this.mapFloor.render(spriteBatch); this.treasureText.render(spriteBatch); this.treasure.render(spriteBatch); foreach (Treasure treasure in this.treasures) { treasure.render(spriteBatch); } this.mapWalls.render(spriteBatch); foreach (Dumpster dumpster in this.dumpsters) { dumpster.render(spriteBatch); } this.player.render(spriteBatch); foreach (Guard guard in this.guards) { guard.render(spriteBatch); } this.timer.render(spriteBatch); if (StateManager.getInstance().CurrentGameState == StateManager.GameState.Reset || StateManager.getInstance().CurrentGameState == StateManager.GameState.Waiting || (StateManager.getInstance().CurrentGameState == StateManager.GameState.InGameMenu && StateManager.getInstance().PreviousGameState == StateManager.GameState.Waiting)) { this.startButton.render(spriteBatch); } this.dustEmitter.render(spriteBatch); #if DEBUG if (this.showCD) { Color debugColour = Color.Green; DebugUtils.drawBoundingBox(spriteBatch, this.player.BoundingBox, debugColour, ResourceManager.getInstance().ButtonLineTexture); foreach (Guard guard in this.guards) { DebugUtils.drawBoundingBox(spriteBatch, guard.BoundingBox, debugColour, ResourceManager.getInstance().ButtonLineTexture); DebugUtils.drawBoundingSphere(spriteBatch, guard.Ring.BoundingSphere, debugColour, ResourceManager.getInstance().DebugRing); } foreach (BoundingBox box in CollisionManager.getInstance().MapBoundingBoxes) { DebugUtils.drawBoundingBox(spriteBatch, box, debugColour, ResourceManager.getInstance().ButtonLineTexture); } foreach (Treasure treasure in this.treasures) { DebugUtils.drawBoundingBox(spriteBatch, treasure.BoundingBox, debugColour, ResourceManager.getInstance().ButtonLineTexture); } foreach (Dumpster dumpster in this.dumpsters) { DebugUtils.drawBoundingBox(spriteBatch, dumpster.BoundingBox, debugColour, ResourceManager.getInstance().ButtonLineTexture); } } if (this.showWayPoints) { List <Point> wayPoints = AIManager.getInstance().WayPoints; foreach (Point wayPoint in wayPoints) { spriteBatch.Draw(ResourceManager.getInstance().DebugChip, new Placement(wayPoint).worldPosition, Color.Purple); } } if (this.showAI) { // draw where we cannot walk for (int y = 0; y < 18; y++) { for (int x = 0; x < 21; x++) { if (AIManager.getInstance().Board[y, x] == BasePathFinder.TypeOfSpace.Unwalkable) { spriteBatch.Draw(ResourceManager.getInstance().DebugChip, new Placement(new Point(x, y)).worldPosition, Color.Red); } } } } #endif }
public override void update(float elapsed) { if (this.player != null) { this.treasureText.WrittenText = " x " + this.player.CapturedTreasures; } if (this.mapWalls != null) { this.mapWalls.update(elapsed); } this.dustEmitter.update(elapsed); Vector2 mousePos = InputManager.getInstance().MousePosition; if (StateManager.getInstance().CurrentGameState == StateManager.GameState.Waiting) { this.startButton.processActorsMovement(mousePos); // mouse over sfx if (this.startButton.isActorOver(mousePos)) { if (!base.previousMouseOverButton) { SoundManager.getInstance().sfxEngine.playSoundEffect(ResourceManager.getInstance().MouseOverSfx); } base.previousMouseOverButton = true; } else { base.previousMouseOverButton = false; } if (InputManager.getInstance().wasLeftButtonPressed() || InputManager.getInstance().wasButtonPressed(PlayerIndex.One, Buttons.A)) { if (this.startButton.isActorOver(mousePos)) { StateManager.getInstance().CurrentGameState = StateManager.GameState.Active; } } } else if (StateManager.getInstance().CurrentGameState == StateManager.GameState.Active) { // check if the player won foreach (Point point in this.entryExitPoints) { if (point == this.player.Placement.index) { StateManager.getInstance().CurrentGameState = StateManager.GameState.GameOver; if (this.player.CapturedTreasures >= 1) { StateManager.getInstance().TypeOfGameOver = StateManager.GameOverType.Player; SoundManager.getInstance().sfxEngine.playSoundEffect(this.payDaySfx); } else { StateManager.getInstance().TypeOfGameOver = StateManager.GameOverType.None; } break; } } this.timer.update(elapsed); this.player.update(elapsed); foreach (Guard guard in this.guards) { guard.update(elapsed); if (guard.Ring.BoundingSphere.Intersects(this.player.BoundingBox) && !this.player.Hiding) { // did we JUST get detected? if (!AIManager.getInstance().PlayerDetected) { SoundManager.getInstance().sfxEngine.playSoundEffect(this.guardDetectedSfx); } AIManager.getInstance().PlayerDetected = true; } } foreach (Treasure treasure in this.treasures) { treasure.update(elapsed); if (treasure.BoundingBox.Intersects(this.player.BoundingBox)) { treasure.PickedUp = true; this.player.CapturedTreasures++; SoundManager.getInstance().sfxEngine.playSoundEffect(this.treasureSfx, .5f); break; } } // are we trying to enter a dumpster if (InputManager.getInstance().wasKeyPressed(Keys.Space) || InputManager.getInstance().wasButtonPressed(PlayerIndex.One, Buttons.A)) { // check if we are close to a dumpster foreach (Dumpster dumpster in dumpsters) { if (dumpster.BoundingBox.Intersects(this.player.BoundingBox) && dumpster.AcceptingOccupants) { this.player.Hiding = !this.player.Hiding; // reverse the bool if (!this.player.Hiding) { // make this dumpster unusable again dumpster.AcceptingOccupants = false; SoundManager.getInstance().sfxEngine.playSoundEffect(this.dumpsterCloseSfx); } else { SoundManager.getInstance().sfxEngine.playSoundEffect(this.dumpsterCrashSfx); } break; } } } } // Transitions #region Transitions if (StateManager.getInstance().CurrentTransitionState == StateManager.TransitionState.TransitionIn) { // start our intro sound effect if we just started to transition if (StateManager.getInstance().PreviousGameState == StateManager.GameState.MapSelection && !SoundManager.getInstance().sfxEngine.isPlaying(LEVEL_ENTRY_SFX_NAME)) { StateManager.getInstance().CurrentGameState = StateManager.GameState.Waiting; SoundManager.getInstance().sfxEngine.playSoundEffect(this.introSfx); // initially create some particles for (int i = 0; i < 40; i++) { this.dustEmitter.createParticle(); } } Color colour = base.fadeIn(Color.White); this.mapWalls.updateColours(base.fadeIn(this.mapWalls.Colour)); this.mapFloor.updateColours(base.fadeIn(this.mapFloor.Colour)); foreach (Treasure treasure in this.treasures) { treasure.updateColours(colour); } foreach (Dumpster dumpster in this.dumpsters) { dumpster.updateColours(colour); } this.player.updateColours(colour); foreach (Guard guard in this.guards) { guard.updateColours(colour); } this.startButton.updateColours(base.fadeIn(ResourceManager.TEXT_COLOUR)); if (this.startButton.isActorOver(mousePos)) { this.startButton.updateColours(base.fadeIn(ResourceManager.MOUSE_OVER_COLOUR)); } // HUD this.treasure.LightColour = colour; this.treasureText.LightColour = base.fadeIn(ResourceManager.TEXT_COLOUR); this.timer.updateColours(base.fadeIn(ResourceManager.TEXT_COLOUR), base.fadeIn(this.timer.ActiveTimeColour)); } else if (StateManager.getInstance().CurrentTransitionState == StateManager.TransitionState.TransitionOut) { Color colour = base.fadeOut(Color.White); this.mapWalls.updateColours(base.fadeOut(this.mapWalls.Colour)); this.mapFloor.updateColours(base.fadeOut(this.mapFloor.Colour)); foreach (Treasure treasure in this.treasures) { treasure.updateColours(colour); } foreach (Dumpster dumpster in this.dumpsters) { dumpster.updateColours(colour); } this.player.updateColours(colour); foreach (Guard guard in this.guards) { guard.updateColours(colour); } this.startButton.updateColours(base.fadeOut(ResourceManager.TEXT_COLOUR)); if (this.startButton.isActorOver(mousePos)) { this.startButton.updateColours(base.fadeOut(ResourceManager.MOUSE_OVER_COLOUR)); } this.dustEmitter.updateColours(base.fadeOut(DustParticleEmitter.COLOUR)); // HUD this.treasure.LightColour = colour; this.treasureText.LightColour = base.fadeOut(ResourceManager.TEXT_COLOUR); this.timer.updateColours(base.fadeOut(ResourceManager.TEXT_COLOUR), base.fadeOut(this.timer.ActiveTimeColour)); // if the alarm is blaring, turn it off if (SoundManager.getInstance().sfxEngine.isPlaying(Timer.DETECTED_SFX_NAME)) { SoundManager.getInstance().sfxEngine.stop(Timer.DETECTED_SFX_NAME); } } // if our transition is up if (base.transitionTimeElapsed()) { if (StateManager.getInstance().CurrentTransitionState == StateManager.TransitionState.TransitionIn) { StateManager.getInstance().CurrentTransitionState = StateManager.TransitionState.None; if (StateManager.getInstance().PreviousGameState == StateManager.GameState.MapSelection) { StateManager.getInstance().CurrentGameState = StateManager.GameState.Waiting; } } else if (StateManager.getInstance().CurrentTransitionState == StateManager.TransitionState.TransitionOut) { StateManager.getInstance().CurrentTransitionState = StateManager.TransitionState.TransitionIn; // clear out the particles this.dustEmitter.Particles.Clear(); } } if (StateManager.getInstance().CurrentTransitionState == StateManager.TransitionState.None && StateManager.getInstance().CurrentGameState == StateManager.GameState.Waiting || StateManager.getInstance().CurrentGameState == StateManager.GameState.Active) { if (InputManager.getInstance().wasKeyPressed(Keys.Escape) || InputManager.getInstance().wasButtonPressed(PlayerIndex.One, Buttons.Start)) { StateManager.getInstance().CurrentGameState = StateManager.GameState.InGameMenu; StateManager.getInstance().CurrentTransitionState = StateManager.TransitionState.TransitionOut; } } #endregion Transitions #if DEBUG if (InputManager.getInstance().wasKeyPressed(Keys.D1)) { this.showAI = !this.showAI; } else if (InputManager.getInstance().wasKeyPressed(Keys.D2)) { this.showCD = !this.showCD; } else if (InputManager.getInstance().wasKeyPressed(Keys.D3)) { this.showWayPoints = !this.showWayPoints; } else if (InputManager.getInstance().wasKeyPressed(Keys.R)) { reset(); } // map editor MapEditor.getInstance().update(); #endif base.update(elapsed); }
public void reset() { string mapInformation = Directory.GetCurrentDirectory() + "\\" + ResourceManager.MAP_FOLDER + StateManager.getInstance().MapInformation; XmlReader xmlReader = XmlReader.Create(mapInformation + "Identifiers.xml"); this.entryExitPoints = new List <Point>(); Point playersLocation = new Point(); Color floorColour = Color.White; Color wallColour = Color.Black; List <Point> guardLocations = new List <Point>(); List <string> guardDirectins = new List <string>(); List <string> guardStates = new List <string>(); List <Point> treasureLocations = new List <Point>(); List <Point> dumpsterLocations = new List <Point>(); List <Point> wayPoints = new List <Point>(); float time = 5f; //default of 5 minutes try { XmlDocument doc = new XmlDocument(); doc.Load(xmlReader); // load the map information MapLoader.loadLevelInformation(doc, ref wallColour, ref floorColour, ref time); // load the player information MapLoader.loadPlayerInformation(doc, ref playersLocation); // load the treasure information MapLoader.loadGenericPointList(doc, MapEditor.MappingState.Treasure, out treasureLocations); // load the dumpster information MapLoader.loadGenericPointList(doc, MapEditor.MappingState.Dumpster, out dumpsterLocations); // load the entry information MapLoader.loadGenericPointList(doc, MapEditor.MappingState.GuardEntry, out entryExitPoints); // load the guard information MapLoader.loadGuardInformation(doc, ref guardLocations, ref guardDirectins, ref guardStates); // load the waypoint information MapLoader.loadGenericPointList(doc, MapEditor.MappingState.WayPoint, out wayPoints); } finally { xmlReader.Close(); } // load our map MapLoader.load(content, mapInformation + Constants.FILE_EXTENSION, floorColour, wallColour, out mapWalls, out mapFloor); // let our AI manager know about the maps way points AIManager.getInstance().WayPoints = wayPoints; // load player at starting point this.player = new Player(this.content, new Placement(playersLocation)); // load treasure at starting points int treasureSize = treasureLocations.Count; this.treasures = new Treasure[treasureSize]; string treasureFileName; Random random = new Random(); for (int i = 0; i < treasureSize; i++) { treasureFileName = "Treasure" + random.Next(1, 3); this.treasures[i] = new Treasure(this.content, treasureFileName, new Placement(treasureLocations[i])); } // load dumpsters at starting points int dumpsterSize = dumpsterLocations.Count; this.dumpsters = new Dumpster[dumpsterSize]; for (int i = 0; i < dumpsterSize; i++) { this.dumpsters[i] = new Dumpster(this.content, "DumpsterOpen", "DumpsterClosed", new Placement(dumpsterLocations[i])); // ensure these places are unwalkable by the guards AIManager.getInstance().Board[dumpsterLocations[i].Y, dumpsterLocations[i].X] = BasePathFinder.TypeOfSpace.Unwalkable; } // load guard(s) at starting points int guardSize = guardLocations.Count; this.guards = new Person[guardSize]; Placement placement; for (int i = 0; i < guardSize; i++) { placement = new Placement(guardLocations[i]); this.guards[i] = new Guard(this.content, placement, guardStates[i], guardDirectins[i]); } this.timer.reset(time); this.treasureText.WrittenText = "x " + this.player.CapturedTreasures; this.dustEmitter.PlayerPosition = Vector2.Add(this.player.Placement.worldPosition, new Vector2(ResourceManager.TILE_SIZE / 2, 0f)); StateManager.getInstance().CurrentGameState = StateManager.GameState.Waiting; }