Beispiel #1
0
        public void makeMapFromFile(string filename)
        {
            int xposition = 0;
            int yposition = 0;

            //This directory navigation might have to change for the final product, or even sooner
            string[] lines = System.IO.File.ReadAllLines(@"../../../Map Files/" + filename);

            wallArray = new bool[lines.GetLength(0), lines[0].Length];
            foreach (string line in lines)
            {
                foreach (char c in line)
                {
                    string   image  = Textures.charToFileName[c];
                    string[] images = image.Split(',');
                    bool     solid  = (images[2].Length > 0);
                    if (c == 'f')
                    {
                        BadTile t = new BadTile(xposition, yposition, worldState, images[0], images[1]);
                        collidableTiles.Add(t);
                        tiles.Add(t);
                    }
                    else if (c == 's')
                    {
                        GoodTile t = new GoodTile(xposition, yposition, worldState, images[0], images[1]);
                        collidableTiles.Add(t);
                        tiles.Add(t);
                    }
                    else if (c == 'l')
                    {
                        LockTile t = new LockTile(xposition, yposition, worldState, images[0], images[1]);
                        collidableTiles.Add(t);
                        tiles.Add(t);
                    }
                    else if (c == 'u')
                    {
                        UnlockTile t = new UnlockTile(xposition, yposition, worldState, images[0], images[1]);
                        collidableTiles.Add(t);
                        tiles.Add(t);
                    }
                    else if (!solid)
                    {
                        Tile t = new Tile(xposition, yposition, worldState, images[0], images[1]);
                        tiles.Add(t);
                    }
                    else
                    {
                        Wall w = new Wall(xposition, yposition, worldState, images[0], images[1]);
                        collidableTiles.Add(w);
                        tiles.Add(w);
                        wallArray[yposition / 32, xposition / 32] = true;
                    }
                    xposition += 32;
                }
                xposition  = 0;
                yposition += 32;
            }
        }
Beispiel #2
0
        public void makeMapFromFile(string filename)
        {
            int xposition = 0;
            int yposition = 0;

            //This directory navigation might have to change for the final product, or even sooner

            string[] lines = System.IO.File.ReadAllLines(@"../../../Map Files/" + filename);
            //string[] lines = System.IO.File.ReadAllLines(@System.IO.Directory.GetCurrentDirectory() + "/Map Files/" + filename);

            mapSizeX = lines[0].Length * 32;
            mapSizeY = lines.Length * 32;
            Game1.wallArray = new bool[lines.GetLength(0), lines[0].Length];
            Game1.darkTileArray = new double[lines.GetLength(0), lines[0].Length];
            foreach (string line in lines)
            {

                foreach (char c in line)
                {
                    string image = Textures.charToFileName[c];
                    string[] images = image.Split(',');
                    bool solid = (images[2].Length > 0);
                    /*if(c == 'a')
                    {
                        LevelTile t = new LevelTile(xposition, yposition, images[0], images[1], "schoolLevel",new Point(9 * 32, 9 * 32));
                        Game1.levelTiles.Add(t);
                        Game1.tiles.Add(t);
                    }
                    else if (c == 'b')
                    {
                        LevelTile t = new LevelTile(xposition, yposition, images[0], images[1], "houseLevel", new Point(9 * 32, 9 * 32));
                        Game1.levelTiles.Add(t);
                        Game1.tiles.Add(t);
                    }
                    else if (c == 'c')
                    {
                        LevelTile t = new LevelTile(xposition, yposition, images[0], images[1], "hubLevel", new Point(9 * 32, 9 * 32));
                        Game1.levelTiles.Add(t);
                        Game1.tiles.Add(t);
                    }*/
                    if (c == 'f')
                    {
                        BadTile t = new BadTile(xposition, yposition, images[0], images[1]);
                        Game1.playerActivateTiles.Add(t);
                        Game1.tiles.Add(t);
                    }
                    else if (c == 's')
                    {
                        GoodTile t = new GoodTile(xposition, yposition, images[0], images[1]);
                        Game1.playerActivateTiles.Add(t);
                        Game1.tiles.Add(t);
                    }
                    else if (c == 'l')
                    {
                        LockTile t = new LockTile(xposition, yposition, images[0], images[1]);
                        Game1.playerActivateTiles.Add(t);
                        Game1.tiles.Add(t);
                    }
                    else if (c == 'u')
                    {
                        UnlockTile t = new UnlockTile(xposition, yposition, images[0], images[1]);
                        Game1.playerActivateTiles.Add(t);
                        Game1.tiles.Add(t);
                    }
                    else if (c == 'g')
                    {
                        Grate t = new Grate(xposition, yposition, images[0], images[1]);
                        Game1.solidTiles.Add(t);
                        Game1.tiles.Add(t);
                        Game1.wallArray[yposition / 32, xposition / 32] = true;
                    }
                    else if (c == 'w')
                    {
                        Wall t = new Wall(xposition, yposition, images[0], images[1]);
                        t.setProjectileBlock(false);
                        Game1.solidTiles.Add(t);
                        Game1.tiles.Add(t);
                        //Game1.wallArray[yposition / 32, xposition / 32] = true;
                    }
                    else if (!solid)
                    {
                        Tile t = new Tile(xposition, yposition, images[0], images[1]);
                        Game1.tiles.Add(t);
                    }
                    else
                    {
                        Wall w = new Wall(xposition, yposition, images[0], images[1]);
                        Game1.solidTiles.Add(w);
                        Game1.tiles.Add(w);
                        Game1.wallArray[yposition / 32, xposition / 32] = true;
                    }
                    xposition += 32;
                }
                xposition = 0;
                yposition += 32;
            }
        }
