Exemplo n.º 1
0
        // 响应工作线程发出的AI移动棋子事件,用ITWEEN移动棋子game obj到对应的位置上
        void OnAiMove( EventBase eb )
        {
            AIMoveEvent aIMoveEvent = eb.eventValue as AIMoveEvent;
            Debug.Log(string.Format("事件回调:{0}, from={1}, to={2}", AIMoveEvent.AI_MOVE_EVNET, aIMoveEvent.from, aIMoveEvent.to));

            if (aIMoveEvent != null) {
                // 得到下标检测球GameObject
                GameObject indexSphereGo = IndexCtrlBehaviour.instance.getIndexSphereGo(aIMoveEvent.from);
                if (indexSphereGo == null) {
                    Debuger.LogError(string.Format("该256下标{0} indexSphereGo is null", aIMoveEvent.from));
                    return;
                }

                // 得到下标检测球上的IndexTriger脚本
                IndexTrigerBehaviour indexTriger = indexSphereGo.GetComponent<IndexTrigerBehaviour>( );
                if (indexTriger != null) {
                    // 如果该检测球上有棋子,则移动棋子到该次下棋的终点的检测球位置
                    if (indexTriger.HasQiZi) {
                        Debug.Log(string.Format("AI下棋,将棋子从256数组下标{0}移到下标{1}", aIMoveEvent.from, aIMoveEvent.to));
                        // 用ITWEEN移动棋子game obj
                        TweenUtil.MoveTo(indexTriger.QiZiGameObject, IndexCtrlBehaviour.instance.getIndexSphereGo(aIMoveEvent.to).GetComponent<Transform>( ).localPosition, m_moveTime);

                        Action finishAction = AiOnceMoveFinish;
                        StartCoroutine(DelayToInvokeUtil.DelayToInvokeDo(finishAction, m_moveTime));
                    }
                } else {
                    Debug.LogError("indexTriger is null !!");
                }
            } else {
                Debug.LogError("aIMoveEvent is null !!");
            }
        }
Exemplo n.º 2
0
    //called when the editor object is activated
    public override void OnActivate(object caller, EventBase evt)
    {
        base.OnActivate(caller, evt);

        foreach(GameObject entityToSpawn in EntitiesToSpawn)
        {
            GameObject.Instantiate(entityToSpawn, transform.position, Quaternion.identity);
        }
    }
Exemplo n.º 3
0
		protected EventSubscription(EventBase parentEvent,
									Action action,
									ThreadOption threadOption,
									ReferenceOption referenceOption)
			: base(parentEvent, threadOption, referenceOption)
		{
			Verify.ArgumentNotNull(action, "action");
			DelegateReference = new DelegateReference(action, referenceOption);
		}
		public UIThreadSubscription(EventBase parentEvent, Action action, ThreadOption threadOption,
		                            ReferenceOption referenceOption)
			: base(parentEvent, action, threadOption, referenceOption)
		{
			if (ThreadOption != ThreadOption.UIThread && ThreadOption != ThreadOption.UIThreadPost)
			{
				throw new InvalidOperationException("Incorrect thread option");
			}
		}
Exemplo n.º 5
0
        public void ApplyEvent(EventBase @event, bool isNew = true)
        {
            dynamic thisAsDynamic = this;
            thisAsDynamic.Handle(Converter.ChangeTo(@event, @event.GetType()));

            if (isNew)
                _uncommittedEvents.Add(@event);

            Version++;
        }
		public BackgroundThreadSubscription(EventBase parentEvent,
											Action action,
											ThreadOption threadOption,
											ReferenceOption referenceOption)
			: base(parentEvent, action, threadOption, referenceOption)
		{
			if (ThreadOption != ThreadOption.BackgroundThread)
			{
				throw new InvalidOperationException("Invalid thread option");
			}
		}
Exemplo n.º 7
0
    public void EventHandler(object sender, EventBase evt)
    {
        foreach(MovableObjectEvent movEvt in mEventDictionary[evt.GetType()])
        {
            if (movEvt.FromObject != null && sender != movEvt.FromObject)
            {
                continue;
            }

            TargetObject.GivePath(new List<MovableObjectPosition>(Positions), MoveSpeed, Interruptable, MoveMode, LoopMode);
        }
    }
Exemplo n.º 8
0
 public void ShowMessage(EventBase currEvent)
 {
     transform.localScale = Vector3.one;
     StartCoroutine(MessageScaleChange(currEvent));
     if (Smoke.activeSelf)
     {
         currEvent.transform.localPosition = new Vector2(-0.4f, 0.7f);
     }
     else
     {
         currEvent.transform.localPosition = new Vector2(0, 0.7f);
     }
 }
Exemplo n.º 9
0
    //called when the editor object is activated
    public override void OnActivate(object caller, EventBase evt)
    {
        base.OnActivate(caller, evt);

        if (!WaitingForCallerAndMessage(caller as EditorObject, EditorObject.EditorObjectMessage.Activate))
        {
            return;
        }

        foreach(GameObject entityToSpawn in EntitiesToSpawn)
        {
            GameObject.Instantiate(entityToSpawn, transform.position, Quaternion.identity);
        }
    }
