/// <summary> /// Go to a new level. /// </summary> /// <param name="name">Level name.</param> public static void GotoLevel(string name) { if (!LevelExists(name)) throw new ArgumentException("Level with such name does not exist!"); if(CurrentScene != null) CurrentScene.OnLevelEnded(); CurrentScene = Scenes[name]; CurrentScene.OnLevelStarted(); }
/// <summary> /// Create a new level and add it to the storyboard. /// </summary> /// <param name="name">Desired level name (must be unique across the game).</param> /// <param name="level">Level.</param> /// <returns></returns> public static void AddLevel(string name, GameScene level) { if(LevelExists(name)) throw new ArgumentException("Level with such name already exists!"); Scenes.Add(name, level); if (CurrentScene == null) { CurrentScene = level; level.OnLevelStarted(); } }
/// <summary> /// Remove a specific level from storyboard. /// </summary> /// <param name="name">Level.</param> public static void RemoveLevel(string name) { if (Scenes.ContainsKey(name)) { var scene = Scenes[name]; if (scene == CurrentScene) CurrentScene = null; Scenes.Remove(name); } }