예제 #1
0
    void FinishGame()
    {
        Invoke("UIFinishGame", TurnCardUI.animationTime);

        if (currentBoard.userMoves <= 0 || currentBoard.userMoves > scoreCount)
        {
            currentBoard.userMoves = scoreCount;
        }

        GameLog.EndGame();
        Controller.instance.dataManager.UpdateBoardInfo(
            currentBoard.matrix,
            scoreCount,
            GameLog.GetTime(),
            GameLog.GetMoves()
            );

        //TODO: Save current board ONLY
        //Controller.instance.dataManager.SaveLocalInfo(boardLevel, boardID);
    }
예제 #2
0
    IEnumerator ResizeBorders(float waitTime = 0)
    {
        yield return(new WaitForSeconds(waitTime));

Init:
        for (int i = currentBoardMinWidth; i < currentBoardMaxWidth; ++i)
        {
            for (int j = currentBoardMinHeight; j < currentBoardMaxHeight; ++j)
            {
                if (cards[i, j].isBusy)
                {
                    yield return(new WaitForSeconds(waitTimeStep));

                    goto Init;
                }
            }
        }

        int ac;

        if (currentBoardMinHeight >= currentBoardMaxHeight || currentBoardMinWidth >= currentBoardMaxWidth)
        {
            goto EndGame;
        }

InitBottom:
        ac = 0;
        //BOTTOM LINE
        for (int i = currentBoardMinWidth; i < currentBoardMaxWidth; ++i)
        {
            if (!cards[i, currentBoardMinHeight].isBack)
            {
                break;
            }
            else
            {
                ac++;
            }
        }
        if (ac == (currentBoardMaxWidth - currentBoardMinWidth))
        {
            for (int i = currentBoardMinWidth; i < currentBoardMaxWidth; ++i)
            {
                cards[i, currentBoardMinHeight].HideCard();
            }
            currentBoardMinHeight++;
            if (currentBoardMinHeight >= currentBoardMaxHeight)
            {
                goto EndGame;
            }
            else
            {
                goto InitBottom;
            }
        }


InitTop:
        ac = 0;
        //TOP LINE
        for (int i = currentBoardMinWidth; i < currentBoardMaxWidth; ++i)
        {
            if (!cards[i, currentBoardMaxHeight - 1].isBack)
            {
                break;
            }
            else
            {
                ac++;
            }
        }
        if (ac == (currentBoardMaxWidth - currentBoardMinWidth))
        {
            for (int i = currentBoardMinWidth; i < currentBoardMaxWidth; ++i)
            {
                cards[i, currentBoardMaxHeight - 1].HideCard();
            }
            currentBoardMaxHeight--;
            if (currentBoardMaxHeight <= currentBoardMinHeight)
            {
                goto EndGame;
            }
            else
            {
                goto InitTop;
            }
        }

InitLeft:
        ac = 0;
        //LEFT COLUMN
        for (int i = currentBoardMinHeight; i < currentBoardMaxHeight; ++i)
        {
            if (!cards[currentBoardMinWidth, i].isBack)
            {
                break;
            }
            else
            {
                ac++;
            }
        }
        if (ac == (currentBoardMaxHeight - currentBoardMinHeight))
        {
            for (int i = currentBoardMinHeight; i < currentBoardMaxHeight; ++i)
            {
                cards[currentBoardMinWidth, i].HideCard();
            }
            currentBoardMinWidth++;
            if (currentBoardMinWidth >= currentBoardMaxWidth)
            {
                goto EndGame;
            }
            else
            {
                goto InitLeft;
            }
        }

InitRight:
        //RIGHT COLUMN
        ac = 0;
        for (int i = currentBoardMinHeight; i < currentBoardMaxHeight; ++i)
        {
            if (!cards[currentBoardMaxWidth - 1, i].isBack)
            {
                break;
            }
            else
            {
                ac++;
            }
        }
        if (ac == (currentBoardMaxHeight - currentBoardMinHeight))
        {
            for (int i = currentBoardMinHeight; i < currentBoardMaxHeight; ++i)
            {
                cards[currentBoardMaxWidth - 1, i].HideCard();
            }
            currentBoardMaxWidth--;
            if (currentBoardMaxWidth <= currentBoardMinWidth)
            {
                goto EndGame;
            }
            else
            {
                goto InitRight;
            }
        }

//		GameObject.Find("Text_Moves").GetComponent<Text>().text = "" +
//			 "Width[" + currentBoardMinWidth  + "," + currentBoardMaxWidth  + "]\n" +
//			"Height[" + currentBoardMinHeight + "," + currentBoardMaxHeight + "]\n";

        yield break;

EndGame:
        gameEnded = true;

        EndGame();

        GameLog.EndGame();
        GameDataWWW.UpdateBoardInfo(
            boardMatrix,
            scoreCount,
            GameLog.GetTime(),
            GameLog.GetMoves()
            );

        GameData.SaveBoard(boardLevel, boardID);


        textTimerCountdown.text = "Next In 5";
        if (retry)
        {
            goto EndFunc;
        }
        yield return(new WaitForSeconds(1));

        if (retry)
        {
            goto EndFunc;
        }
        textTimerCountdown.text = "Next In 4";
        yield return(new WaitForSeconds(1));

        if (retry)
        {
            goto EndFunc;
        }
        textTimerCountdown.text = "Next In 3";
        yield return(new WaitForSeconds(1));

        if (retry)
        {
            goto EndFunc;
        }
        textTimerCountdown.text = "Next In 2";
        yield return(new WaitForSeconds(1));

        if (retry)
        {
            goto EndFunc;
        }
        textTimerCountdown.text = "Next In 1";
        yield return(new WaitForSeconds(1));

        if (retry)
        {
            goto EndFunc;
        }
        textTimerCountdown.text = "Next\nIn 0";
        yield return(new WaitForSeconds(.2f));


        if (retry)
        {
            goto EndFunc;
        }
        else
        {
            if (isRandom)
            {
                GenerateRandomMatrix();
            }
            else
            {
                GenerateNextMatrix();
            }
        }

EndFunc:
        retry = false;
        yield break;
    }