Exemple #1
0
        public override void ReceiveEvent(IGameEvent ge)
        {
            var p = ge.getParameter("Inventory");

            if (p == this || (p is string && ((string)p) == gameObject.name))
            {
                Item item = (Item)ge.getParameter("Item");
                switch (ge.Name.ToLower())
                {
                case "open inventory":
                    openInventory = true;
                    events.Add(ge);
                    break;

                case "add item":
                    itemsToAdd.Add(item);
                    events.Add(ge);
                    break;

                case "remove item":
                    itemsToRemove.Add(item);
                    events.Add(ge);
                    break;

                case "use item":
                    itemsToUse.Add(item);
                    events.Add(ge);
                    break;
                }
            }
        }
Exemple #2
0
    public override void eventHappened(IGameEvent ge)
    {
        if (ge.getParameter("Inventory") == this || ge.getParameter("Inventory") == this.Entity.gameObject)
        {
            Item item = (Item)ge.getParameter("Item");
            switch (ge.Name.ToLower())
            {
            case "open inventory":
                openInventory = true;
                events.Add(ge);
                break;

            case "add item":
                itemsToAdd.Add(item);
                events.Add(ge);
                break;

            case "remove item":
                itemsToRemove.Add(item);
                events.Add(ge);
                break;

            case "use item":
                itemsToUse.Add(item);
                events.Add(ge);
                break;
            }
        }
    }
Exemple #3
0
    public override void ReceiveEvent(IGameEvent ev)
    {
        if (ev.Name.Replace("\"", "") == "mobile message")
        {
            object otherObj = ev.getParameter(SequenceGenerator.EVENT_OTHER_FIELD);
            string other    = otherObj != null?otherObj.ToString().Replace("\"", "") : "";

            if (other == "save")
            {
                mobile.SaveMobileState();
                return;
            }

            if (other == "load")
            {
                mobile.LoadMobileState();
                return;
            }

            string chatName = ev.getParameter(SequenceGenerator.EVENT_VARIABLE_FIELD).ToString().Replace("\"", "");
            string message  = ev.getParameter(SequenceGenerator.EVENT_VALUE_FIELD).ToString().Replace("\"", "");
            string from     = ev.getParameter(SequenceGenerator.EVENT_KEY_FIELD).ToString().Replace("\"", "");

            float time = (float)ev.getParameter(SequenceGenerator.EVENT_TIME_FIELD);


            StartCoroutine(ExecuteAfterTime(time, message, from, chatName, other));
        }
    }
    public override void ReceiveEvent(IGameEvent ev)
    {
        if (ev.Name.Replace("\"", "") == "computer publication")
        {
            object otherObj = ev.getParameter(SequenceGenerator.EVENT_OTHER_FIELD);
            string other    = otherObj != null?otherObj.ToString().Replace("\"", "") : "";

            if (other == "save")
            {
                computer.SaveComputerState();
                return;
            }
            if (other == "load")
            {
                computer.LoadComputerState();
                return;
            }

            string publicationKey = ev.getParameter(SequenceGenerator.EVENT_VARIABLE_FIELD).ToString().Replace("\"", "");
            string message        = ev.getParameter(SequenceGenerator.EVENT_VALUE_FIELD).ToString().Replace("\"", "");
            string author         = ev.getParameter(SequenceGenerator.EVENT_KEY_FIELD).ToString().Replace("\"", "");

            float time = (float)ev.getParameter(SequenceGenerator.EVENT_TIME_FIELD);
            StartCoroutine(ExecuteAfterTime(time, author, message, publicationKey, other));
        }
    }
Exemple #5
0
    public static bool CompareEvents(IGameEvent ge1, IGameEvent ge2)
    {
        // http://msdn.microsoft.com/en-us/library/ms173147(v=vs.80).aspx
        // If both are null, or both are same instance, return true.
        if (System.Object.ReferenceEquals(ge1, ge2))
        {
            return(true);
        }

        // If one is null, but not both, return false.
        if ((ge1 == null) || (ge2 == null))
        {
            return(false);
        }


        bool result = ge1.Name.ToLower().Equals(ge2.Name.ToLower()) && ge1.Params.Length == ge2.Params.Length;

        if (result)
        {
            foreach (string arg in ge1.Params)               // From a to b
            {
                var p1 = ge1.getParameter(arg);
                var p2 = ge2.getParameter(arg);

                result = (p1 == null && p2 == null) || p1.Equals(p2);
                if (!result)
                {
                    Debug.Log("p1: " + p1 + " type( " + p1.GetType() + " ) == p2 : " + p2 + " type( " + p2.GetType() + " ) => " + (result));
                }

                if (!result)
                {
                    break;
                }
            }

            foreach (string arg in ge2.Params)             // From b to a
            {
                var p1 = ge1.getParameter(arg);
                var p2 = ge2.getParameter(arg);

                result = (p1 == null && p2 == null) || p1.Equals(p2);
                if (!result)
                {
                    Debug.Log("p1: " + p1 + " type( " + p1.GetType() + " ) == p2 : " + p2 + " type( " + p2.GetType() + " ) => " + (result));
                }

                if (!result)
                {
                    break;
                }
            }
        }


        return(result);
    }
