public GameData(MapData map) { Maps.Add(map); StartMap = map; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { if (game == null) { game = GameData.ReadFromFile("../../../../../Game1.game"); } map = game.StartMap; // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); Texture2D bgSprite = Content.Load<Texture2D>("space"); background = new Background(bgSprite, (int)myScreenSize.X, (int)myScreenSize.Y); // TODO: use this.Content to load your game content here // Make the hero Texture2D heroImage = Content.Load<Texture2D>("hero"); Texture2D shadow = Content.Load<Texture2D>("shadow"); Texture2D[] heroImages = {Content.Load<Texture2D>("hero0"), Content.Load<Texture2D>("hero1"), Content.Load<Texture2D>("hero2"), Content.Load<Texture2D>("hero3")}; Vector2 center = myScreenSize / 2; myAnimatedHero = new AnimatedHero(heroImages, shadow, center, myScreenSize); LoadMap(map); overlay = new SplashScreen(GraphicsDevice, Content); }
public void LoadMap(MapData map) { this.map = map; mySprites.Clear(); myPlatforms.Clear(); myWordSprites.Clear(); Vector2 center = myScreenSize / 2; Texture2D shadow = Content.Load<Texture2D>("shadow"); //Make a Platform Texture2D plat45 = Content.Load<Texture2D>("platform45squished"); foreach (PlatformData data in map.Platforms) { if (myAnimatedHero.Items.Contains(data.Item)) { data.Item = null; } PlatformSprite platform = new PlatformSprite(plat45, data); mySprites.Add(platform); myPlatforms.Add(platform); platform.LoadItemTextures(Content, shadow); } SpriteFont font = Content.Load<SpriteFont>("DefaultFont"); foreach (WordCloudData wordCloud in map.WordClouds) { foreach (WordData word in wordCloud.Words) { myWordSprites.Add(new WordSprite(word, font)); } } //It's important to keep Hero added after the other sprites! mySprites.Add(myAnimatedHero); myAnimatedHero.Reset(); int startIndex = map.Platforms.IndexOf(map.startPlatform); if (startIndex >= 0) { PlatformSprite startPlatform = myPlatforms[startIndex]; startPlatform.Update(0); myAnimatedHero.myPosition = myPlatforms[startIndex].myPosition; myAnimatedHero.currentPlatform = myPlatforms[startIndex]; } Update(new GameTime()); offset = center - myAnimatedHero.myPosition; }
public MapTransition(GraphicsDevice graphicsDevice, ContentManager content, MapData map) : base(graphicsDevice, content) { this.map = map; }