private void tochar()
        {
            Ship ship = new Ship(currentField);
            Cart cart = new Cart(startpoint);

            EmptyField emptyField = new EmptyField();
            Dock dock = new Dock();
            Rail rail = new Rail('-');
            StartPoint startpointer = new StartPoint('A');
            Storage storage = new Storage();
            Switch switchje = new Switch('S');
            Water water = new Water();

            ship.ToChar();
            cart.ToChar();

            emptyField.ToChar();
            dock.ToChar();
            rail.ToChar();
            startpointer.ToChar();
            storage.ToChar();
            switchje.ToChar();
            water.ToChar();
        }
Example #2
0
        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;
        }