コード例 #1
0
ファイル: StageController.cs プロジェクト: jessekwong/WIP2020
    /// <summary>
    /// coroutine that gets ran when a stage is complete
    /// </summary>
    /// <returns></returns>
    IEnumerator StageClearSequence()
    {
        yield return(new WaitForSeconds(1));

        MainCharacterController cont          = PlayerInstance.GetComponent <MainCharacterController>();
        List <Skill>            unlockedSkill = UnlockSkill(currentStage.UnlockedSkill);

        //level up  stats on player and save stats
        ProgressSave.Instance.LevelUp();

        //unlock skill for player
        for (int i = 0; i < unlockedSkill.Count; i++)
        {
            cont.LearnSkill(unlockedSkill[i]);
        }



        //display stage complete screen
        if (!StageCompleteInstance)
        {
            StageCompleteInstance = Instantiate(StageCompletePrefab, CameraUI.transform);
        }
        else
        {
            StageCompleteInstance.SetActive(true);
        }


        StageCompleteInstance.GetComponent <StageComplete>().Init(stageNumber, unlockedSkill, cont.GetSkillPool(), cont, currentStage.UpgradeRewards);

        //wait for stage complete screen to be closed to move on
        while (StageCompleteInstance.activeSelf)
        {
            yield return(null);
        }
        // upgrades screen
        upgradesLeft = currentStage.UpgradeRewards;
        ShowUpgradeScreen();
        upgradesComplete = false;
        while (!upgradesComplete)
        {
            yield return(null);
        }


        // save upgraded version of skills and equipped slots
        cont.SaveSkills();
        initialized = false;
        Init(ProgressSave.Instance.CurrentLevel); //place holder for next stage, in the future need to implement load scene
    }