Пример #1
0
    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
    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
 void OnDestroy()
 {
     ConvergenceController.DestoryConvergenceController();
     current = null;
 }