Ejemplo n.º 1
0
        /// <summary>
        /// Change the current map, arriving at the given portal if any.
        /// </summary>
        /// <param name="contentName">The asset name of the new map.</param>
        /// <param name="originalPortal">The portal from the previous map.</param>
        public static void ChangeMap(string contentName, Portal originalPortal)
        {
            // make sure the content name is valid
            string mapContentName = contentName;
            if (!mapContentName.StartsWith(@"Maps\"))
            {
                mapContentName = Path.Combine(@"Maps", mapContentName);
            }

            // check for trivial movement - typically intra-map portals
            if ((Map != null) && (Map.Name == mapContentName))
            {
                SetMap(Map, originalPortal == null ? null :
                    Map.GetPortal(originalPortal.DestinationMap));
            }

            // load the map
            changeMap = MapContentManager.Load<Map>(mapContentName);

            // modify the map based on the world changes (removed chests, etc.).
            //ModifyMap(map);

            // start playing the music for the new map
            //AudioManager.PlayMusic(map.MusicCueName);

            // set the new map into the tile engine
            SetMap(changeMap, originalPortal == null ? null :
                changeMap.GetPortal(originalPortal.DestinationPortal));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adjusts the size of the map.  If there is already a map created, clears the old map and
 /// initializes a new one.  None of the data from the old map is preserved.
 /// </summary>
 /// <param name="offset"></param>
 private void AdjustSize(int offset)
 {
     resolution += offset;
     resolution = (int)MathHelper.Clamp(resolution, 1, 11);
     size = (int)Math.Pow(2, resolution) + 1;
     if (map != null)
         map.Destroy();
     map = new Map(size, size);
     map.AddColorMap(Map.DefaultColorMap);
 }
Ejemplo n.º 3
0
        public static void Update(GameTime gameTime)
        {
            if (!fadeIn && !fadeOut)
            {
                HandleInput();
                inputHandling = true;
            }
            else
                inputHandling = false;

            if (fadeIn)
            {
                FadeIn();
                if (map != null &&
                    changeMap != null &&
                    map != changeMap)
                {
                    map = changeMap;
                    Player.Position = changePos;
                }
                UpdateMap(gameTime);
            }
            else if (fadeOut)
            {
                FadeOut();
            }
            else if (!fadeOut && !fadeIn)
                UpdateMap(gameTime);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Set the map in use by the tile engine.
        /// </summary>
        /// <param name="map">The new map for the tile engine.</param>
        /// <param name="portal">The portal the party is entering on, if any.</param>
        public static void SetMap(Map newMap, Portal portalEntry)
        {
            // check the parameter
            if (newMap == null)
            {
                throw new ArgumentNullException("newMap");
            }

            // assign the new map
            changeMap = newMap;

            // move the party to its initial position
            if (portalEntry == null)
            {
                // no portal - use the spawn position
                Player.Position = new Vector2(changeMap.SpawnMapPosition.X * Map.TILE_WIDTH,
                                            changeMap.SpawnMapPosition.Y * Map.TILE_HEIGHT);
            }
            else
            {
                // use the portal provided, which may include automatic movement
                changePos = new Vector2(portalEntry.Position.X * Map.TILE_WIDTH,
                                            portalEntry.Position.Y * Map.TILE_HEIGHT);

                Player.SetAutoMovement(new Vector2(portalEntry.AutoMotion.X * Map.TILE_WIDTH,
                    portalEntry.AutoMotion.Y * Map.TILE_HEIGHT));

                motion = Vector2.Zero;
            }
        }
Ejemplo n.º 5
0
        public static void Load(ContentManager cm)
        {
            if (map != null)
                map.Reset();

            MapContentManager = cm;
            map = MapContentManager.Load<Map>("Maps/Start");
            font = MapContentManager.Load<SpriteFont>("Arial");
            boxTexture = MapContentManager.Load<Texture2D>("Textures/tile");
            Map.CollisionTexture = MapContentManager.Load<Texture2D>("Textures/collision");
            Map.BlockTexture = MapContentManager.Load<Texture2D>("Textures/block");
            Block b = new Block();
            b.Position = new Vector2(5, 4);
            b.Size = new Vector2(32, 32);
            b.IsMoveable = true;
            map.Blocks.Add(b);
            map.SetIndex(LayerType.Collision, (int)b.Position.X, (int)b.Position.Y, 1);

            player = new Player();
            Player.Load(MapContentManager, "Textures/Player");
            Player.Position = new Vector2(64, 64);

            fadeIn = true;

            fadeTexture = MapContentManager.Load<Texture2D>("Textures/fade");
        }
Ejemplo n.º 6
0
 public void Initialize()
 {
     // TODO
     map = new Map(5, 5);
 }