public override void LoadContent() { base.LoadContent(); XmlManager<Player> playerLoader = new XmlManager<Player>(); XmlManager<Map> mapLoader = new XmlManager<Map>(); texturebg = content.Load<Texture2D>("Images/paper"); font = content.Load<SpriteFont>("Fonts/Test"); player = playerLoader.Load("Load/Game/Player.xml"); map = mapLoader.Load("Load/Game/Maps/Map_Two.xml"); map.LoadContent(); player.LoadContent(); music = content.Load<SoundEffect>("Music/sad"); paper = content.Load<SoundEffect>("Music/paper"); music.Play(); player.Image.Position = new Vector2(320, 240); }
public override void LoadContent() { base.LoadContent(); XmlManager<Player> playerLoader = new XmlManager<Player>(); XmlManager<Map> mapLoader = new XmlManager<Map>(); texturebg = content.Load<Texture2D>("Images/paper"); font = content.Load<SpriteFont>("Fonts/Test"); player = playerLoader.Load("Load/Game/Player.xml"); map = mapLoader.Load("Load/Game/Maps/Map_One.xml"); music = content.Load<SoundEffect>("Music/midnightwaltz"); paper = content.Load<SoundEffect>("Music/paper"); typewriter = content.Load<SoundEffect>("Music/typewriter"); map.LoadContent(); player.LoadContent(); sei = music.CreateInstance(); sei.Volume = 0.5f; sei.Play(); player.Image.Position = new Vector2(320,240); }
public void Update(GameTime gameTime, ref Player player) { foreach (Layer l in Layer) l.Update(gameTime, ref player); }
public void Update(GameTime gameTime, ref Player player) { Image.Update(gameTime);/////////////////////////////////////////////////////////////////////////////// foreach (Tile tile in underlayTiles) tile.Update(gameTime, ref player); foreach (Tile tile in overlayTiles) tile.Update(gameTime, ref player); }
public void Update(GameTime gameTime, ref Player player) { if(state=="Interaction") { Rectangle tileRect = new Rectangle((int)Position.X, (int)Position.Y, srcRect.Width, srcRect.Height); Rectangle playerRect = new Rectangle((int)player.Image.Position.X, (int)player.Image.Position.Y, player.Image.SourceRect.Width, player.Image.SourceRect.Height); if (playerRect.Intersects(tileRect)) { GameScreen.popUp(new Vector2((int)Position.X, (int)Position.Y)); // if (player.Velocity.Y > 0 || player.Velocity.Y < 0) // diag = false; } } if (state == "Passive") { Rectangle tileRect = new Rectangle((int)Position.X, (int)Position.Y, srcRect.Width, srcRect.Height); Rectangle playerRect = new Rectangle((int)player.Image.Position.X, (int)player.Image.Position.Y, player.Image.SourceRect.Width, player.Image.SourceRect.Height); if (playerRect.Intersects(tileRect)) if (player.Velocity.Y > 0 || player.Velocity.Y < 0) diag = true; } if(state=="Solid") { Rectangle tileRect = new Rectangle((int)Position.X, (int)Position.Y, srcRect.Width, srcRect.Height); Rectangle playerRect = new Rectangle((int)player.Image.Position.X, (int)player.Image.Position.Y, player.Image.SourceRect.Width, player.Image.SourceRect.Height); if (playerRect.Intersects(tileRect)) { if (player.Velocity.X < 0) player.Image.Position.X = tileRect.Right; else if (player.Velocity.X > 0) player.Image.Position.X = tileRect.Left - player.Image.SourceRect.Width; else if (player.Velocity.Y < 0) player.Image.Position.Y = tileRect.Bottom; else player.Image.Position.Y = tileRect.Top - player.Image.SourceRect.Height; diag = false; // player.Velocity.Y = 0; //player walk while? } } if (state == "Ladder") { Rectangle tileRect = new Rectangle((int)Position.X, (int)Position.Y, srcRect.Width, srcRect.Height); Rectangle playerRect = new Rectangle((int)player.Image.Position.X, (int)player.Image.Position.Y, player.Image.SourceRect.Width, player.Image.SourceRect.Height); if (playerRect.Intersects(tileRect)) { if (player.Velocity.X < 0) player.Image.Position.X = tileRect.Right-31; else if(player.Velocity.X > 0) player.Image.Position.X = tileRect.Left; diag = false; //player.Velocity.Y = 0; //player walk while? } } if (state == "Portal") { Rectangle tileRect = new Rectangle((int)Position.X, (int)Position.Y, srcRect.Width, srcRect.Height); Rectangle playerRect = new Rectangle((int)player.Image.Position.X, (int)player.Image.Position.Y, player.Image.SourceRect.Width, player.Image.SourceRect.Height); if (playerRect.Intersects(tileRect)) { player.Image.Position = new Vector2(-640,-480); ScreenManager.Instance.ChangeScreen(nextScreen); } } }