protected void OnValueChanged()
        {
            if (!_valueWasAssigned)
            {
                return;
            }

            Nodes.Node node = _object as Nodes.Node;
            if (node != null)
            {
                node.OnPropertyValueChanged(true);

                if (ValueWasChanged != null)
                {
                    ValueWasChanged();
                }

                return;
            }

            Events.Event evnt = _object as Events.Event;
            if (evnt != null)
            {
                evnt.OnPropertyValueChanged(true);

                if (ValueWasChanged != null)
                {
                    ValueWasChanged();
                }

                return;
            }
        }
Пример #2
0
        /// <summary>Removes function from call list of this event </summary>
        public void UnsubscribeToEvent(Events.Event _event, EventTrigger _trigger)
        {
            EventList tempList = m_eventList[(int)_event];

            tempList.m_event        -= _trigger;
            m_eventList[(int)_event] = tempList;
        }
Пример #3
0
        private void OnSocketData(Events.Event eventObj)
        {
            SocketEvent socketEvent = (SocketEvent)eventObj;
            TestPacket  packet      = (TestPacket)socketEvent.SocketPacket;

            Debug.Log(packet.Text);
            IntegrationTest.Pass(gameObject);
        }
Пример #4
0
        private void OnServerExceptionCaught(Events.Event eventObj)
        {
            SocketEvent socketEvent = (SocketEvent)eventObj;
            Exception   e           = socketEvent.Exception;

            Debug.Log(e.Message);
            Debug.Log(e.StackTrace);
        }
        /// <summary>
        /// Initialises a property on a given event.
        /// </summary>
        /// <param name="xml">The XML element containing the attribute we want to get.</param>
        /// <param name="node">The event whose property we want to set.</param>
        /// <param name="property">The property on the event we want to set.</param>
        protected void InitProperty(XmlNode xml, Events.Event evnt, DesignerPropertyInfo property)
        {
            string value;

            if (GetAttribute(xml, property.Property.Name, out value))
            {
                property.SetValueFromString(evnt, value);
            }
        }
Пример #6
0
        /// <summary>
        /// Called when [timer handler].
        /// </summary>
        /// <param name="eventObj">The event object.</param>
        private void OnTimerHandler(Events.Event eventObj)
        {
            TimerEvent timerEvent = eventObj as TimerEvent;

            QuickUnity.Timers.ITimer timer = timerEvent.timer;
            float deltaTime = timerEvent.deltaTime;

            Debug.Log("timer1 count: " + timer.currentCount + ", delta time: " + deltaTime);
        }
Пример #7
0
        public override void OnEventReceived(Events.Event e, object o)
        {
            if (e == Events.Event.PleaseDoSomething)
            {
                if (_actions.Count == 0)
                {
                    StartCoroutine(DoNextThing(Random.Range(0.1f, 1f)));
                }
                else
                {
                    DoNextAction();
                }
            }
            // Debug.Log("Event Received");
            if (e == Events.Event.RoomCreated)
            {
                // If already doing something, just redo the paths
                if (_actions != null && _actions.Count > 0)
                {
                    List <(List <ARoom> path, Action action)> newactions = new List <(List <ARoom> path, Action action)>();

                    // do not forget to start from the current room and not from the next one !!
                    _actions[0].path.Insert(0, _currentRoom);
                    foreach (var action in _actions)
                    {
                        newactions.Add((
                                           Astar.FindPath(action.path[0], action.path[action.path.Count - 1]),
                                           action.action
                                           ));
                    }
                    _actions = newactions;
                }
                // else {
                //     ChooseAction();
                // }
            }
            if (e == Events.Event.RoomDestroyed)
            {
                // oups
            }
            if (e == Events.Event.BlueprintDrawn || e == Events.Event.RoomCreated)
            {
                // Debug.Log("Blueprint Drawn event received for warehouseman");
                if (_actions.Count == 0)
                {
                    // Debug.Log("I'm available");
                    StartCoroutine(DoNextThing(Random.Range(0.1f, 1f)));
                }
            }
            if (e == Events.Event.ResourceMined)
            {
                if (_actions.Count == 0)
                {
                    StartCoroutine(DoNextThing(Random.Range(0.1f, 1f)));
                }
            }
        }
