Beispiel #1
0
    IEnumerator TurnRoutine(bool moveRight)
    {
        for (int i = 0; i < 3; i++)
        {
            GameManager.instance.canHexTakeNewPlace = false;
            matchHandler.ClearMatch();

            if (matchHandler.stopRoutine)
            {
                InputManager.getInput    = true;
                matchHandler.stopRoutine = false;
                matchHandler.ClearMatch();
                ResetState();
                GameManager.instance.moves++;
                uıManager.UpdateMovesText();
                yield return(new WaitForSeconds(0.4f));

                GameManager.instance.canHexTakeNewPlace = true;
                break;
            }

            if (moveRight)
            {
                if (firstHex != null)
                {
                    firstHex.Move(secondHex.column, secondHex.row, GameManager.instance.hexSwitchSpeed);
                }
                if (secondHex != null)
                {
                    secondHex.Move(thirdHex.column, thirdHex.row, GameManager.instance.hexSwitchSpeed);
                }
                if (thirdHex != null)
                {
                    thirdHex.Move(firstHex.column, firstHex.row, GameManager.instance.hexSwitchSpeed);
                }
            }
            else
            {
                if (firstHex != null)
                {
                    firstHex.Move(thirdHex.column, thirdHex.row, GameManager.instance.hexSwitchSpeed);
                }
                if (secondHex != null)
                {
                    secondHex.Move(firstHex.column, firstHex.row, GameManager.instance.hexSwitchSpeed);
                }
                if (thirdHex != null)
                {
                    thirdHex.Move(secondHex.column, secondHex.row, GameManager.instance.hexSwitchSpeed);
                }
            }

            yield return(new WaitForSeconds(GameManager.instance.hexSwitchSpeed));

            matchHandler.AddMatch();
            if (i == 2)
            {
                GameManager.instance.moves++;
                uıManager.UpdateMovesText();
                GameManager.instance.canHexTakeNewPlace = true;
                InputManager.getInput = true;
            }
            ResetState();
            yield return(null);
        }
    }