Beispiel #3
0
        public void makeMapFromFile(string filename)
        {
            int xposition = 0;
            int yposition = 0;

            //This directory navigation might have to change for the final product, or even sooner

            string[] lines = System.IO.File.ReadAllLines(@"../../../Map Files/" + filename);
            //string[] lines = System.IO.File.ReadAllLines(@System.IO.Directory.GetCurrentDirectory() + "/Map Files/" + filename);



            mapSizeX            = lines[0].Length * 32;
            mapSizeY            = lines.Length * 32;
            Game1.wallArray     = new bool[lines.GetLength(0), lines[0].Length];
            Game1.darkTileArray = new double[lines.GetLength(0), lines[0].Length];
            foreach (string line in lines)
            {
                foreach (char c in line)
                {
                    string   image  = Textures.charToFileName[c];
                    string[] images = image.Split(',');
                    bool     solid  = (images[2].Length > 0);

                    /*if(c == 'a')
                     * {
                     *  LevelTile t = new LevelTile(xposition, yposition, images[0], images[1], "schoolLevel",new Point(9 * 32, 9 * 32));
                     *  Game1.levelTiles.Add(t);
                     *  Game1.tiles.Add(t);
                     * }
                     * else if (c == 'b')
                     * {
                     *  LevelTile t = new LevelTile(xposition, yposition, images[0], images[1], "houseLevel", new Point(9 * 32, 9 * 32));
                     *  Game1.levelTiles.Add(t);
                     *  Game1.tiles.Add(t);
                     * }
                     * else if (c == 'c')
                     * {
                     *  LevelTile t = new LevelTile(xposition, yposition, images[0], images[1], "hubLevel", new Point(9 * 32, 9 * 32));
                     *  Game1.levelTiles.Add(t);
                     *  Game1.tiles.Add(t);
                     * }*/
                    if (c == 'f')
                    {
                        BadTile t = new BadTile(xposition, yposition, images[0], images[1]);
                        Game1.playerActivateTiles.Add(t);
                        Game1.tiles.Add(t);
                    }
                    else if (c == 's')
                    {
                        GoodTile t = new GoodTile(xposition, yposition, images[0], images[1]);
                        Game1.playerActivateTiles.Add(t);
                        Game1.tiles.Add(t);
                    }
                    else if (c == 'l')
                    {
                        LockTile t = new LockTile(xposition, yposition, images[0], images[1]);
                        Game1.playerActivateTiles.Add(t);
                        Game1.tiles.Add(t);
                    }
                    else if (c == 'u')
                    {
                        UnlockTile t = new UnlockTile(xposition, yposition, images[0], images[1]);
                        Game1.playerActivateTiles.Add(t);
                        Game1.tiles.Add(t);
                    }
                    else if (c == 'g')
                    {
                        Grate t = new Grate(xposition, yposition, images[0], images[1]);
                        Game1.solidTiles.Add(t);
                        Game1.tiles.Add(t);
                        Game1.wallArray[yposition / 32, xposition / 32] = true;
                    }
                    else if (c == 'w')
                    {
                        Wall t = new Wall(xposition, yposition, images[0], images[1]);
                        t.setProjectileBlock(false);
                        Game1.solidTiles.Add(t);
                        Game1.tiles.Add(t);
                        //Game1.wallArray[yposition / 32, xposition / 32] = true;
                    }
                    else if (!solid)
                    {
                        Tile t = new Tile(xposition, yposition, images[0], images[1]);
                        Game1.tiles.Add(t);
                    }
                    else
                    {
                        Wall w = new Wall(xposition, yposition, images[0], images[1]);
                        Game1.solidTiles.Add(w);
                        Game1.tiles.Add(w);
                        Game1.wallArray[yposition / 32, xposition / 32] = true;
                    }
                    xposition += 32;
                }
                xposition  = 0;
                yposition += 32;
            }
        }
Beispiel #4
0
        public void makeMapFromFile(string filename)
        {
            int xposition = 0;
            int yposition = 0;

            //This directory navigation might have to change for the final product, or even sooner
            string[] lines = System.IO.File.ReadAllLines(@"../../../Map Files/" + filename);

            wallArray = new bool[lines.GetLength(0), lines[0].Length];
            foreach (string line in lines)
            {

                foreach (char c in line)
                {
                    string image = Textures.charToFileName[c];
                    string[] images = image.Split(',');
                    bool solid = (images[2].Length > 0);
                    if (c == 'f')
                    {
                        BadTile t = new BadTile(xposition, yposition, worldState, images[0], images[1]);
                        collidableTiles.Add(t);
                        tiles.Add(t);
                    }
                    else if (c == 's')
                    {
                        GoodTile t = new GoodTile(xposition, yposition, worldState, images[0], images[1]);
                        collidableTiles.Add(t);
                        tiles.Add(t);
                    }
                    else if (c == 'l')
                    {
                        LockTile t = new LockTile(xposition, yposition, worldState, images[0], images[1]);
                        collidableTiles.Add(t);
                        tiles.Add(t);
                    }
                    else if (c == 'u')
                    {
                        UnlockTile t = new UnlockTile(xposition, yposition, worldState, images[0], images[1]);
                        collidableTiles.Add(t);
                        tiles.Add(t);
                    }
                    else if (!solid)
                    {
                        Tile t = new Tile(xposition, yposition, worldState, images[0], images[1]);
                        tiles.Add(t);
                    }
                    else
                    {
                        Wall w = new Wall(xposition, yposition, worldState, images[0], images[1]);
                        collidableTiles.Add(w);
                        tiles.Add(w);
                        wallArray[yposition / 32, xposition / 32] = true;
                    }
                    xposition += 32;
                }
                xposition = 0;
                yposition += 32;
            }
        }