Пример #8
0
 public static void ShouldBeTheSameAs(this CommittedEvent committedEvent, Events.Event storedEvent)
 {
     committedEvent.EventLogSequenceNumber.Value.ShouldEqual(storedEvent.EventLogSequenceNumber);
     committedEvent.EventSource.Value.ShouldEqual(storedEvent.Metadata.EventSource);
     committedEvent.ExecutionContext.ShouldBeTheSameAs(storedEvent.ExecutionContext);
     committedEvent.Occurred.UtcDateTime.ShouldEqual(storedEvent.Metadata.Occurred);
     committedEvent.Public.ShouldEqual(storedEvent.Metadata.Public);
     committedEvent.Type.Id.Value.ShouldEqual(storedEvent.Metadata.TypeId);
     committedEvent.Type.Generation.Value.ShouldEqual(storedEvent.Metadata.TypeGeneration);
 }
Пример #9
0
 public void ReceiveEvent(Events.Event e)
 {
     if (e == Events.Event.ExplorationFlagSet)
     {
         PlayAudio(_explorationSet);
     }
     else if (e == Events.Event.ExplorationFlagUnset)
     {
         PlayAudio(_yes);
     }
 }
        private static Dictionary <OutputAction, Events.Event <T> > GenerateEventsForOutputActions <T>()
        {
            var values = Enum.GetValues(typeof(OutputAction));
            var dict   = new Dictionary <OutputAction, Events.Event <T> >(values.Length);

            foreach (OutputAction outputAction in values)
            {
                dict[outputAction] = new Events.Event <T>();
            }
            return(dict);
        }
Пример #11
0
        /// <summary>
        /// Called when [timer complete handler].
        /// </summary>
        /// <param name="eventObj">The event object.</param>
        private void OnTimerCompleteHandler(Events.Event eventObj)
        {
            TimerEvent timerEvent = eventObj as TimerEvent;

            QuickUnity.Timers.ITimer timer = timerEvent.timer;
            float deltaTime = timerEvent.deltaTime;

            Debug.Log("timer2 count: " + timer.currentCount + ", delta time: " + deltaTime);
            TimerManager timerManager = TimerManager.instance;

            timerManager.RemoveTimer("test1");
            timerManager.RemoveTimer("test2");
        }
Пример #12
0
        private Status ConvertFailureToException(Events.Event _event)
        {
            if (_event is Events.DailyLimitOver)
            {
                return(new Status.Failure(new DailyLimitOverException()));
            }
            if (_event is Events.InsufficientProduct)
            {
                return(new Status.Failure(new ProductStockExcessException()));
            }
            if (_event is Events.ProductNotFound)
            {
                return(new Status.Failure(new ArgumentException("Product is not found")));
            }

            return(new Status.Failure(new Exception()));
        }
Пример #13
0
        /// <summary>
        /// Loads an event which is attached to a node.
        /// </summary>
        /// <param name="node">The node the event is created for.</param>
        /// <param name="xml">The XML node the event retrieves its name and attributes from.</param>
        /// <returns>Returns the created SubItems.Event.</returns>
        protected Events.Event CreateEvent(Node node, XmlNode xml)
        {
            // get the type of the event and create it

            // maintain compatibility with version 1
            //string clss= GetAttribute(xml, "Class");
            string clss;

            if (!GetAttribute(xml, "Class", out clss))
            {
                string find  = ".Events." + GetAttribute(xml, "name");
                Type   found = Plugin.FindType(find);
                if (found != null)
                {
                    clss = found.FullName;
                }
            }

            Type t = Plugin.GetType(clss);

            if (t == null)
            {
                throw new Exception(string.Format(Resources.ExceptionUnknownEventType, clss));
            }

            Events.Event evnt = Events.Event.Create(t, node);

            // initialise the events properties
            IList <DesignerPropertyInfo> properties = evnt.GetDesignerProperties();

            for (int p = 0; p < properties.Count; ++p)
            {
                if (properties[p].Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave))
                {
                    continue;
                }

                InitProperty(xml, evnt, properties[p]);
            }

            // update event with attributes
            evnt.OnPropertyValueChanged(false);

            return(evnt);
        }
Пример #14
0
        protected void AddHandler <ChangeEvent>(
            StateChangeHandlerDelegate <ChangeEvent> handler,
            EventComparator <ChangeEvent> comparator,
            Events.Event <ChangeEvent> changeEvent
            )
        {
            UnityAction <ChangeEvent> ephemeralHandler = (ChangeEvent pEv) =>
            {
                handler(pEv);
            };

            changeEvent.Listen(ephemeralHandler);

            // Cleanup
            cleanupActions.Add(() =>
            {
                changeEvent.Remove(ephemeralHandler);
            });
        }