Exemplo n.º 10
0
        public void Store(Guid aggregateId, long aggregateVersion, EventBase[] events)
        {
            List<EventBase> listOfEvents;
            if (!EventsDict.ContainsKey(aggregateId))
            {
                listOfEvents = new List<EventBase>();
                EventsDict[aggregateId] = listOfEvents;
            }
            else
            {
                listOfEvents = EventsDict[aggregateId];
            }
            listOfEvents.AddRange(events);

            _eventBus.Publish(events);
        }
Exemplo n.º 11
0
    public void PushEvent(EventBase targetEvent) // Calls when ritual events created.
    {
        audioSource.Play(); // Notification sound

        World targetWorld = worldMgr.GetWorld(targetEvent.town);
  
        // Set notification message.
        string eventName = targetEvent.GetComponent<SpriteRenderer>().sprite.name;
        string message = "@god" + "  #" + eventName + "  #" + GetWorldName(targetWorld);

        Text newText = Instantiate(newsfeedTextPrefab).GetComponent<Text>();
        newText.transform.SetParent(this.transform, false);
        newText.transform.localPosition = new Vector2(200, -75);
        newText.text = message;
        messageQueue.Enqueue(new MessageInfo(newText.GetComponent<Text>(), 0));

        foreach (MessageInfo eachInfo in messageQueue)
        {
            StartCoroutine(MoveUpward(eachInfo.messageText)); // Move upward old messages.
        }
    }
Exemplo n.º 12
0
    IEnumerator MessageScaleChange(EventBase currEvent)
    {
        float existTime = currEvent.existTime;
        float elapsedTime = 0f;

        yield return new WaitForSeconds(existTime / 2);
        existTime /= 2;

        while (true)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime >= existTime)
                break;
            if (!currEvent.isWaiting)
                break;
            if (currEvent == null)
                break;
            currEvent.transform.localScale = new Vector2(1.5f + Mathf.Sin(elapsedTime * 3) / 7, 1.5f + Mathf.Sin(elapsedTime * 3) / 7);

            yield return null;
        }
    }
 public void SetGesture(EventBase.Type value)
 {
     gesture = value;
 }
Exemplo n.º 14
0
        public Task EventHandler(AmountTransferEvent value, EventBase eventBase)
        {
            var toActor = GrainFactory.GetGrain <IAccount>(value.ToAccountId);

            return(toActor.AddAmount(value.Amount, new EventUID(eventBase.GetEventId(GrainId.ToString()), eventBase.Timestamp)));
        }
Exemplo n.º 15
0
        //Application system event handle.When receive system event(online/offline...), it will be invoked.
        void EventHandler_SYS(EventBase e)
        {
            try
            {
                ServiceEvent serviceEvent = e as ServiceEvent;
                if (serviceEvent == null)
                {
                    return;
                }

                ChannelChangedReport ccs = serviceEvent._eventData as ChannelChangedReport;
                if (ccs == null)
                {
                    return;
                }

                //channel offline notification
                if (ccs._isDelete)
                {
                    for (int i = 0; i < _channelCollection.Count; i++)
                    {
                        if (ccs._channelID != _channelCollection[i].channelId)
                        {
                            continue;
                        }

                        this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =>
                        {
                            _channelCollection.RemoveAt(i);
                            //lbDispatchStationID.Content = "";
                            lbDispatchStationID.Content    = "Not Connected";
                            lbDispatchStationID.Foreground = System.Windows.Media.Brushes.Red;
                        }));
                    }
                }
                //channel online notification
                else
                {
                    Channel channel = new Channel();
                    channel.channelId   = ccs._channelID;
                    channel.deviceId    = ccs._deviceID;
                    channel.ip          = ccs._channelIP;
                    channel.slotId      = ccs._soltID;
                    channel.isPlaySound = false;
                    channel.channelType = (ChannelChangedReport.ChannelType)ccs._channelType;

                    _dispatcherDeviceId = channel.deviceId;
                    _channelCollection.Add(channel);

                    if (_channelCollection.Count == 1 &&
                        _channelCollection[0].channelType == ChannelChangedReport.ChannelType.REPEATER_CHANNEL)
                    {
                        return;
                    }

                    this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =>
                    {
                        //lbDispatchStationID.Content = channel.deviceId;
                        lbDispatchStationID.Content    = "Connected";
                        lbDispatchStationID.Foreground = System.Windows.Media.Brushes.Green;
                        dispatchStationID = channel.deviceId;
                    }));

                    _adk.SetHeardBeatInterval(channel.channelId, 0);
                }
            }
            catch (Exception exception)
            {
            }
        }
