Example #1
0
        public void ReadMap()
        {
            streamReaderEnvironment = new StreamReader(@"map.txt");
            while (!streamReaderEnvironment.EndOfStream)
            {
                strings.Add(streamReaderEnvironment.ReadLine());
            }
            streamReaderEnvironment.Close();

            for (int i = 0; i < tiles.GetLength(0); i++)
            {
                for (int j = 0; j < tiles.GetLength(1); j++)
                {
                    tiles[j, i] = new Tile(TextureManager.floor, new Vector2(j * 24, i * 24), 0,TextureManager.path);
                }
            }
            for (int i = 0; i < tiles.GetLength(0); i++)
            {
                for (int j = 0; j < tiles.GetLength(1); j++)
                {
                    if (strings[i][j] == 'w')
                    {
                        tiles[j, i] = new Tile(TextureManager.wall, new Vector2(j * 24, i * 24), wallTile, TextureManager.path);
                    }
                    if (strings[i][j] == 'f')
                    {
                        tiles[j, i] = new Tile(TextureManager.food, new Vector2(j * 24, i * 24), foodtile, TextureManager.path);
                    }
                    if (strings[i][j] == 'c')
                    {
                        pacman = new Pacman(TextureManager.pacmanSprite, new Vector2(j * 24 + offset, i * 24 + offset));
                    }

                    if (strings[i][j] == 'w')
                    {
                        tiles[j, i] = new Tile(TextureManager.wall, new Vector2(j * 24, i * 24), wallTile, TextureManager.path);
                    }

                    if (strings[i][j] == 'g')
                    {
                        ghost = new Ghost(TextureManager.redGhost, new Vector2(j * 24 + offset, i * 24 + offset));
                    }

                }
            }
        }
Example #2
0
 public PathFinder(Tile[,] tiles)
 {
     this.tiles = tiles;
 }