Beispiel #1
0
        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");
            }
        }
Beispiel #2
0
 /// <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;
     }
 }
Beispiel #3
0
        public void ExitGame()
        {
            eventsCentre.Publish(new GameExitEvent());

#if UNITY_EDITOR
            UnityEditor.EditorApplication.isPlaying = false;
#else
            Application.Quit();
#endif
        }
Beispiel #4
0
        /// <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();
        }
Beispiel #5
0
 private void End()
 {
     eventsCentre.Publish(new LevelNextEvent());
 }
Beispiel #6
0
 public void Restart()
 {
     eventsCentre.Publish(new GameRestartEvent());
 }
Beispiel #7
0
 public void StartGame()
 {
     eventsCentre.Publish(new GameStartEvent());
 }