Exemple #1
0
        private List <BaseField> procesLine(string lineString, int y)
        {
            List <BaseField> fieldLine     = new List <BaseField>();
            BaseField        previousField = null;

            for (int x = 0; x < lineString.Length; x++)
            {
                // nieuw Vakje object maken
                BaseField field;

                switch (lineString[x])
                {
                case '#':
                    field = new WallField();
                    break;

                case '@':
                case 'o':
                case '.':
                    field = new FloorField();
                    break;

                case 'x':
                    field = new TargetField();
                    break;

                case ' ':
                    field = new EmptyField();
                    break;

                default:
                    throw new Exception_MazeIncorrectFileFormat(lineString[x]);
                }

                // koppelen met Vakje op dezelfde regel
                if (previousField != null)
                {
                    field.FieldToLeft          = previousField;
                    previousField.FieldToRight = field;
                }
                previousField = field;
                fieldLine.Add(field);

                // truck toevoegen en koppelen, indien nodig
                if (lineString[x] == '@')
                {
                    Truck newTruck = new Truck(field);
                    _maze.TheTruck = newTruck;
                    ((FloorField)field).Place(newTruck);
                }

                // krat toevoegen en koppelen, indien nodig
                if (lineString[x] == 'o')
                {
                    Crate newCrate = new Crate(field);
                    _maze.AddCrate(newCrate);
                    ((FloorField)field).Place(newCrate);
                }
            }
            return(fieldLine);
        }
Exemple #2
0
 public abstract void Visit(FloorField visitee);