예제 #1
0
    void Start()
    {
        playerColor = Celula.CellType.R;
        Utils.Pair <Vector3, float> aux = grid.getPlayerPositionAndRotation();
        transform.position = aux.first;
        transform.Rotate(Vector3.up * aux.second);

        bool found = false;

        for (i = 0; i < Grid.MAX_SIZE; i++)
        {
            for (j = 0; j < Grid.MAX_SIZE; j++)
            {
                if (grid.getCelula(i, j).getCellType() == Celula.CellType.Entrada)
                {
                    found = true;
                    break;
                }
            }
            if (found)
            {
                break;
            }
        }

        marked         = new bool[Grid.MAX_SIZE, Grid.MAX_SIZE];
        movement       = new Utils.Pair <int, int> [Grid.MAX_SIZE * Grid.MAX_SIZE];
        totalMovements = 0;
        currentMov     = 0;
    }
예제 #2
0
파일: Parser.cs 프로젝트: luiz-santos/RGB
    public bool BuildLevel(Grid grid, string level)
    {
        try {
            string       line;
            string       filename = "Assets/level/" + level + ".txt";
            StreamReader reader   = new StreamReader(filename, Encoding.Default);

            using (reader) {
                int row = 0, col = 0;

                while (true)
                {
                    line = reader.ReadLine();

                    if (line == null)
                    {
                        break;
                    }

                    for (col = 0; col < line.Length; col++)
                    {
                        Celula.CellType tipo = Celula.CellType.Vazia;
                        if (line[col] == 'R')
                        {
                            tipo = Celula.CellType.R;
                        }
                        if (line[col] == 'G')
                        {
                            tipo = Celula.CellType.G;
                        }
                        if (line[col] == 'B')
                        {
                            tipo = Celula.CellType.B;
                        }
                        if (line[col] == 'E')
                        {
                            tipo = Celula.CellType.Entrada;
                        }
                        if (line[col] == 'S')
                        {
                            tipo = Celula.CellType.Saida;
                        }
                        if (line[col] == 'X')
                        {
                            tipo = Celula.CellType.Vazia;
                        }
                        grid.setCelula(row, col, tipo);
                    }

                    row++;
                }
            }
        } catch (System.Exception e) {
            Debug.LogError("Erro ao abrir arquivo level" + level + ".txt");
            Debug.LogError(e.Message);
            return(false);
        }
        return(true);
    }
예제 #3
0
    void Start()
    {
        playerColor = Celula.CellType.R;
        Utils.Pair<Vector3, float> aux = grid.getPlayerPositionAndRotation ();
        transform.position = aux.first;
        transform.Rotate (Vector3.up * aux.second);

        bool found = false;
        for (i = 0; i < Grid.MAX_SIZE; i++) {
            for (j = 0; j < Grid.MAX_SIZE; j++) {
                if (grid.getCelula(i, j).getCellType() == Celula.CellType.Entrada) {
                    found = true;
                    break;
                }
            }
            if (found) break;
        }

        marked = new bool[Grid.MAX_SIZE, Grid.MAX_SIZE];
        movement = new Utils.Pair<int, int>[Grid.MAX_SIZE * Grid.MAX_SIZE];
        totalMovements = 0;
        currentMov = 0;
    }
예제 #4
0
 public void setCelula(int i, int j, Celula.CellType tipo)
 {
     grid[i, j].setCellType(tipo);
 }