示例#1
0
        public static void LoadMap(Game game)
        {
            StreamReader reader = new StreamReader(TitleContainer.OpenStream("quest1.map"));

            int height = int.Parse(reader.ReadLine());
            int width = int.Parse(reader.ReadLine());

            Board.Board board = new Board.Board(width, height, game.Content.Load<Texture2D>("Images/Board/floor"));

            for (int y = 0; y < height; y++)
            {
                char[] c = reader.ReadLine().ToCharArray();
                for (int x = 0; x < c.Length; x++)
                {
                    switch (c[x])
                    {
                        case ' ':
                            board[x, y] = null;
                            break;
                        default:
                            board[x, y] = new Square(int.Parse(c[x] + string.Empty));
                            break;
                    }
                }
            }

            System.Diagnostics.Debug.WriteLine("Map loaded successfully!");

            LoadOther(game, reader, board);
        }
示例#2
0
        private static void LoadOther(Game game, StreamReader reader, Board.Board board)
        {
            int n = int.Parse(reader.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string line = reader.ReadLine();
                string[] data = line.Split(',');

                switch (data[0])
                {
                    case "monster":
                        int x = int.Parse(data[1]);
                        int y = int.Parse(data[2]);
                        Orientation o = Orientation.H;
                        Orientation.TryParse(data[4], true, out o);
                        Monster monster = GetMonster(int.Parse(data[3]));
                        monster.Orientation = o;
                        board.PlaceFigure(monster, new Point(x, y));
                        break;
                    case "door":
                        RuneKey color;
                        RuneKey.TryParse(data[12], out color);
                        Orientation orientation;
                        Orientation.TryParse(data[11], out orientation);
                        board.AddDoor(new Door(int.Parse(data[1]), new Point(int.Parse(data[2]), int.Parse(data[3])), new Point(int.Parse(data[4]), int.Parse(data[5])), int.Parse(data[6]), new Point(int.Parse(data[7]), int.Parse(data[8])), new Point(int.Parse(data[9]), int.Parse(data[10])), orientation, color, game.Content.Load<Texture2D>("Images/Board/door-" + color.ToString())));
                        break;
                    default:
                        board[int.Parse(data[1]), int.Parse(data[2])].Marker = GetMarker(data[0], data[3]);
                        break;
                }
            }

            System.Diagnostics.Debug.WriteLine("Markers loaded successfully!");

            FullModel.board = board;
            LoadChests(game, reader);
        }
示例#3
0
文件: Board.cs 项目: KNCT-KPC/Bungo
 public void Copy(Board other)
 {
     this.basemap = other.basemap;
     this.nowmap = other.nowmap;
     this.maxid = other.maxid;
     this.pass = other.pass;
     this.name = other.name;
     this.time = other.time;
     Invalidate();
 }