예제 #1
0
 public void LoadLevel(int levelIndex)
 {
     _currentLevelIndex = levelIndex;
     ObjectPlacement.ClearPlacedObjects();
     IngameUI.ClearList();
     _currentObjectList.Clear();
     _currentObjectList.AddRange(Levels[_currentLevelIndex].Objects);
     for (int objIndex = 0; objIndex < _currentObjectList.Count; ++objIndex)
     {
         int clickIndex = objIndex;
         IngameUI.AddObject(_currentObjectList[objIndex].ObjectImage, _currentObjectList[objIndex].Count,
                            () => ObjectClicked(clickIndex));
     }
     ExecutionDelayer.Instance.ExecuteNextFrame(() =>
                                                UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(IngameUI.GetComponent <RectTransform>()));
     SceneManager.LoadScene(Levels[_currentLevelIndex].SceneName, LoadSceneMode.Single);
     SceneManager.LoadScene("DynamicObjects", LoadSceneMode.Additive);
     ExecutionDelayer.Instance.ExecuteNextFrame(() =>
     {
         SceneManager.SetActiveScene(SceneManager.GetSceneByName("DynamicObjects"));
         var campos = GameObject.FindWithTag("campos");
         if (campos != null)
         {
             CamPan.transform.position    = campos.transform.position;
             CamPan.transform.eulerAngles = new Vector3(CamPan.transform.eulerAngles.x, campos.transform.eulerAngles.y, 0);
         }
     });
     ExecutionDelayer.Instance.ExecuteNextFrame(() => SetState(GameState.PlacingObjects));
 }