Get First Child of a DialogueFragment

Tue 21. Mar 2017, 13:53

Hi,

I want to simulate the articyflowplayer to find on wich conditions my flows are stuck and keep this conditions somewhere to test them when I update some variable later. (I simulate phone conversation, each of my Dialogue are one conversation. When a inputCondition of a Dialogue Fragment become true it's mean I have a new message and I have to send a notification)

But I don't find how get the firsts childs

for exemple here, I would like to get the empty Dialogue Fragment and the Zelou : test Dialogue Fragment

Image


Thank you :)
User avatar
Zeldarck
 
Posts: 55
Joined: Thu 9. Mar 2017, 16:03

Re: Get First Child of a DialogueFragment

Tue 21. Mar 2017, 14:23

First i would strongly advise you to use the FlowPlayer for that, because thats exactly its purpose, having something traverse the flow for you. Its not just for dialogues and displaying them, you can configure a lot to just a very versatile flow traversal component. Also remember that the FlowPlayer returns all branches, not just the ones where the Conditions are valid.

But to answer your question:

Code: Select all
FlowFragment startNode;

var secondDlgFragment = startNode.InputPins[0].Connections[0].Target as DialogueFragment;
IInputPin targetPin = secondDlgFragment.FirstOrDefault(aPins => aPins.Id == connection.TargetPin);


To understand this, it is easiest to consider the dotted outline in your screenshot to be the parent node of those dialogue fragments. The pin on the left (sometimes we call them Gateway pins) is effectively the parent nodes input pin. So we take this input pin, take one of its outgoing connections, InputPins outgoing connections are in fact connections inside the node itself (i took the first, but these are unordered!! You can order them by sorting by Targets Y position for example). The connection stores a reference to the Target, and from the target and the connections TargetPin we can retrieve the actual pin that this connection is attached to.
This is of course very limited, as a pin can have multiple connections and you have to deal with jumps and hubs etc.

I think you are making it harder than it needs to be, maybe you explain what you want to achieve and i can give you a way to solve that.

Best regards

Nico
Nico Probst
Senior Software Engineer | Articy | LinkedIn
User avatar
[Articy] Nico Probst
Articy Staff
Articy Staff
 
Posts: 217
Joined: Wed 23. Nov 2011, 09:45
Location: Bochum

Re: Get First Child of a DialogueFragment

Tue 21. Mar 2017, 15:05

Oh Ok, I understand better, so with an input pin, I cannot get the connections to it ?

Like if in my screen I am on the input pin of "Salut mon gars", it give me the two connection link with him.




I have to simulate a phone. So I got some Dialogue with a template "FilMessage", that mean they have inside a discussion with a contact. So Inside the Dialogue I have DialogueFragment with a Template "Message" wish got the Date of the message and If I have read it or not.
When I close the game I save for all message the hour and the stats of the boolean isRead.

Some Discussion will be block until I have click somewhere on the menu of my phone for exemple. So There is an condition on the input pin :

Image

When I click on my menu, I have to be notified I have received a Message (because the Discussion can now advance). And with that update some other things like FilMessage Template value of the parents.


So for that I would like to at the launch of my application, get all my FilMessage, go in until I find an unread message. If this (or those) messages have an input condition, I stock this condition in a List with the concerned Message. Every time an articy Variable is update I will check thoses conditions to saw if I can continue in my Discussion and so send notification etc

I don't know if I am very clear.

But now you said it, yeah I can use the articyflowplayer and add a boolean to say him I am in the check work and didn't do the habit jobs :)
User avatar
Zeldarck
 
Posts: 55
Joined: Thu 9. Mar 2017, 16:03

Re: Get First Child of a DialogueFragment

Tue 21. Mar 2017, 15:52

How about you create a template for your Dialogues lets call it "ImportantCall" that has a script property. This script property is called "IsCallAvailable" now you gather all those ImportantCall Dialogues and check those scripts. Of course you could also just use a single boolean if thats enough.

Code: Select all
ImportantCall GetNextFreeCall()
{
   var allCalls = ArticyDatabase.GetAllOfType<ImportantCall>();
   foreach(var call in allCalls)
   {
      if(call.IsCallAvailable.Evaluate() && !call.IsAnswered)
      {
         call.IsAnswered = true;
         return call;
      }
   }
   return null;
}


var nextCall = GetNextFreeCall();

if(nextCall != null)
{
   flowPlayer.StartNode = nextCall;
}


I also added an IsAnswered boolean flag, but this can easily be handled via the IsCallAvailable property. You could also just collect all of them once, store them in a list and remove them once handled.

Does that help?

Best regards

Nico
Nico Probst
Senior Software Engineer | Articy | LinkedIn
User avatar
[Articy] Nico Probst
Articy Staff
Articy Staff
 
Posts: 217
Joined: Wed 23. Nov 2011, 09:45
Location: Bochum

Re: Get First Child of a DialogueFragment

Tue 21. Mar 2017, 16:29

Thank you, hum, I will use that for the call effectivly, it's a good idea :)

But for my new message it's not ok.

Image

The green are Me, Zelou it's a friends.

I speak to him, I choose the ANSWER 1 (set isRead of it to true) , then the program display ZELOU 1 (set isRead of it to true). But not ZELOU 2 because the condition is false.

at an other place, I set Message.Test to true.
Whit your solution, I will Have ZELOU 4 and ZELOU 2 which say it's ok. But I only want ZELOU 2, because it's here I have read.
With the boolean it will be ok I think, I will try that tomorrow :)

Thank you :)
User avatar
Zeldarck
 
Posts: 55
Joined: Thu 9. Mar 2017, 16:03

Re: Get First Child of a DialogueFragment

Wed 22. Mar 2017, 14:09

I do it with success with a boolean, I was stuck when I do that is Start Method so I put it in a coroutine call on start method and it's ok now.

Code: Select all
       

List<FilMessage> list = ArticyDatabase.GetAllOfType<FilMessage>();

        m_notDisplay = true;

        foreach (FilMessage fil in list)
        {
            if (waiter)
            {
                Debug.Log("start : " + fil.DisplayName);
                waiter = false; //to know if the last filMessage it's finish
                flowPlayer.StartOn = fil;
            }
        }

        m_notDisplay = false; //say to the system we don't display the flow
User avatar
Zeldarck
 
Posts: 55
Joined: Thu 9. Mar 2017, 16:03

Return to articy:draft Unity Importer

Who is online

Users browsing this forum: No registered users and 17 guests

Who We Are
Contact Us
Social Links