Exemplo n.º 16
0
        private void RefreshExtendedData()
        {
            grpConsumable.Visible = false;
            grpSpell.Visible      = false;
            grpEquipment.Visible  = false;
            grpEvent.Visible      = false;
            grpBags.Visible       = false;

            if ((int)mEditorItem.ItemType != cmbType.SelectedIndex)
            {
                mEditorItem.Consumable.Type  = ConsumableType.Health;
                mEditorItem.Consumable.Value = 0;

                mEditorItem.TwoHanded         = false;
                mEditorItem.EquipmentSlot     = 0;
                mEditorItem.Effect.Type       = EffectType.None;
                mEditorItem.Effect.Percentage = 0;

                mEditorItem.SlotCount = 0;

                mEditorItem.Damage = 0;
                mEditorItem.Tool   = -1;

                mEditorItem.Spell = null;
                mEditorItem.Event = null;
            }

            if (cmbType.SelectedIndex == (int)ItemTypes.Consumable)
            {
                cmbConsume.SelectedIndex    = (int)mEditorItem.Consumable.Type;
                nudInterval.Value           = mEditorItem.Consumable.Value;
                nudIntervalPercentage.Value = mEditorItem.Consumable.Percentage;
                grpConsumable.Visible       = true;
            }
            else if (cmbType.SelectedIndex == (int)ItemTypes.Spell)
            {
                cmbTeachSpell.SelectedIndex = SpellBase.ListIndex(mEditorItem.SpellId) + 1;
                chkQuickCast.Checked        = mEditorItem.QuickCast;
                chkDestroy.Checked          = mEditorItem.DestroySpell;
                grpSpell.Visible            = true;
            }
            else if (cmbType.SelectedIndex == (int)ItemTypes.Event)
            {
                cmbEvent.SelectedIndex = EventBase.ListIndex(mEditorItem.EventId) + 1;
                grpEvent.Visible       = true;
            }
            else if (cmbType.SelectedIndex == (int)ItemTypes.Equipment)
            {
                grpEquipment.Visible = true;
                if (mEditorItem.EquipmentSlot < -1 || mEditorItem.EquipmentSlot >= cmbEquipmentSlot.Items.Count)
                {
                    mEditorItem.EquipmentSlot = 0;
                }

                cmbEquipmentSlot.SelectedIndex  = mEditorItem.EquipmentSlot;
                cmbEquipmentBonus.SelectedIndex = (int)mEditorItem.Effect.Type;
            }
            else if (cmbType.SelectedIndex == (int)ItemTypes.Bag)
            {
                // Cant have no space or negative space.
                mEditorItem.SlotCount = Math.Max(1, mEditorItem.SlotCount);
                grpBags.Visible       = true;
                nudBag.Value          = mEditorItem.SlotCount;
            }

            mEditorItem.ItemType = (ItemTypes)cmbType.SelectedIndex;
        }
 public virtual void SetParameter(EventBase even)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 18
0
 public static bool CompareID(Tile tile, EventBase targetEvent)
 {
     return tile.ID == targetEvent.ID;
 }
Exemplo n.º 19
0
		internal void Enqueue (EventBase e) {
			_events.Add (e);
		}
