コード例 #1
0
    private void Update()
    {
        if (checkTime && !iu.IsGameOver())
        {
            timeLeft -= Time.deltaTime;
        }

        if (gu.WorkingObjs == 0)
        {
            if (needToCheck)
            {
                CheckGemGrid();
                FillGemGrid();
            }

            // Defeat
            if (suboptimalMoves <= 0)
            {
                if (!checkTime && !checkMoves)
                {
                    UpdateResults(true);
                    gu.DrawEndScreen(true);
                    iu.SetGameOver();
                }
                else
                {
                    UpdateResults(false);
                    gu.DrawEndScreen(false);
                    iu.SetGameOver();
                }
            }
            if (((checkTime && timeLeft <= 0) || (checkMoves && movesLeft <= 0)) && score < pu.scoreToWin)
            {
                UpdateResults(false);
                gu.DrawEndScreen(false);
                iu.SetGameOver();
            }
            else
            {
                // Victory
                if (pu.winCondition - 1 == (int)ParamUnit.WinCondition.FIELD_IS_EMPTY)
                {
                    int nonEmpty = 0;
                    foreach (Cell c in grid)
                    {
                        if (!c.IsEmpty())
                        {
                            nonEmpty++;
                        }
                    }
                    if (nonEmpty == 0)
                    {
                        UpdateResults(true);
                        gu.DrawEndScreen(true);
                        iu.SetGameOver();
                    }
                }

                if (pu.winCondition - 1 == (int)ParamUnit.WinCondition.SCORE_REACHED)
                {
                    if (score >= pu.scoreToWin && ((checkTime && timeLeft <= 0) || (checkMoves && movesLeft <= 0)))
                    {
                        UpdateResults(true);
                        gu.DrawEndScreen(true);
                        iu.SetGameOver();
                    }
                }
            }
        }
    }