Exemplo n.º 1
0
        private void Update()
        {
            if (scoreManager.ObjectiveCount <= 0)
            {
                SceneManager.LoadScene("GameWon", LoadSceneMode.Single);
            }
            else if (scoreManager.Moves <= 0)
            {
                SceneManager.LoadScene("GameOver", LoadSceneMode.Single);
            }

            var interaction = controls.GetInteraction();

            if (interaction != null && cellGrid.Events.Count == 0)
            {
                var point     = GridQuery.ToPoint(this.visualGrid, interaction);
                var cell      = cellGrid.Columns[point.x][point.y];
                var positions = cell.GetPositionsOrDefault(cellGrid);

                if (positions != null)
                {
                    this.scoreManager.Moves--;
                    foreach (var position in positions)
                    {
                        if (cellGrid.Columns[position.x][position.y].Type == this.scoreManager.ObjectiveType)
                        {
                            this.scoreManager.ObjectiveCount--;
                        }
                    }

                    CellGridOperation.RemoveCells(cellGrid, positions);
                }
            }
            else if (cellGrid.Events.Count == 0)
            {
                CellGridOperation.Fill(cellGrid);
            }
            else if (cellGrid.Events.Count > 0)
            {
                this.visualGrid.Sync(cellGrid);
            }

            this.visualGrid.Cascade();
        }
Exemplo n.º 2
0
        private void OnDrawGizmos()
        {
            var cellGrid = new CellGrid(gridWidth, gridHeight);

            CellGridOperation.Fill(cellGrid);

            foreach (var column in cellGrid.Columns)
            {
                foreach (var cell in column)
                {
                    var point  = GridQuery.ToPoint(cellGrid, cell);
                    var center = new Vector3(point.x, point.y);
                    var size   = new Vector3(1, 1, 1);

                    Gizmos.color = Color.yellow;
                    Gizmos.DrawWireCube(center, size);
                }
            }
        }