Beispiel #1
0
        public QuestService(Manifest manifest, PersistentBreadcrumbTypeDefinitionKey breadcrumbType)
        {
            this.breadcrumbType = breadcrumbType;
            dispatcher          = Service.Get <EventDispatcher>();
            MascotService          mascotService = Service.Get <MascotService>();
            List <QuestDefinition> list          = new List <QuestDefinition>();

            ScriptableObject[] assets = manifest.Assets;
            foreach (ScriptableObject scriptableObject in assets)
            {
                string             fileNameWithoutExtension = Path.GetFileNameWithoutExtension(scriptableObject.name);
                Mascot             mascot  = mascotService.GetMascot(fileNameWithoutExtension);
                ScriptableObject[] assets2 = ((Manifest)scriptableObject).Assets;
                foreach (ScriptableObject scriptableObject2 in assets2)
                {
                    QuestDefinition questDefinition = (QuestDefinition)scriptableObject2;
                    knownQuests[scriptableObject2.name]      = questDefinition;
                    questToMascotMap[scriptableObject2.name] = mascot;
                    list.Add(questDefinition);
                }
                mascot.KnownQuests = list.ToArray();
                list.Clear();
            }
            eventChannel = new EventChannel(dispatcher);
            eventChannel.AddListener <QuestEvents.SuspendQuest>(onSuspendQuestRequest);
            eventChannel.AddListener <QuestEvents.ResumeQuest>(onResumeQuestRequest);
            eventChannel.AddListener <QuestEvents.StartQuest>(onStartQuestRequest);
            eventChannel.AddListener <QuestEvents.ReplayQuest>(onReplayQuestRequest);
            eventChannel.AddListener <QuestEvents.RestartQuest>(onRestartQuestRequest);
            eventChannel.AddListener <SplashScreenEvents.SplashScreenOpened>(onSplashScreenOpened);
            eventChannel.AddListener <SplashScreenEvents.SplashScreenClosed>(onSplashScreenClosed);
            eventChannel.AddListener <QuestEvents.QuestUpdated>(onQuestUpdated);
            eventChannel.AddListener <QuestEvents.QuestInitializationComplete>(onQuestInitializationComplete);
            eventChannel.AddListener <RewardEvents.RewardPopupComplete>(onRewardPopupComplete);
            eventChannel.AddListener <QuestEvents.SetPlayerOutOfWorld>(onSetPlayerOutOfWorld);
            eventChannel.AddListener <SceneTransitionEvents.TransitionStart>(onSceneTransition);
            eventChannel.AddListener <QuestEvents.RegisterQuestSubFsm>(onRegisterQuestSubFsm);
            eventChannel.AddListener <InWorldUIEvents.DisableActionIndicators>(onDisableActionIndicators);
            eventChannel.AddListener <InWorldUIEvents.EnableActionIndicators>(onEnableActionIndicators);
            eventChannel.AddListener <QuestServiceEvents.QuestStatesRecieved>(onQuestStatesReceived);
            eventChannel.AddListener <QuestServiceErrors.QuestProgressionError>(onQuestProgressionError);
            eventChannel.AddListener <ProgressionEvents.LevelUp>(onLevelUp);
            updateQuestGivers(0);
            timeLockedCheckTimer = new Timer(2f, repeat: true, delegate
            {
                onTimerTick();
            });
            CoroutineRunner.StartPersistent(timeLockedCheckTimer.Start(), this, "timeLockedQuestTimer");
        }
 public void OnEnable()
 {
     if (Mascot == null)
     {
         Mascot = mascotService.GetMascot(MascotName);
         if (Mascot == null)
         {
             UnityEngine.Object.Destroy(this);
             return;
         }
     }
     dispatcher.AddListener <CinematicSpeechEvents.SpeechCompleteEvent>(onSpeechComplete);
     dispatcher.AddListener <CinematicSpeechEvents.PlayMascotAnimation>(onPlayMascotAnimation);
     dispatcher.AddListener <CinematicSpeechEvents.SetMascotIdleDialogOverride>(onSetMascotIdleDialogOverride);
     dispatcher.AddListener <ButtonEvents.ClickEvent>(onButtonClicked);
     dispatcher.AddListener <QuestEvents.StartQuest>(onStartQuest);
     dispatcher.AddListener <QuestEvents.ReplayQuest>(onReplayQuest);
     dispatcher.AddListener <QuestEvents.ResumeQuest>(onResumeQuest);
     dispatcher.AddListener <SplashScreenEvents.SplashScreenOpened>(onSplashScreenOpened);
     dispatcher.AddListener <QuestEvents.QuestUpdated>(onQuestUpdated);
     Service.Get <MascotService>().RegisterMascotObject(Mascot.Name, base.gameObject);
 }