예제 #1
0
        public Field load_lvl(string name)
        {
            Field field = new Field();

            field = JsonConvert.DeserializeObject <Field>(File.ReadAllText(name));
            Ranges.setSize(new Coord(field.COLS, field.ROWS));
            field.gameField = new Matrix(new Emptiness());
            for (int i = 0; i < field.ROWS; i++)
            {
                for (int j = 0; j < field.COLS; j++)
                {
                    switch (field.matrix[i, j])
                    {
                    case '#': field.gameField[i, j] = new Wall(); break;

                    case 'a': field.gameField[i, j] = new Key('a'); break;

                    case 'A': field.gameField[i, j] = new Door('a'); break;

                    case 'b': field.gameField[i, j] = new Key('b'); break;

                    case 'B': field.gameField[i, j] = new Door('b'); break;

                    case 'c': field.gameField[i, j] = new Key('c'); break;

                    case 'C': field.gameField[i, j] = new Door('c'); break;

                    case '0': field.gameField[i, j] = new Coin(); break;

                    case 'x': field.gameField[i, j] = new Trap(); break;

                    default: field.gameField[i, j] = new Emptiness(); break;
                    }
                }
            }
            return(field);
        }
예제 #2
0
파일: Matrix.cs 프로젝트: SpectraPH/LAB2
 public Matrix(Element element)
 {
     matrix = new Element[Ranges.getSize().x, Ranges.getSize().y];
 }