public override void InitCells() { cells = new List <List <GameCell> >(); for (int x = 0; x < size.x; x++) { List <GameCell> newColumn = new List <GameCell>(); for (int y = 0; y < size.y; y++) { Hexacell newCell = Instantiate <Hexacell>(cellPrefab as Hexacell, this.transform); newCell.Init(); newCell.transform.localPosition = GetHexaPosition(x, y); newCell.coordinates = new Vector2Int(x, y); newCell.SetColor((x + y) % 2 == 0 ? color1 : color2); newCell.SetRenderOrder(size.y - y); newCell.name = "Cell (" + x + ", " + y + ")"; if (x == 0 || x == size.x - 1 || x / 2 + y < (size.x) / 2 || x / 2 + y >= size.x - 1) { newCell.SetWall(true); newCell.SetColor(new Color(0f, 0f, 0f, 0f)); newCell.isStatic = true; } newColumn.Add(newCell as GameCell); } cells.Add(newColumn); } }
private void OnTriggerEnter2D(Collider2D collision) { Hexacell cell = collision.GetComponent <Hexacell>(); if (cell != null && Coordinates != cell.coordinates) { Coordinates = cell.coordinates; cell.SetTemporaryColor(cellColor); heroCell.position = board.CoordinatesToPosition(Coordinates); } }
private void OnTriggerEnter2D(Collider2D collision) { Hexacell cell = collision.GetComponent <Hexacell>(); if (cell != null) { cell.SetTemporaryColor(color); cell.StartCoroutine(cell.GetBackToDefaultColorCoroutine()); cell.SetWall(false); return; } }
private void OnTriggerExit2D(Collider2D collision) { Hexacell cell = collision.GetComponent <Hexacell>(); if (cell != null && prevCoordinates != cell.coordinates) { prevCoordinates = cell.coordinates; cell.StartCoroutine(cell.GetBackToDefaultColorCoroutine()); if (Input.GetButton("Fire1")) { UseWallPower(); } } }
public override void InitCells() { cells = new List <List <GameCell> >(); for (int x = 0; x < size.x; x++) { List <GameCell> newColumn = new List <GameCell>(); for (int y = 0; y < size.y; y++) { Hexacell newCell = Instantiate <Hexacell>(cellPrefab as Hexacell, this.transform); newCell.Init(); newCell.CellChangeEvent.AddListener(new UnityAction(OnCellChange)); newCell.transform.localPosition = GetHexaPosition(x, y); newCell.SetColor((x + y) % 2 == 0 ? color1 : color2); newCell.name = "Cell (" + x + ", " + y + ")"; newColumn.Add(newCell as GameCell); } cells.Add(newColumn); } SetStartEndLabels(); }