public void Notify(IEvent @event) { string topicDescription = @event.Topic.Description; switch (topicDescription) { case "FileDelete": FileDeleteEvent fileDeleteEvent = (FileDeleteEvent)@event; DeleteLevelFile(fileDeleteEvent.FileName); break; case "FileOverride": FileOverrideEvent fileOverrideEvent = (FileOverrideEvent)@event; OverrideLevelFile(fileOverrideEvent.FileName); break; case "FileLoad": LevelLoadEvent levelLoadEvent = (LevelLoadEvent)@event; LoadLevelFile(levelLoadEvent.FileName); break; case "UnlockedLevelsCountRequest": eventsCentre.Publish(new UnlockedLevelsCountReplyEvent(game.CompletedLevelCount)); break; default: throw new AssertionException("Error", "Error"); } }
/// <summary> /// Unlocks all the levels that the play has completed, /// with the exception of the always unlocked main menu level. /// </summary> private void UnlockLevelButtons(IReadOnlyList <Button> levelButtons) { eventsCentre.Publish(new UnlockedLevelsCountRequestEvent()); for (int i = 0; i < unlockedLevelsCount; i++) { levelButtons[i].interactable = true; } }
public void ExitGame() { eventsCentre.Publish(new GameExitEvent()); #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #else Application.Quit(); #endif }
/// <summary> /// Saves the level. /// </summary> /// <remarks> /// This is a wrapper function over the overloaded core <code>SaveLevel#Save(...)</code>. /// If nothing is entered in the input field, the function does nothing. /// </remarks> public void SaveLevel() { string fileName = inputField.text; bool isInputEmpty = fileName.Equals(string.Empty); if (isInputEmpty) { return; } bool isNameTaken = saveMenu.DoesFileWithSameNameExist(fileName); if (isNameTaken) { NotificationManager.Send(new FileAlreadyExistsMessage()); return; } eventsCentre.Publish(new LevelSaveEvent()); saveMenu.AddButton(); ClearInputField(); }
private void End() { eventsCentre.Publish(new LevelNextEvent()); }
public void Restart() { eventsCentre.Publish(new GameRestartEvent()); }
public void StartGame() { eventsCentre.Publish(new GameStartEvent()); }