Beispiel #1
0
    /// <summary>
    /// Rotates cover object by given CoverObjectDirection
    /// </summary>
    /// <param name="cod"></param>
    /// <param name="closestIndexes"></param>
    /// <returns></returns>
    internal override IEnumerator rotateRoutine(CoverObjectDirection cod, List <int> closestIndexes)
    {
        closestIndexes.changeSortingOrder(1);
        closestIndexes.setParent(transform);
        closestIndexes.Sort();
        for (int i = 0; i < 3; i++)
        {
            if (closestIndexes[1] - closestIndexes[0] == 1)//<<if cover object's, two 'vertical aligned' nodes, on the left side
            {
                if (cod != CoverObjectDirection.Clockwise)
                {
                    yield return(StartCoroutine(turnAnim(1f, 0.20f)));

                    closestIndexes.turnIndexesByGivenDirection(1);
                }
                else
                {
                    yield return(StartCoroutine(turnAnim(-1f, 0.20f)));

                    closestIndexes.turnIndexesByGivenDirection(-1);
                }
            }
            else
            {
                if (cod != CoverObjectDirection.Clockwise)
                {
                    yield return(StartCoroutine(turnAnim(1f, 0.20f)));

                    closestIndexes.turnIndexesByGivenDirection(-1);
                }
                else
                {
                    yield return(StartCoroutine(turnAnim(-1f, 0.20f)));

                    closestIndexes.turnIndexesByGivenDirection(1);
                }
            }

            yield return(new WaitForSeconds(0.05f));                                                  //smoothing

            if (GridSystem.uniqueTriples.checkGroupTriplesHaveSameCountOfColorByGivenCountOfColor(1)) //explosion detected
            {
                resetNodesByIndexes(closestIndexes);
                gameObject.SetActive(false);
                GameManager.instance.explosionManager.startExplode(GetType(), GridSystem.uniqueTriples.giveEveryGroupThatWillExplode(1));
                yield break;
            }
        }
        resetNodesByIndexes(closestIndexes);
        SwipeLogger.checkForInput();
        GameManager.instance.inputSys.enabled = true;
    }
Beispiel #2
0
    private void SwipeDetector_OnSwipe(SwipeData data, Node currentNode)
    {
        Vector2 EndPosition = Camera.main.ScreenToWorldPoint(data.EndPosition);

        switch (data.Direction)
        {
        case SwipeDirection.Up:
            cod = EndPosition.x < NodePosition.x ? CoverObjectDirection.Clockwise : CoverObjectDirection.CounterClockwise;
            break;

        case SwipeDirection.Down:
            cod = EndPosition.x < NodePosition.x ? CoverObjectDirection.CounterClockwise : CoverObjectDirection.Clockwise;
            break;

        case SwipeDirection.Left:
            cod = EndPosition.y > NodePosition.y ? CoverObjectDirection.CounterClockwise : CoverObjectDirection.Clockwise;
            break;

        case SwipeDirection.Right:
            cod = EndPosition.y > NodePosition.y ? CoverObjectDirection.Clockwise : CoverObjectDirection.CounterClockwise;
            break;

        default:
            break;
        }
        if (!lastProcessed)
        {
            if (GameManager.instance.coverObjManager.currentCoverObject != null)
            {
                if (GameManager.instance.coverObjManager.currentCoverObject.isActiveAndEnabled)
                {
                    GameManager.instance.inputSys.enabled = false;
                    GameManager.instance.coverObjManager.startRotate(cod);
                    lastProcessed = true;
                }
            }
        }
    }
 /// <summary>
 /// Starts rotating current coverobject according to coverobjectdrection
 /// </summary>
 /// <param name="cod"></param>
 public void startRotate(CoverObjectDirection cod)
 {
     currentCoverObject.rotate(cod, currentIndexes);
 }
Beispiel #4
0
 internal virtual IEnumerator rotateRoutine(CoverObjectDirection cod, List <int> closestIndexes)
 {
     throw new System.NotImplementedException();
 }
Beispiel #5
0
 public virtual void rotate(CoverObjectDirection cod, List <int> closestIndexes)
 {
     throw new System.NotImplementedException();
 }
Beispiel #6
0
 /// <summary>
 /// Starts rotating the coverobject
 /// </summary>
 /// <param name="cod"></param>
 /// <param name="closestIndexes"></param>
 public override void rotate(CoverObjectDirection cod, List <int> closestIndexes)
 {
     StartCoroutine(rotateRoutine(cod, closestIndexes));
 }