Exemplo n.º 20
0
        protected override void ProcessDragDrop(TreeNode dragNode, TreeNode dropNode)
        {
            CollectionEditEventArgs[] eventArgs = new CollectionEditEventArgs[2];

            EventTreeNode node         = dragNode as EventTreeNode;
            int           nodeOldIndex = this.EventSupport.Events.IndexOf(node.Event);
            EventBase     oldEvent     = null;

            if (EventOrderChanged != null)
            {
                oldEvent = node.Event.Clone() as EventBase;
            }

            #region 如果目标节点是触发时机

            //如果目标节点是触发时机,把拖动的节点放到这个触发时机的最后面
            //需要调用一次EventCollection.Down方法,同步事件序列的顺序
            //并把拖动的事件的触发时机修改为目标节点同样的触发时机
            if (dropNode.GetType().Equals(typeof(EventTimeTreeNode)))
            {
                //直接调用基类方法完成节点移动
                base.MoveNode(dragNode, dropNode);

                //同步触发事件顺序
                //拿到dragNode的前一个节点(如果有),调用一次Down方法

                //改变触发时机
                EventTimeTreeNode eventTimeNode = dragNode.Parent as EventTimeTreeNode;
                node.Event.EventTime = eventTimeNode.EventTime.Code;

                //确保拖动的事件在事件序列中处于当前触发时机中所有事件的最后
                EventTreeNode eventNode = dragNode.PrevNode as EventTreeNode;
                if (eventNode != null)
                {
                    this.EventSupport.Events.NextTo(node.Event, eventNode.Event);
                }
            }

            #endregion

            #region 如果目标节点是事件

            //如果目标节点是事件,把拖动的事件放到这个事件的前面,需调用Up方法同步事件顺序
            //并把拖动的事件的触发时机修改为目标节点同样的触发时机
            else if (dropNode.GetType().Equals(typeof(EventTreeNode)))
            {
                //如果放在拖动节点的同级下一个节点,do nothing
                if (dropNode.NextNode == dragNode)
                {
                    return;
                }

                //移动树节点
                // Remove drag node from parent
                dragNode.Parent.Nodes.Remove(dragNode);
                // Add drag node to drop node
                dropNode.Parent.Nodes.Insert(dropNode.Index + 1, dragNode);

                EventTreeNode prevNode = dragNode.PrevNode as EventTreeNode;

                //改变触发时机
                node.Event.EventTime = prevNode.Event.EventTime;

                //nextNode不可能为null,就是dragNode
                this.EventSupport.Events.NextTo(node.Event, prevNode.Event);
            }

            #endregion

            if (EventOrderChanged != null)
            {
                CollectionEditEventArgs args0 = new CollectionEditEventArgs(this.EventSupport.Events,
                                                                            CollectionEditType.Edit, this.EventSupport.Events.IndexOf(node.Event), node.Event);
                args0.Members.Inject(ObjectCompare.Compare(oldEvent, node.Event));
                eventArgs[0] = args0;

                eventArgs[1] = new CollectionEditEventArgs(this.EventSupport.Events, CollectionEditType.Move,
                                                           this.EventSupport.Events.IndexOf(node.Event), nodeOldIndex, node.Event);

                EventOrderChanged(eventArgs);
            }
        }
        public EventPageInstance(
            EventBase myEvent,
            EventPage myPage,
            Guid mapId,
            Event eventIndex,
            Player player
            ) : base(Guid.NewGuid())
        {
            BaseEvent      = myEvent;
            Id             = BaseEvent.Id;
            MyPage         = myPage;
            MapId          = mapId;
            X              = eventIndex.X;
            Y              = eventIndex.Y;
            Name           = myEvent.Name;
            MovementType   = MyPage.Movement.Type;
            MovementFreq   = MyPage.Movement.Frequency;
            MovementSpeed  = MyPage.Movement.Speed;
            DisablePreview = MyPage.DisablePreview;
            Trigger        = MyPage.Trigger;
            Passable       = MyPage.Passable;
            HideName       = MyPage.HideName;
            MyEventIndex   = eventIndex;
            MoveRoute      = new EventMoveRoute();
            MoveRoute.CopyFrom(MyPage.Movement.Route);
            mPathFinder = new Pathfinder(this);
            SetMovementSpeed(MyPage.Movement.Speed);
            MyGraphic.Type     = MyPage.Graphic.Type;
            MyGraphic.Filename = MyPage.Graphic.Filename;
            MyGraphic.X        = MyPage.Graphic.X;
            MyGraphic.Y        = MyPage.Graphic.Y;
            MyGraphic.Width    = MyPage.Graphic.Width;
            MyGraphic.Height   = MyPage.Graphic.Height;
            Sprite             = MyPage.Graphic.Filename;
            mDirectionFix      = MyPage.DirectionFix;
            mWalkingAnim       = MyPage.WalkingAnimation;
            mRenderLayer       = MyPage.Layer;
            if (MyGraphic.Type == EventGraphicType.Sprite)
            {
                switch (MyGraphic.Y)
                {
                case 0:
                    Dir = 1;

                    break;

                case 1:
                    Dir = 2;

                    break;

                case 2:
                    Dir = 3;

                    break;

                case 3:
                    Dir = 0;

                    break;
                }
            }

            if (myPage.AnimationId != Guid.Empty)
            {
                Animations.Add(myPage.AnimationId);
            }

            Face     = MyPage.FaceGraphic;
            mPageNum = BaseEvent.Pages.IndexOf(MyPage);
            Player   = player;
            SendToPlayer();
        }
Exemplo n.º 22
0
 public CommandBinding(EventBase type) : base(type)
 {
 }
Exemplo n.º 23
0
        public override void SetParameter(EventBase even)
        {
            DataListDeleteRowDev _event = even as DataListDeleteRowDev;

            this.DataListId = _event.DataList;

            this.TargetWindow = _event.TargetWindow;

            this._wheres = new BindingList <DataListDeleteRowEvent.WhereItem>(_event.Where);
            this._warningTable.Clear();

            //为用于显示的DataColumnName和SourceName赋值
            bool warningRow            = false;
            DataSourceProvideArgs args = new DataSourceProvideArgs()
            {
                WindowEntity = this.HostAdapter.HostFormEntity
            };

            foreach (DataListDeleteRowEvent.WhereItem where in _wheres)
            {
                //where.SourceName = StringParserLogic.DataSourceVisibleString(this.HostAdapter.HostFormEntity, where.Source.ToString(), out warningRow);
                where.SourceName = DataSourceProvideFactory.Instance.GetDisplayString(where.Source, args);
                if (String.IsNullOrEmpty(where.SourceName))
                {
                    warningRow = true;
                }

                //如果是当前窗体
                if (this.TargetWindow == EnumTargetWindow.Current)
                {
                    UIElement formElementDataList = this.HostAdapter.HostFormEntity.FindFormElementById(_event.DataList);
                    if (formElementDataList == null)
                    {
                        warningRow = true;
                    }
                    else
                    {
                        //FormElementDataListEntityDev
                        UIElementDataListEntity dataList = (UIElementDataListEntity)formElementDataList;
                        UIElementDataListColumnEntityAbstract dataColumn = dataList.GetDataColumn(where.DataColumn);

                        if (dataColumn == null)
                        {
                            warningRow = true;
                        }
                        else
                        {
                            where.DataColumnName = dataColumn.Name;
                        }
                    }
                }
                //如果是调用者窗体
                else
                {
                    where.DataColumnName = where.DataColumn;
                }

                this._warningTable.Add(where, warningRow);
            }

            this.dataGridViewDataSet.DataSource = this._wheres;
        }
