コード例 #1
0
        private void ChainTiles(string line)
        {
            // Remove tab and space elements
            line = Regex.Replace(line, @"[\t|\s]", string.Empty);

            // Split on each column (seperated by ':')
            var column = line.Split(':');

            // Get position out of first column
            var   aPosFrom = column[0].Trim().Split(',');
            Point posFrom  = new Point {
                X = Int32.Parse(aPosFrom[0]), Y = Int32.Parse(aPosFrom[1])
            };

            // Get position out of second column
            var   aPosTo = column[1].Trim().Split(',');
            Point posTo  = new Point {
                X = Int32.Parse(aPosTo[0]), Y = Int32.Parse(aPosTo[1])
            };

            // Chain them
            BaseTile tileFrom = _tiles.FirstOrDefault(item => item.Pos == posFrom);
            BaseTile tileTo   = _tiles.FirstOrDefault(item => item.Pos == posTo);

            tileFrom.ChainTiles(tileTo);
        }