Exemplo n.º 1
0
        public void MoveBrush(Swipe swipe)
        {
            Vector2Int newCoords = grid.GetCellXZBySwipe(currentBrush.currentCoords.x, currentBrush.currentCoords.y, swipe);

            if (newCoords != new Vector2Int(-1, -1))
            {
                SoundManager.Instance.PlayFx(FxType.BrushMove);
                Vector3 finalPos = grid.GetCellWorldPositionBySwipe(currentBrush.currentCoords.x, currentBrush.currentCoords.y, swipe);

                if (!ConnectionAlreadyDone(currentBrush.currentCoords, newCoords, true))
                {
                    inProgressPattern.Add(new ConnectedLine(currentBrush.currentCoords, newCoords));
                    cells[currentBrush.currentCoords.x, currentBrush.currentCoords.y].CellCenterPaint.gameObject.SetActive(true);
                    cells[currentBrush.currentCoords.x, currentBrush.currentCoords.y].CellCenterPaint.material.color = colors[GameManager.currentLevel % colors.Length];
                    LinePaintScript linePaint = Instantiate(linePaintPrefab, new Vector3(0, 0.2f, 0), Quaternion.identity);
                    linePaint.SetRendererPosition(currentBrush.transform.position + new Vector3(0, 0.2f, 0),
                                                  finalPos + new Vector3(0, 0.2f, 0), colors[GameManager.currentLevel % colors.Length]);
                    linePaint.SetConnectedCoords(currentBrush.currentCoords, newCoords);
                    connectedLinePaints.Add(linePaint);
                }
                else
                {
                    RemoveConnectLinePaint(currentBrush.currentCoords, newCoords);
                }

                if (leveldataArray[GameManager.currentLevel].completePattern.Count <= inProgressPattern.Count)
                {
                    //Check for win
                    if (IsLevelComplete())
                    {
                        SoundManager.Instance.PlayFx(FxType.Victory);
                        GameManager.gameStatus = GameStatus.Complete;
                        GameManager.currentLevel++;
                        if (GameManager.currentLevel > leveldataArray.Length - 1)
                        {
                            GameManager.currentLevel = 0;
                        }
                        PlayerPrefs.SetInt("CurrentLevel", GameManager.currentLevel);
                        GameManager.totalDiamonds += 15;
                        PlayerPrefs.SetInt("TotalDiamonds", GameManager.totalDiamonds);

                        uIManager.LevelCompleted();
                    }
                }

                currentBrush.transform.position = finalPos;
                currentBrush.currentCoords      = newCoords;
            }
        }
Exemplo n.º 2
0
        private void CompleteBoard()
        {
            Vector3 offset        = new Vector3((leveldataArray[GameManager.currentLevel].width - _cellSize) / 2, 5f, (leveldataArray[GameManager.currentLevel].height - _cellSize) / 2);
            Vector3 gridOriginPos = solutionCamera.transform.position - offset;

            solutionCamera.ZoomOrthographicSizeCamera(leveldataArray[GameManager.currentLevel].width, leveldataArray[GameManager.currentLevel].height);

            for (int i = 0; i < leveldataArray[GameManager.currentLevel].completePattern.Count; i++)
            {
                Vector3         startPos  = gridOriginPos + grid.GetCellWorldPosition(leveldataArray[GameManager.currentLevel].completePattern[i].startCoord);
                Vector3         endPos    = gridOriginPos + grid.GetCellWorldPosition(leveldataArray[GameManager.currentLevel].completePattern[i].endCoord);
                LinePaintScript linePaint = Instantiate(linePaintPrefab, new Vector3(0, 0.2f, 0), Quaternion.identity);
                linePaint.SetRendererPosition(startPos + new Vector3(0, 0.2f, 0),
                                              endPos + new Vector3(0, 0.2f, 0), colors[GameManager.currentLevel % colors.Length]);
            }
        }