// load content for the screen
        public override void LoadContent(ContentManager Content, ref Player player)
        {
            base.LoadContent(Content, ref player);

            if (font == null)
            {
                font = content.Load <SpriteFont>("Font1");
            }

            imageNumber = 0;
            fileManager = new FileManager();
            images      = new List <Texture2D>();

            // load Image names from file
            fileManager.LoadContent("Content/SplashFile.cwh", "");

            for (int i = 0; i < fileManager.Attributes.Count; i++)
            {
                for (int j = 0; j < fileManager.Attributes[i].Count; j++)
                {
                    switch (fileManager.Attributes[i][j])
                    {
                    case "Image":
                        images.Add(content.Load <Texture2D>(fileManager.Contents[i][j]));
                        break;
                    }
                }
            }

            map = new Map();
            map.LoadContent(content, "MapSplashScreen");
        }
Beispiel #2
0
        // load the layer information from a file
        public void LoadContent(ContentManager Content, Map map, Vector2 tileDimensions, string layerID)
        {
            content     = new ContentManager(Content.ServiceProvider, "Content");
            fileManager = new FileManager();

            tiles = new List <Tile>();
            solid = new List <string>();
            goal  = new List <string>();

            string nullTile = "";

            fileManager.LoadContent("Content/" + map.ID + ".cwh", layerID);       // loads layer from file
            int yIndex = 0;

            // loop through each attribute
            for (int i = 0; i < fileManager.Attributes.Count; i++)
            {
                for (int j = 0; j < fileManager.Attributes[i].Count; j++)
                {
                    switch (fileManager.Attributes[i][j])
                    {
                    case "LayerSize":
                        string[] split = fileManager.Contents[i][j].Split(',');
                        layerDimensions = new Vector2(float.Parse(split[0]) * tileDimensions.X, float.Parse(split[1]) * tileDimensions.Y);
                        break;

                    case "TileSet":
                        tileSheet = content.Load <Texture2D>(fileManager.Contents[i][j]);
                        SplitTilesetInSrcRects();
                        break;

                    case "Goal":
                        goal.Add(fileManager.Contents[i][j]);
                        break;

                    case "Solid":
                        solid.Add(fileManager.Contents[i][j]);
                        break;

                    case "Motion":
                        break;

                    case "NullTile":
                        nullTile = fileManager.Contents[i][j];
                        break;

                    case "StartLayer":

                        Tile.State tempState;

                        // load the information foreach tile of the layer
                        for (int k = 0; k < fileManager.Contents[i].Count; k++)
                        {
                            if (fileManager.Contents[i][k] != nullTile)     // set nothing if null tile
                            {
                                int tilesetIdx = int.Parse(fileManager.Contents[i][k]);
                                tiles.Add(new Tile(this));

                                if (solid.Contains(fileManager.Contents[i][k]))
                                {
                                    tempState = Tile.State.Solid;
                                }
                                else if (goal.Contains(fileManager.Contents[i][k]))
                                {
                                    tempState = Tile.State.Goal;
                                }
                                else
                                {
                                    tempState = Tile.State.Passive;
                                }

                                // set the information for the current tile
                                tiles[tiles.Count - 1].SetTile(tempState, new Vector2(k * 32, yIndex * 32), GetTileSrcRect(tilesetIdx));
                            }
                        }
                        yIndex++;
                        break;
                    }
                }
            }
        }