private List <Tile> ProcesLine(string lineString, int y) { List <Tile> TileLine = new List <Tile>(); Tile previousTile = null; for (int x = 0; x < lineString.Length; x++) { Tile tile; switch (lineString[x]) { case 'W': tile = new Water(); break; case 'D': tile = new Dock(); break; case 'R': tile = new Track('-'); break; case 'U': tile = new Track('|'); break; case '1': tile = new Switch('S'); _gameBoard.Switch1 = (Switch)tile; _gameBoard.Switch1.SwitchDirection = SwitchDirection.MIDDLE; break; case '2': tile = new Switch('S'); _gameBoard.Switch2 = (Switch)tile; _gameBoard.Switch2.SwitchDirection = SwitchDirection.MIDDLE; break; case '3': tile = new Switch('S'); _gameBoard.Switch3 = (Switch)tile; _gameBoard.Switch3.SwitchDirection = SwitchDirection.MIDDLE; break; case '4': tile = new Switch('S'); _gameBoard.Switch4 = (Switch)tile; _gameBoard.Switch4.SwitchDirection = SwitchDirection.MIDDLE; break; case '5': tile = new Switch('S'); _gameBoard.Switch5 = (Switch)tile; _gameBoard.Switch5.SwitchDirection = SwitchDirection.MIDDLE; break; case '8': tile = new Water(); _gameBoard.ShipEnd = (Water)tile; break; case '9': tile = new Water(); _gameBoard.ShipStart = (Water)tile; break; case 'A': tile = new Start('A'); _gameBoard.PointA = tile; break; case 'B': tile = new Start('B'); _gameBoard.PointB = tile; break; case 'C': tile = new Start('C'); _gameBoard.PointC = tile; break; case 'O': tile = new Warehouse(); break; case '.': tile = new EmptyTile(); break; default: tile = new EmptyTile(); break; } if (previousTile != null) { tile.TileToLeft = previousTile; previousTile.TileToRight = tile; } previousTile = tile; TileLine.Add(tile); } return(TileLine); }
private List <Field> procesLine(string lineString, int y) { List <Field> fieldLine = new List <Field>(); Field previousField = null; for (int x = 0; x < lineString.Length; x++) { // nieuw Vakje object maken Field field; switch (lineString[x]) { case 'W': field = new Water(); break; case 'D': field = new Dock(); break; case 'R': field = new Rail('-'); break; case '/': field = new Rail('/'); break; case '\\': field = new Rail('\\'); break; case 'U': field = new Rail('|'); break; case '1': field = new Switch('S'); _gameBoard.switch1 = (Switch)field; _gameBoard.switch1.SwitchDirection = SwitchDirection.MIDDLE; break; case '2': field = new Switch('S'); _gameBoard.switch2 = (Switch)field; _gameBoard.switch2.SwitchDirection = SwitchDirection.MIDDLE; break; case '3': field = new Switch('S'); _gameBoard.switch3 = (Switch)field; _gameBoard.switch3.SwitchDirection = SwitchDirection.MIDDLE; break; case '4': field = new Switch('S'); _gameBoard.switch4 = (Switch)field; _gameBoard.switch4.SwitchDirection = SwitchDirection.MIDDLE; break; case '5': field = new Switch('S'); _gameBoard.switch5 = (Switch)field; _gameBoard.switch5.SwitchDirection = SwitchDirection.MIDDLE; break; case '8': field = new Water(); _gameBoard.ShipEnd = (Water)field; break; case '9': field = new Water(); _gameBoard.ShipStart = (Water)field; break; case 'A': field = new StartPoint('A'); _gameBoard.PointA = field; break; case 'B': field = new StartPoint('B'); _gameBoard.PointB = field; break; case 'C': field = new StartPoint('C'); _gameBoard.PointC = field; break; case 'O': field = new Storage(); break; case '.': field = new EmptyField(); break; default: throw new Exception_GameBoardIncorrectFileFormat(lineString[x]); } // koppelen met Vakje op dezelfde regel if (previousField != null) { field.FieldToLeft = previousField; previousField.FieldToRight = field; } previousField = field; fieldLine.Add(field); } return(fieldLine); }