private void animate(GridCell cell, Color color) // animate only DefaultCell { cell.setColor(color, immediately: true); DefaultCell defaultCell = cell as DefaultCell; Vector3 cachedPosition = defaultCell.platform.localPosition; Vector3 cachedRotation = defaultCell.platform.eulerAngles; if (cell.previousSelectedCell.index.x != cell.index.x) { float sign = Mathf.Sign(cell.index.x - cell.previousSelectedCell.index.x); defaultCell.platform.Translate(-.5f * sign, .5f, 0f, Space.World); defaultCell.platform.Rotate(Vector3.forward * 90f * sign); } if (cell.previousSelectedCell.index.y != cell.index.y) { float sign = Mathf.Sign(cell.previousSelectedCell.index.y - cell.index.y); defaultCell.platform.Translate(0f, .5f, .5f * sign, Space.World); defaultCell.platform.Rotate(Vector3.right * 90f * sign); } defaultCell.platform.DOLocalMove(cachedPosition, .5f).SetEase(Ease.OutCubic); defaultCell.platform.DORotate(cachedRotation, .75f).SetEase(Ease.OutCubic); }
public override void setup_map() { Cell[,] array = new Cell[x_max, y_max]; Random rnd = new Random(); for (int x = 0; x < x_max; x++) { for (int y = 0; y < y_max; y++) { array[x, y] = new DefaultCell(x, y, CellState.Dead); } } array[1, 5].state = CellState.Live; array[2, 5].state = CellState.Live; array[1, 6].state = CellState.Live; array[2, 6].state = CellState.Live; array[11, 5].state = CellState.Live; array[11, 6].state = CellState.Live; array[11, 7].state = CellState.Live; array[12, 4].state = CellState.Live; array[13, 3].state = CellState.Live; array[14, 3].state = CellState.Live; array[12, 8].state = CellState.Live; array[13, 9].state = CellState.Live; array[14, 9].state = CellState.Live; array[15, 6].state = CellState.Live; array[16, 4].state = CellState.Live; array[16, 8].state = CellState.Live; array[17, 5].state = CellState.Live; array[17, 6].state = CellState.Live; array[17, 7].state = CellState.Live; array[18, 6].state = CellState.Live; array[21, 3].state = CellState.Live; array[21, 4].state = CellState.Live; array[21, 5].state = CellState.Live; array[22, 3].state = CellState.Live; array[22, 4].state = CellState.Live; array[22, 5].state = CellState.Live; array[23, 2].state = CellState.Live; array[23, 6].state = CellState.Live; array[25, 1].state = CellState.Live; array[25, 2].state = CellState.Live; array[25, 6].state = CellState.Live; array[25, 7].state = CellState.Live; array[35, 3].state = CellState.Live; array[35, 4].state = CellState.Live; array[36, 3].state = CellState.Live; array[36, 4].state = CellState.Live; map = new DefaultCellMap(array, square_size); }
public override void setup_map() { Cell[,] array = new Cell[x_max, y_max]; for (int x = 0; x < x_max; x++) { for (int y = 0; y < y_max; y++) { CellState state = CellState.Dead; if ((x - y) % 2 == 1) { state = CellState.Live; } array[x, y] = new DefaultCell(x, y, state); } } map = new DefaultCellMap(array, square_size); }
public virtual void setup_map() { Cell[,] array = new Cell[x_max, y_max]; for (int x = 0; x < x_max; x++) { for (int y = 0; y < y_max; y++) { CellState state = CellState.Dead; if (x >= 1 && x <= x_max - 5 && y == decimal.Round(y_max / 2)) { state = CellState.Live; } array[x, y] = new DefaultCell(x, y, state); } } map = new DefaultCellMap(array, square_size); }
public override void setup_map() { Cell[,] array = new Cell[x_max, y_max]; Random rnd = new Random(); for (int x = 0; x < x_max; x++) { for (int y = 0; y < y_max; y++) { CellState state = CellState.Dead; if (x % rnd.Next(1, 10) == 1 || y / rnd.Next(1, 5) == 0) { state = CellState.Live; } array[x, y] = new DefaultCell(x, y, state); } } map = new DefaultCellMap(array, square_size); }
private IEnumerator _showPictureFrame() { yield return(new WaitUntil(() => pixelizationCount == 0)); // wait for all cells ready planeBorders.material.DOColor(colorScheme.randomBorderColor, 1f); foreach (GridCell cell in grid.totalCells.OrderBy(rnd => UnityEngine.Random.value)) { if (cell is DefaultCell) { DefaultCell defaultCell = cell as DefaultCell; foreach (Transform cellPart in defaultCell.meshTransforms) { cellPart.DOMove(pictureFrame.transform.position, UnityEngine.Random.Range(.5f, 1f)).SetDelay(UnityEngine.Random.Range(.5f, 2f)).OnStart(() => { cellPart.DOScale(Vector3.zero, 1f).SetEase(Ease.OutCirc); }); } } else { Destroy(cell.gameObject); } } yield return(new WaitForSeconds(.5f)); // confetti for (int i = 0; i < 10; i++) { ParticleSystem confetti = Instantiate(confettiPs, grid.randomCell().transform.position + (Vector3.up * 15f), Quaternion.identity); ParticleSystemRenderer confettiRenderer = confetti.GetComponent <ParticleSystemRenderer>(); confettiRenderer.material = confettiMaterials[UnityEngine.Random.Range(0, confettiMaterials.Length)]; confetti.Play(); } pictureFrame.setSprite(colorPicker.sprite); yield return(new WaitForSeconds(4f)); gameController.uiManager.showEndLevelMenu(); }
private IEnumerator _pixelizeFilledCell(List <List <GridCell> > selectedCells) { pixelizationCount++; foreach (List <GridCell> cellsRange in selectedCells) { foreach (GridCell cell in cellsRange) { DefaultCell defaultCell = cell as DefaultCell; List <Color> defaultCellPartColors = new List <Color>(); foreach (Transform defaultCellPart in defaultCell.meshTransforms) { defaultCellPart.DORotate(Vector3.up * 90f * (Utility.maybe ? -1f : 1f), .5f); Color averageColor = colorPicker.getPixelAverageColor(defaultCellPart, Vector3.down); defaultCellPartColors.Add(averageColor); } defaultCell?.setColor(defaultCellPartColors); cell.transform.DOLocalJump(cell.transform.localPosition, 2f, 1, .5f).SetEase(Ease.Linear); } yield return(new WaitForSeconds(.05f)); } pixelizationCount--; }