Exemplo n.º 24
0
 static void \u202E​‭‌‬‪‏‌‌‮​‌‌‫‮‌‮‌​‌‍‫‮([In] EventBase obj0, [In] SubscriptionToken obj1)
 {
     obj0.Unsubscribe(obj1);
 }
Exemplo n.º 25
0
 private void OnSceneUnlock(EventBase evt)
 {
     UpdateUI();
 }
Exemplo n.º 26
0
 public virtual void ExecuteDefaultActionAtTarget(EventBase evt)
 {
 }
Exemplo n.º 27
0
 public DataListRefreshDevEditorAdapter(EventBase hostEvent)
     : base(hostEvent)
 {
 }
Exemplo n.º 28
0
        public void DispatchEvent(EventBase evt, IPanel panel)
        {
            IMouseEvent mouseEvent = evt as IMouseEvent;

            if (mouseEvent == null)
            {
                return;
            }

            BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel;

            // update element under mouse and fire necessary events

            bool shouldRecomputeTopElementUnderMouse = true;

            if ((IMouseEventInternal)mouseEvent != null)
            {
                shouldRecomputeTopElementUnderMouse =
                    ((IMouseEventInternal)mouseEvent).recomputeTopElementUnderMouse;
            }

            VisualElement elementUnderMouse = shouldRecomputeTopElementUnderMouse
                ? basePanel?.Pick(mouseEvent.mousePosition)
                : basePanel?.GetTopElementUnderPointer(PointerId.mousePointerId);

            if (evt.target == null && elementUnderMouse != null)
            {
                evt.propagateToIMGUI = false;
                evt.target           = elementUnderMouse;
            }
            else if (evt.target == null && elementUnderMouse == null)
            {
                // Event occured outside the window.
                // Send event to visual tree root and
                // don't modify evt.propagateToIMGUI.
                evt.target = panel?.visualTree;
            }
            else if (evt.target != null)
            {
                evt.propagateToIMGUI = false;
            }

            if (basePanel != null)
            {
                // If mouse leaves the window, make sure element under mouse is null.
                // However, if pressed button != 0, we are getting a MouseLeaveWindowEvent as part of
                // of a drag and drop operation, at the very beginning of the drag. Since
                // we are not really exiting the window, we do not want to set the element
                // under mouse to null in this case.
                if (evt.eventTypeId == MouseLeaveWindowEvent.TypeId() &&
                    (evt as MouseLeaveWindowEvent).pressedButtons == 0)
                {
                    basePanel.SetElementUnderPointer(null, evt);
                }
                else if (shouldRecomputeTopElementUnderMouse)
                {
                    basePanel.SetElementUnderPointer(elementUnderMouse, evt);
                }
            }

            if (evt.target != null)
            {
                EventDispatchUtilities.PropagateEvent(evt);
                if (evt.target is IMGUIContainer)
                {
                    evt.propagateToIMGUI = true;
                    evt.skipElements.Add(evt.target);
                }
            }

            if (!evt.isPropagationStopped && panel != null)
            {
                if (evt.propagateToIMGUI ||
                    evt.eventTypeId == MouseEnterWindowEvent.TypeId() ||
                    evt.eventTypeId == MouseLeaveWindowEvent.TypeId()
                    )
                {
                    EventDispatchUtilities.PropagateToIMGUIContainer(panel.visualTree, evt);
                }
                else if (panel.visualTree.childCount > 0 && panel.visualTree[0] is IMGUIContainer)
                {
                    // Send the events to the GUIView container so that it can process them.
                    // This avoid elements near the edge of the window preventing the dock area splitter to work.
                    // See case : https://fogbugz.unity3d.com/f/cases/1197851/
                    var topLevelIMGUI = (IMGUIContainer)panel.visualTree[0];
                    if (!evt.Skip(topLevelIMGUI) && evt.imguiEvent != null)
                    {
                        topLevelIMGUI.SendEventToIMGUI(evt, false);
                        if (evt.imguiEvent.rawType == EventType.Used)
                        {
                            evt.StopPropagation();
                        }
                    }
                }
            }

            evt.stopDispatch = true;
        }
