Beispiel #1
0
    void Update()
    {
        if (switchingObjects.Count() == 2)
        {
            GridObject first = switchingObjects.First();
            if (first.Position() == first.gameObject.transform.position)
            {
                if (Matches().Count > 0)
                {
                    score.StartSequence();
                    score.AddMove();
                    CheckMatches();
                }
                else
                {
                    Debug.Log("cant move there");
                    audio.PlayOneShot(rejectSound);
                    grid.Switch(first, switchingObjects [1]);
                }
                switchingObjects = new List <GridObject> ();
            }
        }
        if (!preventInput)
        {
            if (Input.GetMouseButtonDown(2))
            {
                grid.ResetBoard();
            }
            if (Input.GetMouseButtonDown(1))
            {
                int newRotationIndex;
                if (grid.rotationIndex != (grid.RowsByDirection().Count - 1))
                {
                    newRotationIndex = grid.rotationIndex + 1;
                }
                else
                {
                    newRotationIndex = 0;
                }
                Debug.Log("newRotationIndex: " + newRotationIndex);
                grid.SetTopTo(newRotationIndex);
            }

            if (!grid.IsRegenerating() && !isRotating)
            {
                GetRotationInput();
            }
        }
        if (isRotating)
        {
            ContinueRotation();
        }
    }