Exemple #6
0
    /// <summary>
    /// Receive the pick event
    /// </summary>
    /// <param name="ev"></param>
    public override void ReceiveEvent(IGameEvent ev)
    {
        if (ev.Name.Replace("\"", "") == "pick")
        {
            string var = ((String)ev.getParameter(SequenceGenerator.EVENT_VARIABLE_FIELD)).Replace("\"", "");

            var value = ev.getParameter(SequenceGenerator.EVENT_VALUE_FIELD);
            this.PickObject(var, value);
        }
    }
 public override void ReceiveEvent(IGameEvent ev)
 {
     base.ReceiveEvent(ev);
     // Old name support
     if (ev.Name == "ChangeSwitch")
     {
         object value   = ev.getParameter("value");
         string iswitch = (string)ev.getParameter("switch");
         this.ChangeSwitch(iswitch, value);
     }
 }
Exemple #8
0
 public GameEventConfig(IGameEvent gameEvent)
 {
     Name            = gameEvent.Name;
     ParameterConfig = new Dictionary <string, Type>();
     foreach (var p in gameEvent.Params)
     {
         if (p != "synchronous")
         {
             ParameterConfig.Add(p, gameEvent.getParameter(p) != null ? gameEvent.getParameter(p).GetType() : typeof(object));
         }
     }
 }
Exemple #9
0
 public override void eventHappened(IGameEvent ge)
 {
     if (ge.getParameter("Talker") == this)
     {
         switch (ge.Name.ToLower())
         {
         case "talk":
             start           = true;
             talkerDirection = ((Entity)ge.getParameter("Executer")).GetComponent <Mover>().direction;
             break;
         }
     }
 }
Exemple #10
0
    /// <summary>
    /// Receive the pick event
    /// </summary>
    /// <param name="ev"></param>
    public override void ReceiveEvent(IGameEvent ev)
    {
        if (ev.Name.Replace("\"", "") == "active object")
        {
            object timeObj = ev.getParameter(SequenceGenerator.EVENT_TIME_FIELD);
            float  time    = timeObj != null ? (float)timeObj : 0;

            object otherObj = ev.getParameter(SequenceGenerator.EVENT_OTHER_FIELD);
            string other    = otherObj != null?otherObj.ToString().Replace("\"", "") : "";

            StartCoroutine(ActiveObject(time, other));
        }
    }
Exemple #11
0
    /// <summary>
    /// Receive the change friendship event
    /// </summary>
    /// <param name="ev"></param>
    public override void ReceiveEvent(IGameEvent ev)
    {
        if (ev.Name.Replace("\"", "") == "change variable")
        {
            object vAux = ev.getParameter(SequenceGenerator.EVENT_VARIABLE_FIELD);
            string var  = null;
            if (vAux != null)
            {
                var = ((String)vAux).Replace("\"", "");
            }

            var value = ev.getParameter(SequenceGenerator.EVENT_VALUE_FIELD);
            this.ChangeVarValue(var, value);
        }
    }
    public override void ReceiveEvent(IGameEvent ev)
    {
        if (ev.Name.Replace("\"", "") == "computer friend")
        {
            string name         = ev.getParameter(SequenceGenerator.EVENT_VARIABLE_FIELD).ToString().Replace("\"", "");
            string state        = ev.getParameter(SequenceGenerator.EVENT_VALUE_FIELD).ToString().Replace("\"", "");
            object globalKeyObj = ev.getParameter(SequenceGenerator.EVENT_KEY_FIELD);
            string globalKey    = globalKeyObj != null?globalKeyObj.ToString().Replace("\"", "") : "";

            object otherObj = ev.getParameter(SequenceGenerator.EVENT_OTHER_FIELD);
            string other    = otherObj != null?otherObj.ToString().Replace("\"", "") : "";

            float time = (float)ev.getParameter(SequenceGenerator.EVENT_TIME_FIELD);
            StartCoroutine(ExecuteAfterTime(time, name, state, globalKey, other));
        }
    }
