public void BeforeEach()
            {
                _database = Substitute.For <IDatabaseInstance>();
#pragma warning disable 618
                _ctrl = new DialogueController(_database);
#pragma warning restore 618
                _playback = Substitute.For <IDialoguePlayback>();
            }
Пример #2
0
        protected override void OnPlay(IDialoguePlayback playback)
        {
            _emittedChoices = GetValidChoices(playback);
            if (_emittedChoices.Count > 0)
            {
                playback.Events.Choice.Invoke(_actor, _dialogue, _emittedChoices);
                return;
            }

            playback.Events.Speak.Invoke(_actor, _dialogue);
        }
Пример #3
0
        private List <IChoice> GetValidChoices(IDialoguePlayback playback)
        {
            var child = Next();

            if (_choices.Count == 0 && child?.HubChoices != null && child.HubChoices.Count > 0)
            {
                playback.Events.NodeEnter.Invoke(child);
                return(child.HubChoices);
            }

            return(_choices.Where(c => c.IsValid).ToList());
        }
        public void Play(IDialoguePlayback playback, IGameObjectOverride[] gameObjectOverrides = null)
        {
            SetupDatabases(gameObjectOverrides);

            Stop();

            playback.Events.Speak.AddListener(TriggerSpeak);
            playback.Events.Choice.AddListener(TriggerChoice);
            playback.Events.NodeEnter.AddListener(TriggerEnterNode);
            playback.Events.Begin.AddListener(TriggerBegin);
            playback.Events.End.AddListener(TriggerEnd);

            _activeDialogue.Push(playback);
            playback.Play();
        }
        public void PlayChild(IDialoguePlayback playback)
        {
            if (ActiveDialogue == null)
            {
                throw new InvalidOperationException("Cannot trigger child dialogue, nothing is playing");
            }

            var parentDialogue = ActiveDialogue;

            playback.Events.End.AddListener(() => {
                _activeDialogue.Pop();
                parentDialogue.Next();
            });
            playback.Events.Speak.AddListener(TriggerSpeak);
            playback.Events.Choice.AddListener(TriggerChoice);
            playback.Events.NodeEnter.AddListener(TriggerEnterNode);

            _activeDialogue.Push(playback);
            playback.Play();
        }
Пример #6
0
 protected virtual void OnPlay(IDialoguePlayback playback)
 {
     playback.Next();
 }
Пример #7
0
 public void Play(IDialoguePlayback playback)
 {
     playback.Events.NodeEnter.Invoke(this);
     OnPlay(playback);
 }
Пример #8
0
 public void Play(IDialoguePlayback playback)
 {
     throw new System.NotImplementedException();
 }
Пример #9
0
 protected override void OnPlay(IDialoguePlayback playback)
 {
     playback.ParentCtrl.PlayChild(_graph);
 }
 public void BeforeEachMethod()
 {
     _parentPlayback = Substitute.For <IDialoguePlayback>();
     _ctrl.Play(_parentPlayback);
 }