Наследование: UnityEngine.ScriptableObject
Пример #1
0
    public override void ReceiveEvent(GameEvent ev)
    {
        if (ev.name == "event finished" && secuencesStarted.ContainsKey(((GameEvent)ev.getParameter("event")).GetInstanceID()))
        {
            GameEvent ge = ev.getParameter("event") as GameEvent;
            secuencesStarted.Remove(ge.GetInstanceID());
            Secuence se = ge.getParameter("secuence") as Secuence;
            Secuence.DestroyImmediate(se);
        }
        else if (eventsSendedToGame.ContainsKey(ev.GetInstanceID()))
        {
            eventsSendedToGame.Remove(ev.GetInstanceID());
        }
        else if (IcaroSocket.Instance.isConnected())
        {
            if (ev.name == "IniciarPartida")
            {
                MinionScript[] minions    = GameObject.FindObjectsOfType <MinionScript>();
                List <object>  minionList = new List <object>();
                foreach (var ms in minions)
                {
                    minionList.Add(ms);
                }

                ev.setParameter("minions", minionList);
            }
            ev.setParameter("fromClient", true);

            IcaroSocket.Instance.sendMessage(ev.toJSONObject().ToString());
        }
    }
Пример #2
0
    /**
     *  Rectangle backup code calculation
     **

        if(!rects.ContainsKey(node.Childs[i]))
            rects.Add(node.Childs[i], new Rect(rects[node].x + 315, rects[node].y + i*altura, 150, 0));
        curveFromTo(rects[node], rects[node.Childs[i]], new Color(0.3f,0.7f,0.4f), s);

     */
    void createWindows(Secuence secuence)
    {
        float altura = 100;
        foreach(var node in secuence.Nodes){
            nodes.Add(node.GetInstanceID(), node);
            node.Position = GUILayout.Window(node.GetInstanceID(), node.Position, nodeWindow, node.Name);
        }
    }
Пример #3
0
 void OnEnable()
 {
     if (secuence == null) {
         Debug.Log ("Secuence created");
         secuence = ScriptableObject.CreateInstance<Secuence> ();
         secuence.init ();
         DontDestroyOnLoad(secuence);
     }
 }
Пример #4
0
    /**
     *  Rectangle backup code calculation
     **
     **
     ** if(!rects.ContainsKey(node.Childs[i]))
     **                 rects.Add(node.Childs[i], new Rect(rects[node].x + 315, rects[node].y + i*altura, 150, 0));
     **         curveFromTo(rects[node], rects[node.Childs[i]], new Color(0.3f,0.7f,0.4f), s);
     **
     */

    void createWindows(Secuence secuence)
    {
        float altura = 100;

        foreach (var node in secuence.Nodes)
        {
            nodes.Add(node.GetInstanceID(), node);
            node.Position = GUILayout.Window(node.GetInstanceID(), node.Position, nodeWindow, node.Name);
        }
    }
Пример #5
0
 public override void ReceiveEvent(IGameEvent ev)
 {
     if (secuenceInterpreter == null)
     {
         if (ev.Name.ToLower() == "start secuence")
         {
             Secuence secuence = (ev.getParameter("Secuence") as Secuence);
             secuenceInterpreter = new SecuenceInterpreter(secuence);
             de = ControllerManager.onControllerEvent;
             ControllerManager.onControllerEvent  = null;
             ControllerManager.onControllerEvent += this.onControllerEvent;
         }
     }
     else
     {
         secuenceInterpreter.EventHappened(ev);
     }
 }
Пример #6
0
    void drawLines(Secuence secuence)
    {
        loopCheck.Clear();
        drawLines(new Rect(0, 0, 0, position.height), secuence.Root);

        // Draw the rest of the lines in red
        foreach (var n in secuence.Nodes)
        {
            if (!loopCheck.ContainsKey(n))
            {
                float h = n.Position.height / (n.Childs.Length * 1.0f);
                for (int i = 0; i < n.Childs.Length; i++)
                {
                    if (n.Childs[i] != null)
                    {
                        Rect fromRect = sumRect(n.Position, new Rect(0, h * i, 0, h - n.Position.height));
                        curveFromTo(fromRect, n.Childs[i].Position, r, s);
                    }
                }
            }
        }
    }
Пример #7
0
 public SecuenceInterpreter(Secuence secuence)
 {
     currentNode = secuence.Root;
 }
Пример #8
0
 public void init(Secuence s)
 {
     childs        = new SecuenceNode[0];
     this.secuence = s;
     DontDestroyOnLoad(this);
 }
Пример #9
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);
            }
        }
    }
Пример #10
0
 public SecuenceInterpreter(Secuence secuence)
 {
     currentNode = secuence.Root;
 }
Пример #11
0
 public void ExecuteSecuence(Secuence secuence)
 {
     Debug.Log("Executing");
     instance.isOnSecuence = true;
     StartCoroutine(secuence.DoSecuence());
 }
Пример #12
0
    void drawLines(Secuence secuence)
    {
        loopCheck.Clear();
        drawLines(new Rect(0, 0, 0, position.height), secuence.Root);

        // Draw the rest of the lines in red
        foreach (var n in secuence.Nodes)
        {
            if (!loopCheck.ContainsKey(n))
            {
                float h = n.Position.height / (n.Childs.Length * 1.0f);
                for (int i = 0; i < n.Childs.Length; i++)
                    if(n.Childs[i]!=null)
                    {
                        Rect fromRect = sumRect(n.Position, new Rect(0, h * i, 0, h - n.Position.height));
                        curveFromTo(fromRect, n.Childs[i].Position, r, s);
                    }
            }
        }
    }