Exemple #13
0
        public override void ReceiveEvent(IGameEvent ev)
        {
            if (ev.Name == "show dialog fragment")
            {
                gameEvent = ev;
                DoFragment(ev.getParameter("fragment") as Fragment);
                doing = DOING_FRAGMENT;
            }

            if (ev.Name == "show dialog options")
            {
                gameEvent = ev;
                DoOptions(ev.getParameter("message") as string, ev.getParameter("options") as List <Option>);
                doing = DOING_OPTIONS;
            }
        }
    public void EventHappened(IGameEvent ge)
    {
        if (ge.getParameter("Launcher") == this)
        {
            switch (ge.Name.ToLower())
            {
            case "ended fragment":
                next = true;
                break;

            case "chosen option":
                chosen = (int)ge.getParameter("option");
                break;
            }
        }
    }
 public override void ReceiveEvent(IGameEvent ev)
 {
     if (ev.Name == "ChangeSwitch")
     {
         IsoSwitchesManager.getInstance().getIsoSwitches().getSwitch((string)ev.getParameter("switch")).State = ev.getParameter("value");
     }
 }
        public override void ReceiveEvent(IGameEvent ev)
        {
            base.ReceiveEvent(ev);
            if (ev.Name == "important")
            {
                string o1, o2, o3, o4;
                o1 = (string)ev.getParameter("o1");
                o2 = (string)ev.getParameter("o2");
                o3 = (string)ev.getParameter("o3");
                o4 = (string)ev.getParameter("o4");

                opts.GetComponent <Options>().setText(o1, o2, o3, o4);

                this.ev = ev;
                show();
            }
        }
        public void EventHappened(IGameEvent ge)
        {
            if (ge.Name == "event finished" && ge.getParameter("event") == eventLaunched)
            {
                switch (eventLaunched.Name.ToLower())
                {
                case "show dialog fragment":
                    next = true;
                    break;

                case "show dialog options":
                    var optionchosen = (int)ge.getParameter("option");
                    chosen = optionsList.FindIndex(o => o == launchedOptionsList[optionchosen]);
                    break;
                }
            }
        }
Exemple #18
0
 public void Tick()
 {
     ge = (node.Content as IGameEvent);
     if (!launched)
     {
         Game.main.enqueueEvent(ge);
         if (ge.getParameter("synchronous") != null && (bool)ge.getParameter("synchronous") == true)
         {
             waitTillEventFinished = true;
         }
         launched = true;
     }
     if (!waitTillEventFinished)
     {
         finished = true;
     }
 }
Exemple #19
0
 /// <summary>
 /// Receive the pick event
 /// </summary>
 /// <param name="ev"></param>
 public override void ReceiveEvent(IGameEvent ev)
 {
     if (ev.Name.Replace("\"", "") == "little move" && (keyEvent == null || keyEvent == "" ||
                                                        ((String)ev.getParameter(SequenceGenerator.EVENT_KEY_FIELD)).Replace("\"", "") == keyEvent))
     {
         this.ChangePosition();
     }
 }
Exemple #20
0
 /// <summary>
 /// Receive the pick event
 /// </summary>
 /// <param name="ev"></param>
 public override void ReceiveEvent(IGameEvent ev)
 {
     if (ev.Name.Replace("\"", "") == "fade out" && (keyEvent == null || keyEvent == "" ||
                                                     ((String)ev.getParameter(SequenceGenerator.EVENT_KEY_FIELD)).Replace("\"", "") == keyEvent))
     {
         this.FadeOutObject();
     }
 }
Exemple #21
0
 /// <summary>
 /// Receive the pick event
 /// </summary>
 /// <param name="ev"></param>
 public override void ReceiveEvent(IGameEvent ev)
 {
     if (ev.Name.Replace("\"", "") == "move camera" &&
         ev.getParameter(SequenceGenerator.EVENT_KEY_FIELD).ToString().Replace("\"", "") == keyEvent)
     {
         this.moveCamera();
     }
 }
Exemple #22
0
 public override void ReceiveEvent(IGameEvent ev)
 {
     if (ev.Name.Replace("\"", "") == "black")
     {
         String value = (String)ev.getParameter(SequenceGenerator.EVENT_VALUE_FIELD);
         gEvent = ev;
         ThrowBlackImage(value);
     }
 }
Exemple #23
0
 public override void ReceiveEvent(IGameEvent ev)
 {
     if (ev.Name.Replace("\"", "") == "class entrance")
     {
         String value = (String)ev.getParameter(SequenceGenerator.EVENT_VALUE_FIELD);
         gEvent = ev;
         AnimateCharacter();
     }
 }
