示例#1
0
        public void Update(GameTime gameTime, WorldMapCamera camera)
        {
            if (!IsAnimating) return;

            if (totalFrames == -1) totalFrames = 1 * 1;

            timer += (float)gameTime.ElapsedGameTime.TotalSeconds;

            
        }
示例#2
0
        private void LoadMap(string assetName)
        {
            //List of Portals declared for traveling between World map and scrolling levels
            Statics.Portals = new List<Portal>();
            
            Statics.ClipMap = new Dictionary<Vector2, Rectangle>();

            map = content.Load<Map>(assetName);

            camera = new WorldMapCamera(new Vector2(map.Width, map.Height), new Vector2(map.TileWidth, map.TileHeight), new Vector2(Statics.Game.GraphicsDevice.Viewport.Width, Statics.Game.GraphicsDevice.Viewport.Height));

            MapObjectLayer objects = map.GetLayer("Objects") as MapObjectLayer;
            
            //Read in information about portals from tmx file
            foreach (MapObject obj in objects.Objects)
            {
                switch (obj.Name)
                {
                    case "PlayerStart":
                        if (Statics.WorldPlayer == null)
                        {
                            Statics.WorldPlayer = new WorldPlayer(new Vector2(obj.Location.X + (obj.Location.Width / 2), obj.Location.Y), new Vector2(91f, 91f));
                            Statics.WorldPlayer.LoadContent(content, "Sprites\\Characters\\Warrior1WalkLeft");
                            Statics.WorldPlayer.Map = map;
                        }
                        else
                        {
                            Statics.WorldPlayer.Position = new Vector2(obj.Location.X + (obj.Location.Width / 2), obj.Location.Y);
                        }
                        break;
                    case "Portal1":
                    case "Portal2":
                    case "Portal3":
                    case "Portal4":
                        Portal portal = new Portal();
                        portal.Position = new Vector2(obj.Location.X, obj.Location.Y);
                        portal.Size = new Vector2(obj.Location.Width, obj.Location.Height);
                        portal.LevelName = obj.Properties["LevelName"].Value;
                        string[] tileLoc = obj.Properties["DestinationTileLocation"].Value.Split(',');
                        portal.DestinationTileLocation = new Vector2(Convert.ToInt32(tileLoc[0]), Convert.ToInt32(tileLoc[1]));
                        Statics.Portals.Add(portal);
                        break;
                }
            }

            Statics.WorldPlayer.UpdateBounds(map.TileWidth, map.TileHeight);
    //        camera.FocusOn(Statics.WorldPlayer);

            LoadClipMap();
        }