init() public method

public init ( ) : void
return void
Exemplo n.º 1
0
 void OnEnable()
 {
     if (secuence == null) {
         Debug.Log ("Secuence created");
         secuence = ScriptableObject.CreateInstance<Secuence> ();
         secuence.init ();
         DontDestroyOnLoad(secuence);
     }
 }
Exemplo n.º 2
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);
            }
        }
    }