コード例 #1
0
    private IEnumerator Init()
    {
        completeQuiz = false;  // determine the quiz is done or not

        fc = FirebaseController.Instance;

        // yield return fc.GetBankList(); //TODO wait until we can select the question bank

        if (!fc.InitReady)
        {
            yield return(fc.InitQuizer(Properties.Instance.BANK_NAME));   //TODO change by giving bank list, the property may store in game controller
        }

        // Update the number of question will be access in the UI
        ProgressUIManager.GetComponent <ProgressUIManager>().UpdateRemainingQuestions(fc.Histories.Count.ToString());

        int totalQuestions = FirebaseController.Instance.Histories.Count;

        if (totalQuestions >= 10)
        {
            GenerateRooms(10); // TODO

            // respawn enemies
            if (totalQuestions > 15)
            {
                RespawnEnemies(15);
            }
            else
            {
                RespawnEnemies(totalQuestions);
            }
        }
        else if (totalQuestions > 0)
        {
            int roomNumber = totalQuestions;
            if (roomNumber == 1)
            {
                GenerateRooms(2);
            }
            GenerateRooms(roomNumber);

            // respawn enemies
            RespawnEnemies(totalQuestions);
        }
        else
        {
            Debug.Log("No question need to be assessed.");

            //completeQuiz = true;
            StartCoroutine(CompleteQuiz());
        }
    }