Exemplo n.º 29
0
        public void Store(Guid aggregateId, long aggregateVersion, EventBase[] events)
        {
            var currentVersion = aggregateVersion;
            var expectedInitialVersion = currentVersion - events.Count();
            var streamId = aggregateId;

            var connectionString = _dataAccessConfiguration.EventStoreConnectionString;
            var serializedEvents = events.Select(x => new Tuple<string, string>(
                x.GetType().FullName + "," + x.GetType().Assembly.GetName(), JsonConvert.SerializeObject(x, _serializerSettings)));

            using (var t = new TransactionScope(TransactionScopeOption.Required,
                new TransactionOptions { IsolationLevel = IsolationLevel.Serializable }))
            {
                using (var con = new SqlConnection(connectionString))
                {
                    con.Open();

                    const string commandText = "SELECT TOP 1 CurrentSequence " +
                        "FROM Streams WITH (UPDLOCK) WHERE StreamId = @StreamId;";

                    long? existingSequence;
                    using (var command = new SqlCommand(commandText, con))
                    {
                        command.Parameters.AddWithValue("StreamId", streamId);
                        var current = command.ExecuteScalar();
                        existingSequence = current == null ? (long?)null : (long)current;

                        if (existingSequence != null && ((long)existingSequence) != expectedInitialVersion)
                            throw new ConcurrencyException();
                    }

                    var nextVersion = InsertEventsAndReturnLastVersion(streamId, con, expectedInitialVersion, serializedEvents);

                    if (existingSequence == null)
                        StartNewSequence(streamId, nextVersion, con);
                    else
                        UpdateSequence(streamId, expectedInitialVersion, nextVersion, con);

                    t.Complete();
                }
            }

            _bus.Publish(events);
        }
Exemplo n.º 30
0
 public bool CanDispatchEvent(EventBase evt)
 {
     return(evt is IMouseEvent);
 }
Exemplo n.º 31
0
 void Awake()
 {
     targetEvent = GetComponent<EventBase>();
 }
Exemplo n.º 32
0
        public bool TryDequeue(string queueName, out EventBase @event)
        {
            var queue = _eventQueues.GetOrAdd(queueName, q => new ConcurrentQueue <EventBase>());

            return(queue.TryDequeue(out @event));
        }
 public override bool CanHandle(EventBase e)
 {
     return(e is MoveInCatalogEvent);
 }
Exemplo n.º 34
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="evt">Note that all events have NOT being developed to be sent, only to be received.</param>
 public SendEventCmd(EventBase evt)
 {
     _event = evt;
 }
Exemplo n.º 35
0
 private void cmbEvent_SelectedIndexChanged(object sender, EventArgs e)
 {
     mEditorItem.Event = EventBase.Get(EventBase.IdFromList(cmbEvent.SelectedIndex - 1));
 }
Exemplo n.º 36
0
 public ContentEvent(EventBase baseInstance)
     : base(baseInstance)
 {
 }
        public MapBase(MapBase mapBase) : base(mapBase?.Id ?? Guid.Empty)
        {
            if (mapBase == null)
            {
                return;
            }

            lock (MapLock ?? throw new ArgumentNullException(nameof(MapLock), @"this"))
            {
                lock (mapBase.MapLock ?? throw new ArgumentNullException(nameof(mapBase.MapLock), nameof(mapBase)))
                {
                    Name       = mapBase.Name;
                    Brightness = mapBase.Brightness;
                    IsIndoors  = mapBase.IsIndoors;
                    if (Layers != null && mapBase.Layers != null)
                    {
                        Layers.Clear();

                        foreach (var layer in mapBase.Layers)
                        {
                            var tiles = new Tile[Options.MapWidth, Options.MapHeight];
                            for (var x = 0; x < Options.MapWidth; x++)
                            {
                                for (var y = 0; y < Options.MapHeight; y++)
                                {
                                    tiles[x, y] = new Tile
                                    {
                                        TilesetId = layer.Value[x, y].TilesetId,
                                        X         = layer.Value[x, y].X,
                                        Y         = layer.Value[x, y].Y,
                                        Autotile  = layer.Value[x, y].Autotile
                                    };
                                }
                            }
                            Layers.Add(layer.Key, tiles);
                        }
                    }

                    for (var x = 0; x < Options.MapWidth; x++)
                    {
                        for (var y = 0; y < Options.MapHeight; y++)
                        {
                            if (Attributes == null)
                            {
                                continue;
                            }

                            if (mapBase.Attributes?[x, y] == null)
                            {
                                Attributes[x, y] = null;
                            }
                            else
                            {
                                Attributes[x, y] = mapBase.Attributes[x, y].Clone();
                            }
                        }
                    }

                    for (var i = 0; i < mapBase.Spawns?.Count; i++)
                    {
                        Spawns.Add(new NpcSpawn(mapBase.Spawns[i]));
                    }

                    for (var i = 0; i < mapBase.Lights?.Count; i++)
                    {
                        Lights.Add(new LightBase(mapBase.Lights[i]));
                    }

                    foreach (var record in mapBase.LocalEvents)
                    {
                        var evt = new EventBase(record.Key, record.Value?.JsonData);
                        LocalEvents?.Add(record.Key, evt);
                    }

                    EventIds?.Clear();
                    EventIds?.AddRange(mapBase.EventIds?.ToArray() ?? new Guid[] { });
                }
            }
        }