Exemple #24
0
    /// <summary>
    /// Receive the pick event
    /// </summary>
    /// <param name="ev"></param>
    public override void ReceiveEvent(IGameEvent ev)
    {
        if (ev.Name.Replace("\"", "") == "change scene")
        {
            int    scene   = (int)ev.getParameter(SequenceGenerator.EVENT_VALUE_FIELD);
            object timeObj = ev.getParameter(SequenceGenerator.EVENT_TIME_FIELD);
            float  time    = timeObj != null ? (float)timeObj : 1f;

            if (time > 0 && eyelid)
            {
                eyelid.goToSleep(time - 0.2f);
            }
            StartCoroutine(ChangeScene(time, scene));
            if (loading != null)
            {
                loading.SetActive(true);
            }
        }
    }
Exemple #25
0
    /// <summary>
    /// Receive the pick event
    /// </summary>
    /// <param name="ev"></param>
    public override void ReceiveEvent(IGameEvent ev)
    {
        if (ev.Name.Replace("\"", "") == "deactive object")
        {
            object timeObj = ev.getParameter(SequenceGenerator.EVENT_TIME_FIELD);
            float  time    = timeObj != null ? (float)timeObj : 0;

            StartCoroutine(DeactiveObject(time));
        }
    }
    public override void ReceiveEvent(IGameEvent ev)
    {
        if (ev.Name == "ShowAnimation")
        {
            Decoration dec       = (ev.getParameter("Objetive") as GameObject).GetComponent <Decoration>();
            GameObject animation = (GameObject)ev.getParameter("Animation");

            GameObject go = (GameObject)GameObject.Instantiate(animation);

            Decoration animation2 = go.GetComponent <Decoration>();

            animation2.GetComponent <Renderer>().sharedMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse"));
            animation2.Father = dec;
            animation2.adaptate();

            AutoAnimator anim = go.GetComponent <AutoAnimator>();
            anim.registerEvent(ev);
        }
    }
    public void ReceiveEvent(IGameEvent ev)
    {
        if (ev.Name == "event finished" && ev.getParameter("event") == waiting)
        {
            finished = true;
            if (Game.main)
            {
                Game.main.DeRegisterEventManager(this);
            }

            if (outParams != null)
            {
                foreach (var param in ev.Params)
                {
                    outParams.Add(param, ev.getParameter(param));
                }
            }
        }
    }
Exemple #28
0
        public override void ReceiveEvent(IGameEvent ev)
        {
            if (ev.Name == "ShowAnimation")
            {
                Decoration dec       = (ev.getParameter("Objective") as GameObject).GetComponent <Decoration>();
                GameObject animation = (GameObject)ev.getParameter("Animation");

                GameObject go = (GameObject)GameObject.Instantiate(animation);

                Decoration animation2 = go.GetComponent <Decoration>();

                animation2.GetComponent <Renderer>().sharedMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse"));
                animation2.Father = dec;
                animation2.adaptate();

                AutoAnimator anim = go.GetComponent <AutoAnimator>();
                anim.registerEvent(ev);
            }

            if (ev.Name == "show decoration animation")
            {
                Decoration dec = (ev.getParameter("objective") as GameObject).GetComponent <Decoration>();

                GameObject go         = GameObject.CreatePrimitive(PrimitiveType.Quad);
                Decoration decoration = go.AddComponent <Decoration>();
                decoration.IsoDec = (IsoDecoration)ev.getParameter("animation");

                decoration.GetComponent <Renderer>().sharedMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse"));
                decoration.Father   = dec;
                decoration.Centered = true;
                decoration.adaptate();
                decoration.SendMessage("Update");

                AutoAnimator anim = go.AddComponent <AutoAnimator>();
                anim.FrameSecuence = new int[8] {
                    0, 1, 2, 3, 4, 5, 6, 7
                };
                anim.FrameRate   = 0.07f;
                anim.AutoDestroy = true;
                anim.Repeat      = 1;
                anim.registerEvent(ev);
            }
        }
 public void ReceiveEvent(IGameEvent ev)
 {
     if (ev.Name == "event finished" && ev.getParameter("event") == waiting)
     {
         finished = true;
         if (Game.main)
         {
             Game.main.DeRegisterEventManager(this);
         }
     }
 }
Exemple #30
0
 public void EventHappened(IGameEvent ge)
 {
     Debug.Log("Something happened: " + ge.Name);
     if (waitTillEventFinished)
     {
         if (ge.Name.ToLower() == "event finished" && ((IGameEvent)ge.getParameter("event")) == this.ge)
         {
             waitTillEventFinished = false;
         }
     }
 }