//把轉移到指定場景
    bool SwitchToStage(int stageIndex)
    {
        try
        {
            //先指定
            _nowState = _listSceneManager[stageIndex];
        }
        catch
        {
            return(false);
        }


        //把場景複製過來
        //_nowState = Instantiate(_listStage[stageIndex]);
        //_nowState.transform.parent = this.transform;

        //還有設定關卡的參數
        _nowState._difficulity = _passParameter.difficulity;
        //把玩家設定上去
        _nowState.SetPlayer(_player);
        //然後是設定事件
        _nowState._playerFinishStage += new StageController.PlayerFinishStage(StageFinishGoal); //完成關卡,就跳到下一個關卡,如果沒關卡了就顯示結果
        _nowState._playerStageFall   += new StageController.PlayerStageFall(StageFall);         // 直接切回第一個關卡?
        _nowState._playerExitGame    += new StageController.PlayExitGame(GoToMainMenuScene);    //直接離開遊戲
        _nowState._playerRestartGame += new StageController.PlayerRestartGame(Restart);         //重新開始遊戲

        //如果要設定時間
        if (_passParameter.limitStageTime)
        {
            //_nowState.GetComponent<StageController>().SetTimeLimit();
        }
        //把人物設定是在哪個場景
        _player.GetComponent <SteamVR_CharacterController>().SetNowAtStageController(_nowState.GetComponent <StageController>());
        //在通知廠景要開始惹
        _nowState.GetComponent <StageController>().StartGame();

        //如果時間不是9999,就代表使用系統時間

        try
        {
        }
        catch (Exception ex)
        {
            Debug.Log("Scene Error :" + ex.Message);
        }
        return(true);
    }
Example #2
0
    public void StageComplete(StageController targetStage)
    {
        targetStage.CurrentLoop = false;
        targetStage.GetComponent <Rotator>().enabled             = false;
        targetStage.GetComponentInChildren <Renderer>().material = LevelController.Instance.selectedMat;

        currentStageIndex++;
        StartCoroutine(FinishRotation(targetStage));
    }