protected override Status OnExecute(Component agent, IBlackboard bb)
        {
            if (outConnections.Count == 0)
            {
                return(Error("There are no connections to the Multiple Choice Node!"));
            }

            var finalOptions = new Dictionary <IStatement, int>();

            for (var i = 0; i < availableChoices.Count; i++)
            {
                var condition = availableChoices[i].condition;
                if (condition == null || condition.CheckCondition(finalActor.transform, bb))
                {
                    var tempStatement = availableChoices[i].statement.BlackboardReplace(bb);
                    finalOptions[tempStatement] = i;
                }
            }

            if (finalOptions.Count == 0)
            {
                Debug.Log("Multiple Choice Node has no available options. Dialogue Ends");
                DLGTree.Stop(false);
                return(Status.Failure);
            }

            var optionsInfo = new MultipleChoiceRequestInfo(finalActor, finalOptions, availableTime, OnOptionSelected);

            optionsInfo.showLastStatement = inConnections.Count > 0 && inConnections[0].sourceNode is StatementNode;
            DialogueTree.RequestMultipleChoices(optionsInfo);
            return(Status.Running);
        }
Example #2
0
        protected override Status OnExecute(Component agent, IBlackboard bb)
        {
            var tempStatement = statement.BlackboardReplace(bb);

            DialogueTree.RequestSubtitles(new SubtitlesRequestInfo(finalActor, tempStatement, OnStatementFinish));
            return(Status.Running);
        }
Example #3
0
        protected override void OnGraphStoped()
        {
            currentNode     = null;
            currentDialogue = null;

            Debug.Log(string.Format("<b>DialogueTree:</b> Dialogue Finished '{0}'", this.name));
            if (OnDialogueFinished != null)
            {
                OnDialogueFinished(this);
            }
        }
Example #4
0
        protected override void OnGraphStoped()
        {
            endState        = currentNode != null? (EndState)currentNode.status : EndState.Success;
            currentNode     = null;
            currentDialogue = null;

            Debug.Log(string.Format("<b>DialogueTree:</b> Dialogue Finished '{0}'", this.name));
            if (OnDialogueFinished != null)
            {
                OnDialogueFinished(this);
            }
        }
        void OnOptionSelected(int index)
        {
            status = Status.Success;

            System.Action Finalize = () => { DLGTree.Continue(index); };

            if (saySelection)
            {
                var tempStatement = availableChoices[index].statement.BlackboardReplace(graphBlackboard);
                var speechInfo    = new SubtitlesRequestInfo(finalActor, tempStatement, Finalize);
                DialogueTree.RequestSubtitles(speechInfo);
            }
            else
            {
                Finalize();
            }
        }
        void CheckInstance()
        {
            if (IsInstance(subTree))
            {
                return;
            }

            DialogueTree instance = null;

            if (!instances.TryGetValue(subTree, out instance))
            {
                instance           = Graph.Clone <DialogueTree>(subTree);
                instances[subTree] = instance;
            }

            subTree = instance;
        }
Example #7
0
        void CheckInstance()
        {
            if (IsInstance(subTree))
            {
                return;
            }

            DialogueTree instance = null;

            if (!instances.TryGetValue(subTree, out instance))
            {
                instance           = Graph.Clone <DialogueTree>(subTree);
                instances[subTree] = instance;
            }

            instance.agent      = graphAgent;
            instance.blackboard = graphBlackboard;
            subTree             = instance;
        }
Example #8
0
        ////

        protected override void OnGraphStarted()
        {
            if (currentDialogue != null)
            {
                Debug.LogWarning(string.Format("<b>DialogueTree:</b> Another Dialogue Tree named '{0}' is already running and will be stoped before starting new one '{1}'", currentDialogue.name, this.name));
                currentDialogue.Stop(true);
            }

            currentDialogue = this;

            Debug.Log(string.Format("<b>DialogueTree:</b> Dialogue Started '{0}'", this.name));
            if (OnDialogueStarted != null)
            {
                OnDialogueStarted(this);
            }

            if (!(agent is IDialogueActor))
            {
                Debug.Log("<b>DialogueTree:</b> INSTIGATOR agent used in DialogueTree does not implement IDialogueActor. A dummy actor will be used.");
            }

            currentNode = currentNode != null? currentNode : (DTNode)primeNode;
            EnterNode(currentNode);
        }
Example #9
0
 bool IsInstance(DialogueTree dt)
 {
     return(instances.Values.Contains(dt));
 }
		protected override void OnGraphStoped(){

			endState = currentNode != null? (EndState)currentNode.status : EndState.Success;
			currentNode = null;
			currentDialogue = null;

			Debug.Log(string.Format("<b>DialogueTree:</b> Dialogue Finished '{0}'", this.name));
			if (OnDialogueFinished != null)
				OnDialogueFinished(this);
		}
		////

		protected override void OnGraphStarted(){

			if (currentDialogue != null){
				Debug.LogWarning(string.Format("<b>DialogueTree:</b> Another Dialogue Tree named '{0}' is already running and will be stoped before starting new one '{1}'", currentDialogue.name, this.name ));
				currentDialogue.Stop();
			}

			currentDialogue = this;

			Debug.Log(string.Format("<b>DialogueTree:</b> Dialogue Started '{0}'", this.name));
			if (OnDialogueStarted != null)
				OnDialogueStarted(this);

			if ( !(agent is IDialogueActor) ){
				Debug.Log("<b>DialogueTree:</b> INSTIGATOR agent used in DialogueTree does not implement IDialogueActor. A dummy actor will be used.");
			}

			currentNode = currentNode != null? currentNode : (DTNode)primeNode;
			EnterNode( currentNode );
		}
Example #12
0
 void OnDialogueStarted(DialogueTree dlg)
 {
     //nothing special...
 }
Example #13
0
 void OnDialoguePaused(DialogueTree dlg)
 {
     subtitlesGroup.gameObject.SetActive(false);
     optionsGroup.gameObject.SetActive(false);
 }