Exemplo n.º 1
0
        /// <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);

            TitleFont = Content.Load<SpriteFont>("TitleFont");
            MenuFont = Content.Load<SpriteFont>("ButtonFont");

            player = new Player();
            player.X = 0;
            player.Y = 0;
            player.Z = 1;
            player.Texture = Content.Load<Texture2D>("Character\\Character Boy");

            inputDelayMax = new TimeSpan(0, 0, 0, 0, 100);
            inputDelayCurrent = new TimeSpan();

            DataManager = new thegame.DataManager();

            MapParser.Parse("maps\\demo.txt", DataManager, Content);
            grid = DataManager.getGrid("start");
        }
Exemplo n.º 2
0
        private static void translateEntries(List<MapEntry> entries, DataManager manager, ContentManager content)
        {
            Dictionary<string, EPoint> points = new Dictionary<string, EPoint>();
            Dictionary<string, Texture2D> textures = new Dictionary<string, Texture2D>();
            Dictionary<string, ETile> tiles = new Dictionary<string, ETile>();
            Dictionary<string, Grid> grids = new Dictionary<string, Grid>();
            Dictionary<string, ECell> cells = new Dictionary<string, ECell>();
            Dictionary<string, double> numbers = new Dictionary<string, double>();
            Dictionary<string, bool> booleans = new Dictionary<string, bool>();
            Dictionary<string, string> strings = new Dictionary<string, string>();

            foreach (MapEntry entry in entries)
            {
                if (entry.TypeName == "Texture")
                {
                    Texture2D texture = content.Load<Texture2D>(entry[0]);
                    textures.Add(entry.EntryName, texture);
                }
                else if (entry.TypeName == "Point")
                {
                    EPoint point = new EPoint(
                        int.Parse(entry[0]),
                        int.Parse(entry[1]),
                        int.Parse(entry[2]));
                    points.Add(entry.EntryName, point);
                }
                else if (entry.TypeName == "Tile")
                {
                    ETile tile = new ETile();
                    tile.Texture = textures[entry[0]];
                    tile.Solid = bool.Parse(entry[1]);

                    tiles.Add(entry.EntryName, tile);
                }
                else if (entry.TypeName == "Grid")
                {
                    EPoint gridSize = points[entry[0]];
                    EPoint gridOrigin = points[entry[1]];
                    EPoint gridTileOffset = points[entry[2]];
                    EPoint gridTileSize = points[entry[3]];
                    EPoint playerStart = points[entry[4]];

                    Grid grid = new Grid(
                        gridSize.X,
                        gridSize.Y,
                        gridSize.Z,
                        null,
                        gridTileOffset.X,
                        gridTileOffset.Y,
                        gridTileSize.X,
                        gridTileSize.Y,
                        gridTileOffset.Z,
                        gridOrigin.X,
                        gridOrigin.Y);

                    grid.ShadowEast = content.Load<Texture2D>("Block Shadow\\Shadow East");
                    grid.ShadowEast = content.Load<Texture2D>("Block Shadow\\Shadow North East");
                    grid.ShadowEast = content.Load<Texture2D>("Block Shadow\\Shadow North West");
                    grid.ShadowEast = content.Load<Texture2D>("Block Shadow\\Shadow North");
                    grid.ShadowEast = content.Load<Texture2D>("Block Shadow\\Shadow West");
                    grid.ShadowEast = content.Load<Texture2D>("Block Shadow\\Shadow South East");
                    grid.ShadowEast = content.Load<Texture2D>("Block Shadow\\Shadow South West");
                    grid.ShadowEast = content.Load<Texture2D>("Block Shadow\\Shadow South");
                    grid.ShadowEast = content.Load<Texture2D>("Block Shadow\\Shadow East");

                    grids.Add(entry.EntryName, grid);
                }
                else if (entry.TypeName == "Cell")
                {
                    ECell cell = new ECell();

                    cell.Point = new EPoint(int.Parse(entry[0]), int.Parse(entry[1]), int.Parse(entry[2]));
                    cell.Grid = grids[entry[3]];
                    cell.Tile = tiles[entry[4]];

                    cell.Grid.setTile(
                        cell.Point.X,
                        cell.Point.Y,
                        cell.Point.Z,
                        cell.Tile.Texture,
                        cell.Tile.Solid);

                    if (!string.IsNullOrEmpty(entry.EntryName))
                        cells.Add(entry.EntryName, cell);
                }
                else if (entry.TypeName == "Number")
                {
                    numbers.Add(entry.EntryName, double.Parse(entry[0]));
                }
                else if (entry.TypeName == "Boolean")
                {
                    booleans.Add(entry.EntryName, bool.Parse(entry[0]));
                }
                else if (entry.TypeName == "String")
                {
                    strings.Add(entry.EntryName, entry[0]);
                }
            }

            foreach (string key in grids.Keys)
            {
                manager.AddItem(key, grids[key]);
            }

            foreach (string key in textures.Keys)
            {
                manager.AddItem(key, textures[key]);
            }
        }
Exemplo n.º 3
0
 public void AddItem(string name, Grid grid)
 {
     grids.Add(name, grid);
 }