コード例 #1
0
ファイル: LevelController.cs プロジェクト: chadrc/convergence
    private void LoadLevel()
    {
        if (CurrentLevel == null || CurrentLevel.Prefab == null)
        {
            Debug.LogError("Attempting to start level with invalid level data.");
            return;
        }

        var obj = GameObject.Instantiate(CurrentLevel.Prefab);

        if (obj == null)
        {
            Debug.LogError("Failed to create prefab of level: " + CurrentLevel.Name);
            return;
        }

        rootLevelObj = obj;

        levelPlaying = true;
        if (CurrentLevel.convergences.Count > 0)
        {
            ConvergenceController.CreateConvergenceController(this);
        }

        if (LevelStart != null)
        {
            //Debug.Log("Level Starting");
            LevelStart();
        }
    }
コード例 #2
0
 public static void DestoryConvergenceController()
 {
     if (current != null)
     {
         current.routineBehavior.StopCoroutine(current.updateRoutine);
     }
     current             = null;
     ConvergenceOccurred = null;
 }
コード例 #3
0
 public static void CreateConvergenceController(MonoBehaviour routineBehavior)
 {
     if (current == null)
     {
         current              = new ConvergenceController(routineBehavior);
         CurrentInterval      = TimeTillNextConvergence;
         ConvergenceWaveCount = 1;
     }
 }
コード例 #4
0
ファイル: LevelController.cs プロジェクト: chadrc/convergence
    void Awake()
    {
        // Redundant Reset
        ConvergenceController.DestoryConvergenceController();
        Time.timeScale = 1.0f;
        FactionController.SetDefaultFactions();

        // Raise warning if more than one LevelController exists.
        if (current != null)
        {
            Debug.LogWarning("Multiple LevelControllers created. Replacing current.");
        }
        current = this;

        // Check Game for level list
        if (!Game.HasLevelList())
        {
            Game.SetLevelList(DefaultList);
        }

        // Check Game for a selected level
        var selectedLevel = Game.CurrentLevel;

        // If Game has one, else use one assigned in editor
        if (selectedLevel != null)
        {
            CurrentLevel = selectedLevel;
        }

        // If there isn't one and CurrentLevel is still null (i.e. nothing assigned in editor) error is raised.
        if (CurrentLevel == null)
        {
            Debug.LogError("Attempting to start game without any level data.");
            return;
        }
    }
コード例 #5
0
ファイル: LevelController.cs プロジェクト: chadrc/convergence
 void OnDestroy()
 {
     ConvergenceController.DestoryConvergenceController();
     current = null;
 }