/// <summary> /// обновляет изображение клетки на доске /// r,c int в диапазоне [0-7] /// </summary> static void DrawCell(VisualCell visualCell, int row, int column) { Image CellImage = null; int x = column * 100; int y = row * 100; switch (visualCell)//клетка которую нужно нарисовать { case (VisualCell.BlackCell): CellImage = BlackCell; break; case (VisualCell.BlackCellAvailable): CellImage = BlackCellAvailable; break; case (VisualCell.WhiteCell): CellImage = WhiteCell; break; case (VisualCell.WhiteCellAvailable): CellImage = WhiteCellAvailable; break; case (VisualCell.CellEnemy): CellImage = CellEnemy; break; default: return; } DrawElement(CellImage, x, y);//нарисовать клетку }
public Cell(CellType incType, int incX, int incY) { vCell = new VisualCell(); this.CellType = incType; this.posX = incX; this.posY = incY; }
//instantiate prefabs based on cell / obstacle rules void InitVisualCell() { foreach (Cell cell in cells) { if (cell.isObstacle) { int poop = Random.Range(0, obstacles.Length); visualCellInst = Instantiate(obstacles[poop], new Vector3(cell.xPos * 3, obstacles[poop].gameObject.transform.position.y, height * 3f - cell.zPos * 3), Quaternion.identity) as VisualCell; visualCellInst.transform.parent = transform; visualCellInst.North.gameObject.SetActive(!cell.North); visualCellInst.South.gameObject.SetActive(!cell.South); visualCellInst.East.gameObject.SetActive(!cell.East); visualCellInst.West.gameObject.SetActive(!cell.West); if (visualCellInst.GetComponent <obstacle1>() != null || visualCellInst.GetComponent <Obstacle4>() != null) { visualCellInst.GetComponent <Renderer>().material = obstacleFloor; } else { visualCellInst.GetComponent <Renderer>().material = floorFinal; } visualCellInst.North.gameObject.GetComponent <Renderer>().material = wallFinal; visualCellInst.South.gameObject.GetComponent <Renderer>().material = wallFinal; visualCellInst.East.gameObject.GetComponent <Renderer>().material = wallFinal; visualCellInst.West.gameObject.GetComponent <Renderer>().material = wallFinal; visualCellInst.transform.name = cell.xPos.ToString() + "_" + cell.zPos.ToString(); //visualCellInst.GetComponent<VisualCell>().RandomizeScale(); } else { visualCellInst = Instantiate(visualCellPrefab, new Vector3(cell.xPos * 3, 0, height * 3f - cell.zPos * 3), Quaternion.identity) as VisualCell; visualCellInst.transform.parent = transform; visualCellInst.North.gameObject.SetActive(!cell.North); visualCellInst.South.gameObject.SetActive(!cell.South); visualCellInst.East.gameObject.SetActive(!cell.East); visualCellInst.West.gameObject.SetActive(!cell.West); visualCellInst.GetComponent <Renderer>().material = floorFinal; visualCellInst.North.gameObject.GetComponent <Renderer>().material = wallFinal; visualCellInst.South.gameObject.GetComponent <Renderer>().material = wallFinal; visualCellInst.East.gameObject.GetComponent <Renderer>().material = wallFinal; visualCellInst.West.gameObject.GetComponent <Renderer>().material = wallFinal; visualCellInst.transform.name = cell.xPos.ToString() + "_" + cell.zPos.ToString(); //visualCellInst.GetComponent<VisualCell>().RandomizeScale(); } } }
void InitVisualCell() { foreach (Cell cell in cells) { visualCellInst = Instantiate(visualCellPrefab, new Vector3(cell.xPos * 3, 0, _height * 3f - cell.zPos * 3), Quaternion.identity) as VisualCell; visualCellInst.transform.parent = transform; visualCellInst._North.gameObject.SetActive(!cell._North); visualCellInst._South.gameObject.SetActive(!cell._South); visualCellInst._Est.gameObject.SetActive(!cell._Est); visualCellInst._West.gameObject.SetActive(!cell._West); visualCellInst.transform.name = cell.xPos.ToString() + "_" + cell.zPos.ToString(); } }
void InitVisualCell() { foreach (Cell cell in celdas) { tempVisualCell = Instantiate(visualCell, new Vector3(cell.xPos * 3, 0, alto * 3f - cell.zPos * 3), Quaternion.identity) as VisualCell; tempVisualCell.transform.parent = transform; tempVisualCell.norte.gameObject.SetActive(!cell._norte); tempVisualCell.sur.gameObject.SetActive(!cell._sur); tempVisualCell.este.gameObject.SetActive(!cell._este); tempVisualCell.oeste.gameObject.SetActive(!cell._oeste); tempVisualCell.transform.name = cell.xPos.ToString() + "_" + cell.zPos.ToString(); } }
void InitVisualCell() { foreach (Cell cell in cells) { visualCellInst = Instantiate(visualCellPrefab, new Vector3(cell.xPos * 3, 0, height * 3f - cell.zPos * 3), Quaternion.identity) as VisualCell; visualCellInst.transform.parent = transform; visualCellInst.North.gameObject.SetActive(!cell.North); visualCellInst.South.gameObject.SetActive(!cell.South); visualCellInst.East.gameObject.SetActive(!cell.East); visualCellInst.West.gameObject.SetActive(!cell.West); visualCellInst.transform.name = cell.xPos.ToString() + "_" + cell.zPos.ToString(); //visualCellInst.GetComponent<VisualCell>().RandomizeScale(); } }
void InitVisualCell() { // Initialise mes cellules visuel et detruit les murs en fonction des cellules virtuel foreach (Cell cell in casillas) { visualCellInst = Instantiate(visualCellPrefab, new Vector3(cell.xPos * 3, 0, height * 3f - cell.zPos * 3), Quaternion.identity) as VisualCell; visualCellInst.transform.parent = transform; visualCellInst.Norte.gameObject.SetActive(!cell.Norte); visualCellInst.Sur.gameObject.SetActive(!cell.Sur); visualCellInst.Este.gameObject.SetActive(!cell.Este); visualCellInst.Oeste.gameObject.SetActive(!cell.Oeste); visualCellInst.transform.name = cell.xPos.ToString() + "_" + cell.zPos.ToString(); } }
void DrawCells() { // draw the cells of the maze foreach (Cell cell in cells) { Vector3 pos = new Vector3(cell.xPos * 3, 0, _height * 3 - cell.zPos * 3); visualCell = Instantiate(visualCellPrefab, pos, Quaternion.identity) as VisualCell; visualCell.transform.parent = transform; // if north, east, south or west are made true in the MazeGenerator, then delete that wall visualCell._North.gameObject.SetActive(!cell._North); visualCell._South.gameObject.SetActive(!cell._South); visualCell._Est.gameObject.SetActive(!cell._East); visualCell._West.gameObject.SetActive(!cell._West); visualCell.transform.name = "[ " + cell.xPos.ToString() + ", " + cell.zPos.ToString() + " ]"; } }
public static Comparison[] CompareWith(this Dictionary <string, VisualCell> cellsBefore, Dictionary <string, VisualCell> cellsAfter) { var keys = cellsBefore.Keys .Union(cellsAfter.Keys) .Distinct() .ToArray(); var comparisons = keys .Select(key => { VisualCell before = null, after = null; cellsBefore.TryGetValue(key, out before); cellsAfter.TryGetValue(key, out after); return(new Comparison(before, after)); }) .ToArray(); return(comparisons); }
public void Init(int _gridX, int _gridY, float _offsetX, float _offsetY) { gridX = _gridX; gridY = _gridY; offsetX = _offsetX; offsetY = _offsetY; cells = new VisualCell[_gridX, _gridY]; trees = new VisualTree[_gridX, _gridY]; for (int y = 0; y < _gridY; y++) { for (int x = 0; x < _gridX; x++) { VisualCell c = Instantiate <VisualCell>(cellPrefab); c.transform.SetParent(transform); c.transform.position = new Vector3(x * offsetX, y * offsetY, 0); cells[x, y] = c; } } transform.Translate(new Vector3(-(_gridX - 1) * _offsetX / 2f, -(_gridY - 1) * _offsetY / 2f - 1)); }
public Comparison(VisualCell before, VisualCell after) { Before = before; After = after; }
void InitVisualCell() { // Initialise mes cellules visuel et detruit les murs en fonction des cellules virtuel foreach(Cell cell in cells) { visualCellInst = Instantiate(visualCellPrefab, new Vector3(cell.xPos * 3, 0, _height * 3f - cell.zPos * 3), Quaternion.identity) as VisualCell; visualCellInst.transform.parent = transform; visualCellInst._North.gameObject.SetActive(!cell._North); visualCellInst._South.gameObject.SetActive(!cell._South); visualCellInst._Est.gameObject.SetActive(!cell._Est); visualCellInst._West.gameObject.SetActive(!cell._West); visualCellInst.transform.name = cell.xPos.ToString() + "_" + cell.zPos.ToString(); } }