コード例 #1
0
        /// <summary>
        /// loads the world from a given path
        /// </summary>
        /// <param name="worldPath">The path to the world</param>
        public World LoadWorld(String worldPath)
        {
            Stream worldStream = File.OpenRead("./Content/" + worldPath + ".txt");
            StreamReader worldReader = new StreamReader(worldStream);

            World tmpWorld = new World(int.Parse(worldReader.ReadLine()), int.Parse(worldReader.ReadLine()));

            tmpWorld.canRespawn = bool.Parse(worldReader.ReadLine());   //Josiah S DeVizia

            GUI.Door[] doors = new GUI.Door[int.Parse(worldReader.ReadLine())]; //Josiah S DeVizia

            //Josiah S DeVizia
            for(int x = 0; x < doors.Length; ++x)
            {
                doors[x] = new Door(worldReader.ReadLine(), int.Parse(worldReader.ReadLine()), int.Parse(worldReader.ReadLine()));
            }

            Vector2[] doorLocs = new Vector2[doors.Length]; //Josiah S DeVizia

            int y = 0;
            string line = worldReader.ReadLine();
            int row = 0;
            int doorCntr = 0;
            while (line != null)
            {
                for (int col = 0; col < line.Length; ++col)
                {
                    switch (line[col])
                    {
                        case '0':
                            tmpWorld.tiles[row][col] = Tiles.tilesDictionary["RoadTar"];
                            break;

                        case '1':
                            tmpWorld.tiles[row][col] = Tiles.tilesDictionary["RoadLine"];
                            break;

                        case '2':
                            tmpWorld.tiles[row][col] = Tiles.tilesDictionary["SideWalkBrick"];
                            break;

                        case '3':
                            tmpWorld.tiles[row][col] = Tiles.tilesDictionary["BuildingEdge"];
                            break;

                        case '4':
                            tmpWorld.tiles[row][col] = Tiles.tilesDictionary["BuildingRoof"];
                            break;

                        case '5':
                            tmpWorld.tiles[row][col] = Tiles.tilesDictionary["Water"];
                            break;

                        //Josiah S DeVizia
                        case '6':
                            doorLocs[y] = new Vector2(row, col);
                            y++;
                            tmpWorld.tiles[row][col] = doors[doorCntr];
                            doorCntr++;
                            break;

                        //Josiah S DeVizia
                        case '7':
                            tmpWorld.tiles[row][col] = Tiles.tilesDictionary["Debris"];
                            break;
                        case '8':
                            tmpWorld.tiles[row][col] = Tiles.tilesDictionary["Heal"];
                            break;
                        case '9':
                            tmpWorld.tiles[row][col] = Tiles.tilesDictionary["Ammo"];
                            break;
                        default:
                            tmpWorld.tiles[row][col] = Tiles.tilesDictionary["BuildingEdge"];
                            break;
                    }
                }
                row++;
                line = worldReader.ReadLine();
            }
            tmpWorld.doors = doorLocs;
            //MainGame.worldManager.worlds.Add(worldPath, tmpWorld);
            return tmpWorld;
        }
コード例 #2
0
        /// <summary>
        /// loads the world from a given path
        /// </summary>
        /// <param name="worldPath">The path to the world</param>
        public World LoadWorld(String worldPath)
        {
            Stream       worldStream = File.OpenRead("./Content/" + worldPath + ".txt");
            StreamReader worldReader = new StreamReader(worldStream);

            World tmpWorld = new World(int.Parse(worldReader.ReadLine()), int.Parse(worldReader.ReadLine()));

            tmpWorld.canRespawn = bool.Parse(worldReader.ReadLine());           //Josiah S DeVizia

            GUI.Door[] doors = new GUI.Door[int.Parse(worldReader.ReadLine())]; //Josiah S DeVizia

            //Josiah S DeVizia
            for (int x = 0; x < doors.Length; ++x)
            {
                doors[x] = new Door(worldReader.ReadLine(), int.Parse(worldReader.ReadLine()), int.Parse(worldReader.ReadLine()));
            }

            Vector2[] doorLocs = new Vector2[doors.Length]; //Josiah S DeVizia

            int    y        = 0;
            string line     = worldReader.ReadLine();
            int    row      = 0;
            int    doorCntr = 0;

            while (line != null)
            {
                for (int col = 0; col < line.Length; ++col)
                {
                    switch (line[col])
                    {
                    case '0':
                        tmpWorld.tiles[row][col] = Tiles.tilesDictionary["RoadTar"];
                        break;

                    case '1':
                        tmpWorld.tiles[row][col] = Tiles.tilesDictionary["RoadLine"];
                        break;

                    case '2':
                        tmpWorld.tiles[row][col] = Tiles.tilesDictionary["SideWalkBrick"];
                        break;

                    case '3':
                        tmpWorld.tiles[row][col] = Tiles.tilesDictionary["BuildingEdge"];
                        break;

                    case '4':
                        tmpWorld.tiles[row][col] = Tiles.tilesDictionary["BuildingRoof"];
                        break;

                    case '5':
                        tmpWorld.tiles[row][col] = Tiles.tilesDictionary["Water"];
                        break;

                    //Josiah S DeVizia
                    case '6':
                        doorLocs[y] = new Vector2(row, col);
                        y++;
                        tmpWorld.tiles[row][col] = doors[doorCntr];
                        doorCntr++;
                        break;

                    //Josiah S DeVizia
                    case '7':
                        tmpWorld.tiles[row][col] = Tiles.tilesDictionary["Debris"];
                        break;

                    case '8':
                        tmpWorld.tiles[row][col] = Tiles.tilesDictionary["Heal"];
                        break;

                    case '9':
                        tmpWorld.tiles[row][col] = Tiles.tilesDictionary["Ammo"];
                        break;

                    default:
                        tmpWorld.tiles[row][col] = Tiles.tilesDictionary["BuildingEdge"];
                        break;
                    }
                }
                row++;
                line = worldReader.ReadLine();
            }
            tmpWorld.doors = doorLocs;
            //MainGame.worldManager.worlds.Add(worldPath, tmpWorld);
            return(tmpWorld);
        }