Example #1
0
 public void init(Object launcher, Dialog.Fragment frg)
 {
     this.picture  = frg.Face;
     this.name     = frg.Name;
     this.msg      = frg.Msg;
     this.launcher = launcher;
     this.mode     = 0;
 }
Example #2
0
    private void DrawFragment(Rect rect, int index, bool active, bool focused)
    {
        Dialog.Fragment frg = (Dialog.Fragment)fragmentsReorderableList.list[index];

        EditorGUI.LabelField(moveRect(entityRect, rect), "Target: ");
        frg.IsEntityFragment = true;
        frg.Entity           = (Entity)EditorGUI.ObjectField(moveRect(objectRect, rect), frg.Entity, typeof(Entity), true);
        frg.IsEntityFragment = frg.Entity != null;
        frg.Face             = EditorGUI.ObjectField(moveRect(faceRect, rect), frg.Face, typeof(Texture2D), true) as Texture2D;
        frg.Name             = EditorGUI.TextField(moveRect(nameRect, rect), frg.Name);
        frg.Msg = EditorGUI.TextArea(moveRect(textRect, rect), frg.Msg);

        // If you are using a custom PropertyDrawer, this is probably better
        // EditorGUI.PropertyField(rect, serializedObject.FindProperty("list").GetArrayElementAtIndex(index));
        // Although it is probably smart to cach the list as a private variable ;)
    }
Example #3
0
    public override void Tick()
    {
        if (IcaroSocket.Instance.isConnected())
        {
            List <string> messages = IcaroSocket.Instance.getMessages();
            if (messages.Count == 0)
            {
                return;
            }

            Secuence secuence = null;
            Dialog   dialog   = null;

            foreach (string s in messages)
            {
                GameEvent ge = GameEvent.CreateInstance <GameEvent>();
                ge.fromJSONObject(JSONObject.Create(s));

                // TODO Maybe this showmessage thing will be in another event manager
                if (ge.name == "show message")
                {
                    if (secuence == null && dialog == null)
                    {
                        secuence = ScriptableObject.CreateInstance <Secuence>();
                        secuence.init();
                        dialog = ScriptableObject.CreateInstance <Dialog>();
                        secuence.Root.Content = dialog;
                    }

                    dialog.addFragment();
                    Dialog.Fragment[] fragments = dialog.getFragments();
                    Dialog.Fragment   fragment  = fragments[fragments.Length - 1];
                    fragment.Name = "ChatterBotten";
                    fragment.Msg  = (string)ge.getParameter("message");
                }
                else if (ge.name == GameEvent.RECEIVE_TEXT_EVENT)
                {
                    if (ge.containsParameter("message"))
                    {
                        var msg  = (string)ge.getParameter("message");
                        var menu = GameObject.FindObjectOfType <MenuBehaviour>();
                        if (menu)
                        {
                            menu.AddLineToReceivedText(msg);
                        }
                    }
                }
                else
                {
                    Game.main.enqueueEvent(ge);
                    eventsSendedToGame.Add(ge.GetInstanceID(), ge);
                }
            }

            if (secuence != null)
            {
                GameEvent secuenceGE = new GameEvent();
                secuenceGE.Name = "start secuence";
                secuenceGE.setParameter("Secuence", secuence);
                secuenceGE.setParameter("syncronized", true);
                Game.main.enqueueEvent(secuenceGE);
                secuencesStarted.Add(secuenceGE.GetInstanceID(), secuenceGE);
            }
        }
    }