Ejemplo n.º 1
0
        public void ChoiceSelected(string id)
        {
            DialogueSystemCallbackDelegate callbackDelegate   = null;
            ConversationChoice             conversationChoice = null;

            if (this.choices.ContainsKey(id))
            {
                conversationChoice = this.choices[id];

                if (!String.IsNullOrEmpty(conversationChoice.NavigateTo))
                {
                    // All selected is overriden by NavigateTo
                    this.ParentConversation.ExecuteNode(conversationChoice.NavigateTo);
                }
                else
                {
                    if (!String.IsNullOrEmpty(conversationChoice.OnSelectedID))
                    {
                        callbackDelegate = this.ParentConversation.ParentConversationManager.GetMethodDelegate(conversationChoice.OnSelectedID) as DialogueSystemCallbackDelegate;
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(this.ParentConversation.DefaultOnSelectedID))
                        {
                            callbackDelegate = this.ParentConversation.ParentConversationManager.GetMethodDelegate(this.ParentConversation.DefaultOnSelectedID) as DialogueSystemCallbackDelegate;
                        }
                    }
                }
            }

            callbackDelegate?.Invoke(this.ParentConversation.ParentConversationManager, id);
        }
Ejemplo n.º 2
0
        public void StartConversation(string id)
        {
            DialogueSystemCallbackDelegate callbackDelegate = null;

            if (String.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException("Conversation ID cannot be null");
            }

            // Here we start.
            if (this.conversationsDictionary.ContainsKey(id) == false)
            {
                throw new ArgumentException("No conversation with ID " + id + " found in the manager.");
            }

            this.RunningConversation = this.conversationsDictionary[id];

            this.OnConversationStarted();

            if (!String.IsNullOrEmpty(this.RunningConversation.OnStartConversationID))
            {
                callbackDelegate = this.GetMethodDelegate(this.RunningConversation.OnStartConversationID) as DialogueSystemCallbackDelegate;
                callbackDelegate?.Invoke(this, null);
            }
            else
            {
                if (!String.IsNullOrEmpty(this.RunningConversation.DefaultRootNodeID))
                {
                    this.ExecuteNode(this.RunningConversation.DefaultRootNodeID);
                }
            }
        }
Ejemplo n.º 3
0
        protected virtual void DefaultOnChoiceSelected(ConversationsManager manager, object state)
        {
            DialogueSystemCallbackDelegate callbackDelegate = null;
            bool   handled  = false;
            string choiceID = state as String;

            if (manager.RunningConversation != null && !String.IsNullOrEmpty(manager.runningConversation.DefaultOnSelectedID))
            {
                callbackDelegate = this.GetMethodDelegate(manager.RunningConversation.DefaultOnSelectedID) as DialogueSystemCallbackDelegate;
                if (callbackDelegate != null)
                {
                    handled = true;
                    callbackDelegate.Invoke(manager, state);
                }
            }

            if (!handled && manager.RunningConversation != null && manager.RunningConversation.CurrentNode != null)
            {
#warning Add the choice code.
            }
        }
Ejemplo n.º 4
0
        internal void ExecuteNode(ConversationNode node)
        {
            DialogueSystemCallbackDelegate currentDelegate = null;

            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            if (this.CurrentNode != null)
            {
                if (!String.IsNullOrEmpty(this.CurrentNode.DidExitNodeID))
                {
                    currentDelegate = this.ParentConversationManager.GetMethodDelegate(this.CurrentNode.DidExitNodeID) as DialogueSystemCallbackDelegate;
                    currentDelegate?.Invoke(this.ParentConversationManager, this.CurrentNode.ID);
                    currentDelegate = null;
                }

                this.PreviousNode = this.CurrentNode;
            }

            this.CurrentNode = node;

            if (!String.IsNullOrEmpty(this.CurrentNode.DidEnterNodeID))
            {
                currentDelegate = this.ParentConversationManager.GetMethodDelegate(this.CurrentNode.DidEnterNodeID) as DialogueSystemCallbackDelegate;
            }
            else
            {
                if (!String.IsNullOrEmpty(this.DefaultDidEnterNodeID))
                {
                    currentDelegate = this.ParentConversationManager.GetMethodDelegate(this.DefaultDidEnterNodeID) as DialogueSystemCallbackDelegate;
                }
            }

            if (currentDelegate != null)
            {
                currentDelegate.Invoke(this.ParentConversationManager, node.ID);
            }
        }
Ejemplo n.º 5
0
 public void RegisterDelegate(string id, DialogueSystemCallbackDelegate callback)
 {
     this.RegisterDelegateInternal(id, callback);
 }