Exemplo n.º 38
0
 //called when the editor object is deactivated
 public override void OnDeactivate(object caller, EventBase evt)
 {
     base.OnDeactivate(caller, evt);
 }
 public bool CanDispatchEvent(EventBase evt)
 {
     return(true);
 }
Exemplo n.º 40
0
 //called when the editor object is toggled
 public override void OnToggle(object caller, EventBase evt)
 {
     base.OnToggle(caller, evt);
 }
Exemplo n.º 41
0
 public void AddEvent(EventBase e)   //向字典中添加请求
 {
     eventDict.Add(e.eventCode, e);
 }
Exemplo n.º 42
0
 public override void UseTile(EventBase targetEvent)
 {
     this.targetEvent = targetEvent;
     StartCoroutine(HealParticleProcess());
 }
Exemplo n.º 43
0
 void OnTitleChange(EventBase e)
 {
     title = m_TitleField.value;
 }
Exemplo n.º 44
0
 private void OnSucceed(EventBase e)
 {
     SetResult(1);
     pass();
 }
Exemplo n.º 45
0
 public BreakEvent(EventBase baseInstance)
     : base(baseInstance)
 {
 }
Exemplo n.º 46
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="evt"></param>
 /// <returns>true if it's inbound to pbx (not to user)</returns>
 private bool IsInbound(EventBase evt)
 {
     return(evt.Parameters["Call-Direction"] == "inbound");
 }
Exemplo n.º 47
0
 //called when the editor object is deactivated
 public override void OnEnabled(object caller, EventBase evt)
 {
     base.OnEnabled(caller, evt);
 }
Exemplo n.º 48
0
        public void OnSwitchEvents2(EventBase theEvent)
        {
            ChannelEvent      evt          = theEvent as ChannelEvent;
            EventChannelState channelState = theEvent as EventChannelState;

            if (channelState != null)
            {
                Debug.WriteLine("ChannelState: " + channelState.ChannelInfo.State + " " + channelState.Caller.UserName +
                                " " + channelState.Caller.DestinationNumber);
            }
            else if (evt != null && evt.ChannelInfo != null)
            {
                Debug.WriteLine("ChannelEvent: " + evt.Name + " " + evt.ChannelInfo.Address);
            }
            if (evt != null)
            {
                // CHANNEL_ANSWER, No originator = new outgoing call.
                // ChannelName = the one who makes the call
                if (evt is EventChannelAnswer)
                {
                    EventChannelAnswer e = (EventChannelAnswer)evt;
                    if (e.Originator.CallerIdName != string.Empty)
                    {
                        Debug.WriteLine("Skipping emoty ChannelAnswer");
                        return; // We do only want empty ones.
                    }

                    if (!IsExternalNumber(evt.ChannelInfo.Address))
                    {
                        Debug.WriteLine("triggering CallState.Alerting");
                        TriggerCallState(evt.ChannelInfo.Address, e.UniqueId, CallState.Alerting,
                                         e.Caller.DestinationNumber);
                    }
                }

                // CHANNEL_OUTGOING, Event for Alerting/Offering
                // Originator = the one calling
                // ChannelName = the one getting called.
                else if (evt is EventChannelOutgoing)
                {
                    EventChannelOutgoing e = (EventChannelOutgoing)evt;
                    if (!IsExternalNumber(evt.ChannelInfo.Address))
                    {
                        Debug.WriteLine("triggering CallState.Offering");
                        TriggerCallState(evt.ChannelInfo.Address, e.UniqueId, CallState.Offering, e.Originator.UserName);
                    }
                    if (!IsExternalNumber(e.Originator.UserName))
                    {
                        Debug.WriteLine("triggering CallState.Alerting");
                        TriggerCallState(e.Originator.UserName, e.Originator.UniqueId, CallState.Alerting,
                                         e.ChannelInfo.Address);
                    }
                }

                else if (evt is EventChannelBridge)
                {
                    EventChannelBridge e = (EventChannelBridge)evt;
                    if (!IsExternalNumber(evt.ChannelInfo.Address))
                    {
                        Debug.WriteLine("triggering CallState.Connected");
                        TriggerCallState(evt.ChannelInfo.Address, e.UniqueId, CallState.Connected,
                                         e.Caller.DestinationNumber);
                    }

                    // Trigger destination
                    if (!IsExternalNumber(e.Caller.DestinationNumber) && e.Originator.ChannelName != string.Empty)
                    {
                        Debug.WriteLine("triggering CallState.Connected");
                        TriggerCallState(ChannelDestination(e.Originator.ChannelName), e.UniqueId, CallState.Connected,
                                         e.ChannelInfo.Address);
                    }
                }

                else if (evt is EventChannelDestroy)
                {
                    EventChannelDestroy e = (EventChannelDestroy)evt;
                    Debug.WriteLine("triggering CallState.Disconnected");
                    TriggerCallState(evt.ChannelInfo.Address, e.UniqueId, CallState.Disconnected,
                                     e.Originator.DestinationNumber);
                }
            }
        }
