示例#1
0
        public Board(AIRally aiRally, string name, string boardString)
        {
            Name        = name;
            Tiles       = new List <Tile>();
            Flags       = new List <Tile>();
            SpawnPoints = new List <Tile>();

            this.aiRally = aiRally;

            var lines = Regex.Split(boardString, "\r\n|\r|\n");

            var size = lines[0].Split('x');

            Height = Convert.ToInt32(size[0]);
            Width  = Convert.ToInt32(size[1]);

            Tile currTile = null;

            for (var y = 0; y < Height; y++)
            {
                var tileRow = lines[y + 1].Split(';');
                for (var x = 0; x < Width; x++)
                {
                    currTile = Tile.MakeTile(this, tileRow[x], x, y);
                    Tiles.Add(currTile);
                    if (currTile.HasFlag() != 0)
                    {
                        Flags.Add(currTile);
                    }
                    if (currTile.HasSpawnPoint() != 0)
                    {
                        SpawnPoints.Add(currTile);
                    }
                }
            }
            Flags       = Flags.OrderBy(o => o.HasFlag()).ToList();
            SpawnPoints = SpawnPoints.OrderBy(o => o.HasSpawnPoint()).ToList();
        }
示例#2
0
文件: Board.cs 项目: mvdlaar/AIRally
        public Board(AIRally aiRally, string name, string boardString)
        {
            Name = name;
            Tiles = new List<Tile>();
            Flags = new List<Tile>();
            SpawnPoints = new List<Tile>();

            this.aiRally = aiRally;

            var lines = Regex.Split(boardString, "\r\n|\r|\n");

            var size = lines[0].Split('x');
            Height = Convert.ToInt32(size[0]);
            Width = Convert.ToInt32(size[1]);

            Tile currTile = null;

            for (var y = 0; y < Height; y++)
            {
                var tileRow = lines[y + 1].Split(';');
                for (var x = 0; x < Width; x++)
                {
                    currTile = Tile.MakeTile(this, tileRow[x], x, y);
                    Tiles.Add(currTile);
                    if (currTile.HasFlag() != 0)
                    {
                        Flags.Add(currTile);
                    }
                    if (currTile.HasSpawnPoint() != 0)
                    {
                        SpawnPoints.Add(currTile);
                    }
                }
            }
            Flags = Flags.OrderBy(o => o.HasFlag()).ToList();
            SpawnPoints = SpawnPoints.OrderBy(o => o.HasSpawnPoint()).ToList();
        }
示例#3
0
文件: Board.cs 项目: mvdlaar/AIRally
 public Board(AIRally airally, string filename)
     : this(airally, StripFileName(filename), new StreamReader(filename).ReadToEnd())
 {
 }
示例#4
0
 public Board(AIRally airally, string filename)
     : this(airally, StripFileName(filename), new StreamReader(filename).ReadToEnd())
 {
 }