예제 #1
0
    /// <summary>
    /// The turn the routine of this selector.
    /// </summary>
    /// <returns>The routine.</returns>
    /// <param name="angleDir">Angle dir.</param>
    public override IEnumerator TurnRoutine(int angleDir)
    {
        GameSkeleton.inputManager.IsReadyForInput = false;
        SelectorManager selectorManager = GameSkeleton.selectorManager;

        //initialize selecteds
        List <Transform> selecteds = selectorManager.SelectedPieceGroup.AddThisGroupPiecesInToTheTransformList();

        initializeSelectedsForTurn(selecteds);

        //get start rotation euler
        Vector3 startEuler = selectorManager.currentSelectorObject.transform.rotation.eulerAngles;

        //this is the algorith for that when in 3 selecteds turned on clockwise, if 2 of them in left 1 of them is right, indexes changes clockwise
        //but the in other situation indexes changes counter-clockwise
        //index turn direction also can be found with middle index minus lower index == 1 or bigger,
        int indexTurnDir = selecteds.CheckIfItsHaveAHighestXValue() == true ? angleDir : -angleDir;

        for (int i = 0; i < 3; i++)
        {
            //turn the selector
            for (int x = 0; x < 10; x++)
            {
                startEuler.z += (12f * angleDir);
                selectorManager.currentSelectorObject.transform.rotation = Quaternion.Euler(startEuler);
                yield return(new WaitForFixedUpdate());
            }
            //correct Selecteds rotation
            for (int b = 0; b < selecteds.Count; b++)
            {
                selecteds [b].GetComponent <GridPiece> ().CorrectRotationWhenSelectorTurns();
            }
            //turn idexes according to indexTurnDirection
            TurnSelectedIndexesInGridSystem(indexTurnDir);
            //wait for smoothness
            yield return(new WaitForSeconds(0.05f));

            //check for any explosion
            if (ExplosionSystem.IsAnyExplosionInTheSystem)
            {
                resetSelectedsAfterTurn(selecteds);
                selectorManager.currentSelectorObject.SetActive(false);
                Stats.movedCountSystem.ActionMaded();
                yield return(GameSkeleton.Instance.StartCoroutine(ExplosionSystem.Explode()));

                yield break;
            }
        }
        resetSelectedsAfterTurn(selecteds);

        GameSkeleton.inputManager.IsReadyForInput = true;
    }
예제 #2
0
    public static IEnumerator Explode()
    {
        //patlayacak tüm grupları al
        List <IndexGroup> explodingGroups = giveEveryGroupThatGoingToExplodeInExplosionTypes();

        //patlayacak gruplarda
        visualProcessInTheExplodingGroups(explodingGroups);
        yield return(GameSkeleton.Instance.StartCoroutine(spawnNewPiecesInTheMapAndRecorrectGridIndexes(divideExplodingGroupsInToColumns(explodingGroups))));

        yield return(new WaitForSeconds(.1f));

        if (IsAnyExplosionInTheSystem)
        {
            GameSkeleton.Instance.StartCoroutine(ExplosionSystem.Explode());
            yield break;
        }
        //Game over checks
        GameSkeleton.Instance.GameOverChecks();
    }