Пример #15
0
        public override void OnEventReceived(Events.Event e, object o)
        {
            if (e == Events.Event.MasterBlueprintFinished)
            {
                MasterBlueprint mbp = (MasterBlueprint)o;

                if (mbp.Owner == _id)
                {
                    // this is our BP
                    GenerateNewMasterBlueprint();
                }
            }
            if (e == Events.Event.ExplorationNewZone)
            {
                // check if any blueprints is active
                if (!MapManager.S.MapMasterBlueprints.Any(mbp => mbp.Owner == _id))
                {
                    GenerateNewMasterBlueprint();
                }
            }
        }
Пример #16
0
        protected void AddHandler <PressEvent>(
            PressHandlerDelegate <PressEvent> handler,
            PressEventComparator <PressEvent> comparator,
            Events.Event <PressEvent> pressEvent,
            Events.Event <PressEvent> unpressEvent
            )
        {
            UnityAction <PressEvent> ephemeralHandler = (PressEvent pEv) =>
            {
                var unpressHandler = handler(pEv);
                UnityAction <PressEvent> ephemeralUnpressHandler = null;
                void cleanupEphemeralUnpressHandler()
                {
                    unpressEvent.Remove(ephemeralUnpressHandler);
                }

                ephemeralUnpressHandler = (PressEvent uEv) =>
                {
                    if (!comparator(pEv, uEv))
                    {
                        return;
                    }

                    unpressHandler(uEv);
                    cleanupEphemeralUnpressHandler();
                    cleanupActions.Remove(cleanupEphemeralUnpressHandler);
                };
                unpressEvent.Listen(ephemeralUnpressHandler);
                cleanupActions.Add(cleanupEphemeralUnpressHandler);
            };

            pressEvent.Listen(ephemeralHandler);

            // Cleanup
            cleanupActions.Add(() =>
            {
                pressEvent.Remove(ephemeralHandler);
            });
        }
Пример #17
0
        /// <summary>
        /// Finds the correct Apply() method in the AggregateRoot and call it to apply changes to state
        /// </summary>
        /// <param name="event">The event to handle</param>
        /// <param name="isNew">Is this a new Event</param>
        private void HandleEvent(Events.Event @event, bool isNew)
        {
            //All state changes to AggregateRoot must happen via the Apply method
            //Make sure the right Apply method is called with the right type.
            //We will use reflection for this.

            //TODO: I tried dynamic object for this but ran into some issues. Give it a try using dynamics again.

            try
            {
                object[] args   = new object[] { @event };
                var      method = ((object)this).GetType().GetMethod("Apply", new Type[] { @event.GetType() }); //Find the right method
                method.Invoke(this, args);                                                                      //invoke with the event as argument

                if (isNew)
                {
                    _changes.Add(@event); //only add to the events collection if it's a new event
                }
            }
            catch (Exception ex)
            {
                throw new EventHandlerApplyMethodMissingException(ex.Message);
            }
        }
Пример #18
0
 private void OnSocketDisconnected(Events.Event eventObj)
 {
     Debug.Log("socket is disconnected");
 }
Пример #19
0
 protected void tab_Click(object sender, Events.Event e)
 {
     pages.ActivatePage(e.properties.Get("id"));
 }
Пример #20
0
 private void OnSocketClosed(Events.Event eventObj)
 {
     Debug.Log("socket is closed");
 }
Пример #21
0
 /// <summary>Adds event call to EventBuffer for processing in LateUpdate </summary>
 public void AddEvent(Events.Event _event)
 {
     m_tempBuffer.Add(_event);
 }
Пример #22
0
			/// <summary>
			/// Creates a new subitm which can render an event on the node.
			/// </summary>
			/// <param name="evnt">The event we want to draw.</param>
			public SubItemEvent(Events.Event evnt) : base(_theDefaultEventBrush, _theSelectedEventBrush, _theEventLabelFont, null, Alignment.Center, false)
			{
				_event= evnt;
			}
Пример #23
0
        /// <summary>
        /// Tests the event handler.
        /// </summary>
        /// <param name="eventObj">The event object.</param>
        private void TestEventHandler(Events.Event eventObj)
        {
            EventExample example = GetComponent <EventExample>();

            example.RemoveEventListener(EventExample.TestEvent, TestEventHandler);
        }
Пример #24
0
 public void onEvent(Events.Event e)
 {
 }