Exemplo n.º 49
0
 public override void UseTile(EventBase targetEvent)
 {
     this.targetEvent = targetEvent;
     StartCoroutine(ThunderProcess());
 }
Exemplo n.º 50
0
        public void OnSwitchEvents(EventBase theEvent)
        {
            if (theEvent is EventPresenceIn)
            {
                EventPresenceIn ep = (EventPresenceIn)theEvent;
                //Channel-State: CS_ROUTING
                //Channel-Name: sofia/default/jonas%40192.168.1.102%3A5070
                //Unique-ID: 2f87ba27-2f71-d64d-8c64-9966ee894eac
                //Call-Direction: inbound
                //Answer-State: ringing
                //Event-Name: PRESENCE_IN
                CallState state       = CallState.Unknown;
                string    destination = string.Empty;
                if (ep.ChannelState.ChannelInfo.State == ChannelState.Routing)
                {
                    if (IsInbound(ep))
                    {
                        state       = CallState.Alerting;
                        destination = ep.Caller.DestinationNumber;
                    }
                    else
                    {
                        state       = CallState.Offering;
                        destination = ep.Caller.UserName;
                    }
                }
                else if (ep.ChannelState.ChannelInfo.State == ChannelState.Hangup)
                {
                    state = CallState.Disconnected;
                    if (IsInbound(ep))
                    {
                        destination = ep.Caller.DestinationNumber;
                    }
                    else
                    {
                        destination = ep.Caller.UserName;
                    }
                }
                if (state != CallState.Unknown)
                {
                    TriggerCallState(ep.ChannelState.ChannelInfo.Address, ep.ChannelState.UniqueId, state, destination);
                }
            }
            else if (theEvent is EventChannelAnswer)
            {
                EventChannelAnswer ea = (EventChannelAnswer)theEvent;
                string             destination;
                if (IsInbound(ea))
                {
                    destination = ea.Caller.DestinationNumber;
                }
                else
                {
                    destination = ea.Caller.UserName;
                }

                TriggerCallState(ea.ChannelInfo.Address, ea.UniqueId, CallState.Connected, destination);
            }

            else if (theEvent is EventChannelDestroy)
            {
                EventChannelDestroy e = (EventChannelDestroy)theEvent;
                Debug.WriteLine("triggering CallState.Disconnected");
                TriggerCallState(e.ChannelInfo.Address, e.UniqueId, CallState.Disconnected,
                                 e.Originator.DestinationNumber);
            }
        }
Exemplo n.º 51
0
 public BackgroundColourEvent(EventBase baseInstance)
     : base(baseInstance)
 {
 }
Exemplo n.º 52
0
 protected void ApplyChange(EventBase @event)
 {
     ApplyChange(@event, true);
 }
Exemplo n.º 53
0
    public virtual void UseTile(EventBase targetEvent)
    {

    }
		protected EventSubscriptionBase(EventBase parentEvent, ThreadOption threadOption, ReferenceOption referenceOption)
		{
			Verify.ArgumentNotNull(parentEvent, "parentEvent", out _event);
			IsSubscribed = true;
			ThreadOption = threadOption;
		}
Exemplo n.º 55
0
    //This EditorObject has been Toggled
    public virtual void OnToggle(object caller, EventBase evt)
    {
        switch(_state)
        {
            case EDITOROBJECTSTATES.ACTIVE:

            break;

            case EDITOROBJECTSTATES.INACTIVE:

            break;

            case EDITOROBJECTSTATES.DISABLED:

            break;
        }
    }
Exemplo n.º 56
0
 public OarsServer(EventBase eventBase)
 {
     this.eventBase = eventBase;
 }
Exemplo n.º 57
0
 public override bool InterceptEvent(EventBase ev)
 {
     return(false);
 }
Exemplo n.º 58
0
 public static VesselStateChangedEvent FromVesselInGame(Guid gameId, VesselDto vessel) =>
 new VesselStateChangedEvent(
     EventBase.GetDateIsoString(),
     gameId,
     vessel
     );
Exemplo n.º 59
0
 private void ApplyChange(EventBase @event, bool isNew)
 {
     this.AsDynamic().Apply(@event);
     if (isNew) _changes.Add(@event);
 }
Exemplo n.º 60
0
 public override void PostProcessEvent(EventBase ev)
 {
 }