Пример #1
0
        public void setField(int value)
        {
            _filePath  = Directory.GetParent(Directory.GetParent(_filePath).FullName).FullName;
            _filePath += @"\Levels\doolhof" + value + ".txt";

            string[] lines = System.IO.File.ReadAllLines(_filePath);

            this._height = getHeightOfLevel(lines);
            this._width  = getWidthofLevel(lines);

            this._fieldArray    = new Field[_height, _width];
            this._fieldArrayTop = new Field[_height, _width];

            int y = 0; // row
            int x = 0; // colomn

            foreach (string line in lines)
            {
                foreach (char Char in line)
                {
                    switch (Char)
                    {
                    case '~':
                        _fieldArrayTop[y, x] = new Floor();
                        _fieldArray[y, x]    = new Pitfall(3);
                        break;

                    case '#':
                        _fieldArrayTop[y, x] = new Wall();
                        _fieldArray[y, x]    = new Wall();
                        break;

                    case '.':
                        _fieldArrayTop[y, x] = new Floor();
                        _fieldArray[y, x]    = new Floor();
                        break;

                    case 'o':
                        _fieldArrayTop[y, x] = new Chest();
                        _fieldArray[y, x]    = new Floor();
                        break;

                    case 'x':
                        _fieldArrayTop[y, x] = new Floor();
                        _fieldArray[y, x]    = new Destination();
                        break;

                    case ' ':
                        _fieldArrayTop[y, x] = new Floor();
                        _fieldArray[y, x]    = new Void();
                        break;

                    case '@':
                        this._player         = new Player(y, x);
                        _fieldArrayTop[y, x] = this._player;
                        _fieldArray[y, x]    = new Floor();
                        break;
                    }
                    x++;
                }
                y++;
                x = 0;
            }
        }
Пример #2
0
        public override void move(String direction)
        {
            switch (direction)
            {
            case "links":
                if (floor.West.GameObject is UnmovableObject)
                {
                    break;
                }
                if (floor.West.GameObject is Chest && !floor.West.West.getGameObjectType().Equals('#'))
                {
                    Chest c = (Chest)floor.West.GameObject;
                    c.move(direction);
                    swap(direction);
                }

                else if (floor.West.GameObject == null)
                {
                    swap(direction);
                }
                break;



            case "rechts":

                if (floor.East.GameObject is UnmovableObject)
                {
                    break;
                }

                else if (floor.East.GameObject is Chest && !floor.East.East.getGameObjectType().Equals('#'))
                {
                    Chest c = (Chest)floor.East.GameObject;
                    c.move(direction);
                    swap(direction);
                }

                else if (floor.East.GameObject == null)
                {
                    swap(direction);
                }
                break;


            case "omhoog":

                if (floor.North.GameObject is UnmovableObject)
                {
                    break;
                }
                else if (floor.North.GameObject is Chest && !(floor.North.North.GameObject is UnmovableObject))
                {
                    Chest c = (Chest)floor.North.GameObject;
                    c.move(direction);
                    swap(direction);
                }

                else if (floor.North.GameObject == null)
                {
                    swap(direction);
                }
                break;


            case "omlaag":

                if (floor.South.GameObject is UnmovableObject)
                {
                    break;
                }

                if (floor.South.GameObject is Chest && !floor.South.South.getGameObjectType().Equals('#'))
                {
                    Chest c = (Chest)floor.South.GameObject;
                    c.move(direction);
                    swap(direction);
                }

                else if (floor.South.GameObject == null)
                {
                    swap(direction);
                }
                break;
            }
        }
Пример #3
0
 public override void PlaceChest(Chest chest)
 {
     throw new NotImplementedException();
 }
Пример #4
0
 public override void PlaceChest(Chest chest)
 {
     Chest = chest;
 }