Пример #25
0
 public static void ShouldBeTheSameAs(this CommittedAggregateEvent committedEvent, Events.Event storedEvent)
 {
     (committedEvent as CommittedEvent).ShouldBeTheSameAs(storedEvent);
     committedEvent.AggregateRoot.Id.Value.ShouldEqual(storedEvent.Aggregate.TypeId);
     committedEvent.AggregateRoot.Generation.Value.ShouldEqual(storedEvent.Aggregate.TypeGeneration);
     committedEvent.AggregateRootVersion.Value.ShouldEqual(storedEvent.Aggregate.Version);
 }
 /// <summary>
 /// Creates a new subitm which can render an event on the node.
 /// </summary>
 /// <param name="evnt">The event we want to draw.</param>
 public SubItemEvent(Events.Event evnt) : base(_theDefaultEventBrush, _theSelectedEventBrush, _theEventLabelFont, null, Alignment.Center, false)
 {
     _event = evnt;
 }
Пример #27
0
 private void OnClientConnected(Events.Event eventObj)
 {
     Debug.Log("client connected!");
     IntegrationTest.Pass();
 }
 /// <summary>
 /// Returns the property's value.
 /// </summary>
 /// <param name="node">The event we want to get the value from.</param>
 /// <returns>The value as an object.</returns>
 public object GetValue(Events.Event evnt)
 {
     return(_property.GetValue(evnt, null));
 }
Пример #29
0
 private void OnServerStop(Events.Event eventObj)
 {
     Debug.Log("server stop");
 }
Пример #30
0
 private void OnServerStart(Events.Event eventObj)
 {
     Debug.Log("server started!");
 }
Пример #31
0
        /// <summary>
        /// Saves a node to the XML file.
        /// </summary>
        /// <param name="root">The XML node we want to attach the node to.</param>
        /// <param name="node">The node we want to save.</param>
        protected void SaveNode(XmlElement root, Node node)
        {
            // allow the node to process its attributes in preparation of the save
            node.PreSave(_node);

            // store the class we have to create when loading
            XmlElement elem = _xmlfile.CreateElement("Node");

            elem.SetAttribute("Class", node.GetType().FullName);

            // save attributes
            IList <DesignerPropertyInfo> properties = node.GetDesignerProperties();

            for (int p = 0; p < properties.Count; ++p)
            {
                if (!properties[p].Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave))
                {
                    elem.SetAttribute(properties[p].Property.Name, properties[p].GetStringValue(node));
                }
            }

            // append node to root
            root.AppendChild(elem);

            // save comment
            if (node.CommentObject != null)
            {
                XmlElement comment = _xmlfile.CreateElement("Comment");

                properties = node.CommentObject.GetDesignerProperties();
                for (int p = 0; p < properties.Count; ++p)
                {
                    if (!properties[p].Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave))
                    {
                        comment.SetAttribute(properties[p].Property.Name, properties[p].GetStringValue(node.CommentObject));
                    }
                }

                elem.AppendChild(comment);
            }

            // save events
            foreach (Nodes.Node.SubItem sub in node.SubItems)
            {
                if (sub is Nodes.Node.SubItemEvent)
                {
                    Events.Event ne = ((Nodes.Node.SubItemEvent)sub).Event;

                    XmlElement evnt = _xmlfile.CreateElement("Event");
                    evnt.SetAttribute("Class", ne.GetType().FullName);

                    // save attributes
                    properties = ne.GetDesignerProperties();
                    for (int p = 0; p < properties.Count; ++p)
                    {
                        if (!properties[p].Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave))
                        {
                            elem.SetAttribute(properties[p].Property.Name, properties[p].GetStringValue(ne));
                        }
                    }

                    elem.AppendChild(evnt);
                }
            }

            // save children if allowed. Disallowed for referenced behaviours.
            if (node.SaveChildren)
            {
                // save connectors
                foreach (Nodes.Node.Connector connector in node.Connectors)
                {
                    // if we have no children to store we can skip the connector
                    if (connector.ChildCount < 1)
                    {
                        continue;
                    }

                    XmlElement conn = _xmlfile.CreateElement("Connector");
                    conn.SetAttribute("Identifier", connector.Identifier);
                    elem.AppendChild(conn);

                    // save their children
                    for (int i = 0; i < connector.ChildCount; ++i)
                    {
                        SaveNode(conn, connector.GetChild(i));
                    }
                }
            }
        }