public void Start() { this.posX = 0; this.posY = 0; rb = GetComponent <Rigidbody>(); Laby.AddToTheMaze(this); }
// Use this for initialization void Start() { laby = Laby.RandomLaby; cells = new Cell[nbLignes, nbColonnes]; for (int i = 0; i < nbLignes; i++) { for (int j = 0; j < nbColonnes; j++) { Cell cell = Instantiate(prefabCell, place); cell.transform.localPosition = new Vector3(0.1f * j - 0.25f, 0.25f - 0.1f * i, 0f); cell.transform.localRotation = Quaternion.identity; cell.name = "Cell " + i.ToString() + " " + j.ToString(); cells[i, j] = cell; } } foreach (Vector2 circle in laby.Circles) { cells[(int)circle.y, (int)circle.x].ShowCircle(); } int tx = Random.Range(0, nbColonnes); int ty = Random.Range(0, nbLignes); triangle = new Vector2(tx, ty); cells[ty, tx].SetObjective(); int cx, cy; do { cx = Random.Range(0, nbColonnes); cy = Random.Range(0, nbLignes); }while (cx == tx && cy == ty); carre = new Vector2(cx, cy); cells[cy, cx].ShowSquare(true); flecheHaut.onClick.AddListener(Haut); flecheGauche.onClick.AddListener(Gauche); flecheBas.onClick.AddListener(Bas); flecheDroite.onClick.AddListener(Droite); }
public static bool CanMoveInDirection(int posX, int posY, Orientation orientation) { Tile currentTile = Laby.board[posX, posY]; if (orientation == Orientation.NORTH && !currentTile.hasWall(Wall.NORTH) && !Laby.IsTileOccupied(posX, posY + 1)) { return(true); } else if (orientation == Orientation.EAST && !currentTile.hasWall(Wall.EAST) && !Laby.IsTileOccupied(posX + 1, posY)) { return(true); } else if (orientation == Orientation.WEST && !currentTile.hasWall(Wall.WEST) && !Laby.IsTileOccupied(posX - 1, posY)) { return(true); } else if (orientation == Orientation.SOUTH && !currentTile.hasWall(Wall.SOUTH) && !Laby.IsTileOccupied(posX, posY - 1)) { return(true); } return(false); }