예제 #1
0
 private void Notify(BoardEvent boardEvent)
 {
     foreach (Action callback in this.listeners[boardEvent])
     {
         callback.Invoke();
     }
 }
예제 #2
0
        public Board GetByBoardEventAndForeignId(BoardEvent boardEvent, long foreignId)
        {
            var item = DbUtil.Client.CreateDocumentQuery <BoardDO>(CollectionUri)
                       .Where(b => b.BoardEvent.Type == boardEvent.Type && b.BoardEvent.ForeignId == foreignId)
                       .AsEnumerable().FirstOrDefault();

            return(item == null ? null : _mapper.Map <Board>(item));
        }
예제 #3
0
 public Trigger(
     BoardEvent triggerEvent,
     Ability ability,
     BoardEvent?expirationEvent = null,
     bool unlimited             = false)
 {
     TriggerEvent    = triggerEvent;
     Ability         = ability;
     ExpirationEvent = expirationEvent;
     Unlimited       = unlimited;
 }
예제 #4
0
 public void AddListener(string name, Action <EventData> action)
 {
     if (events.ContainsKey(name))
     {
         events[name].action += action;
     }
     else
     {
         events[name] = new BoardEvent(action);
     }
 }
예제 #5
0
        /*
         * Event handling best practice from http://msdn.microsoft.com/en-us/library/w369ty8x.aspx
         */
        protected virtual void OnRaiseBoardEvent(BoardEvent e)
        {
            // Make a temporary copy of the event to avoid possibility of
            // a race condition if the last subscriber unsubscribes
            // immediately after the null check and before the event is raised.
            EventHandler<BoardEvent> handler = RaiseBoardEvent;

            // Event will be null if there are no subscribers
            if (handler != null)
            {
                // Use the () operator to raise the event.
                handler(this, e);
            }
        }
예제 #6
0
 public void When(BoardEvent boardEvent, Action callback)
 {
     this.listeners[boardEvent].Add(callback);
 }
예제 #7
0
 private void BoardMoveEvent(BoardEvent evt)
 {
     ((QuoridorService)_quoridorServiceConnector).SendGameEvent(Session.Instance.Opponent.Id.ToString(), evt);
 }