public void Follow(Enemy source) { this.source = source.center; }
//Depending on the direction we will check to see if the npc is ahead of the player public bool NpcInFrontPlayer(Enemy npc) { switch (walkDir) { case 0: return new Rectangle(footArea.X, footArea.Y + footArea.Height, footArea.Width, footArea.Height).Intersects(npc.footArea); case 1: return new Rectangle(footArea.X + footArea.Width, footArea.Y, footArea.Width, footArea.Height).Intersects(npc.footArea); case 2: return new Rectangle(footArea.X - footArea.Width, footArea.Y, footArea.Width, footArea.Height).Intersects(npc.footArea); } return new Rectangle(footArea.X, footArea.Y - footArea.Height, footArea.Width, footArea.Height).Intersects(npc.footArea); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); rand = new Random(); mediaPlayer = new MediaPlayerGaia(); soundPlayer = new SoundPlayerGaia(); //Load the main player player = new MainPlayer(Content.Load<Texture2D>("Sprites/Will"),Content.Load<Texture2D>("Sprites/WillAttackingSheet") ,Content.Load<Texture2D>("Sprites/freedan"),null,new Vector2(160, 120),64,84); skeleton = new Enemy(20, 5, 4, new Vector2(60, 50), 72, 120, false, Content.Load<Texture2D>("Sprites/Enemy/Skeleton"),true,rand,false); bat = new Enemy(14,9, 3, new Vector2(70, 70), 80, 80, true, Content.Load<Texture2D>("Sprites/Enemy/Bat"),true,rand,false); powerHitter= new Enemy(100, 20, 25, new Vector2(700, 300), 72, 120, false, Content.Load<Texture2D>("Sprites/Enemy/Skeleton"), true, rand,false); lance = new Enemy(10, 10, 10, new Vector2(600, 200), 64, 64, false, Content.Load<Texture2D>("Sprites/NPC/NPCSheet"), true, rand,true); //startUpMapBuilder mapDesigner = new MapReader(Content.Load<Texture2D>("Maps/GTILES32")); //This tells the camera to follow the player as well as setting up the camera cam = new Camera(graphics.GraphicsDevice.Viewport, Vector2.Zero); cam.Follow(player); //load font and set position informFont = Content.Load <SpriteFont>("Text2"); informFont2 = Content.Load<SpriteFont>("Text"); mediaPlayer.init(Content); soundPlayer.init(Content); //Load first level mapDesigner.init(); mapDesigner.buildMap("Content/Maps/level",0); //Connect the map to the main player and temporary enemies player.connectMap(mapDesigner,rand,soundPlayer); skeleton.connectMap(mapDesigner,cam,soundPlayer); bat.connectMap(mapDesigner,cam,soundPlayer); powerHitter.connectMap(mapDesigner,cam,soundPlayer); lance.connectMap(mapDesigner, cam,soundPlayer); enemyHolder[0] = skeleton; enemyHolder[1] = bat; enemyHolder[2] = powerHitter; //sets the game state to opening screen //stats - '0' for title // '1' for openingScreen // '2' for player menu gameState = 0; lance.addText("Hello there, this is just a test to make sure that NPC is "); lance.addText("working correctly. This is another test run because "); lance.addText("we will be reading line by line or max characters. Not "); lance.addText("100% sure what will be done with this yet"); lance.color = Color.LightGreen; lance.textBox = Content.Load<Texture2D>("Sprites/Gui/TextBox"); //sets up the Hud and all the graphics any menu allGui = new AllGui(cam, player, Content.Load<Texture2D>("Sprites/Gui/PlayerGui") , Content.Load<Texture2D>("Sprites/Gui/Transformation2") , Content.Load<Texture2D>("Sprites/Gui/characters2"), Content.Load<Texture2D>("Sprites/Gui/TitleScreen"), Content.Load<Texture2D>("Sprites/Gui/IntroScreenSetup") , Content.Load<Texture2D>("Sprites/Gui/life") , Content.Load<Texture2D>("Sprites/Gui/SelectionScreen"), Content.Load<Texture2D>("Sprites/Gui/PlayerMenu") ,Content.Load<Texture2D>("Sprites/Gui/transitionBackground")); allGui.connect(soundPlayer,Content.Load<SpriteFont>("Text"),mapDesigner); // TODO: use this.Content to load your game content here }