コード例 #1
0
        /// <summary>
        /// Called when cards are loaded for a card group
        /// </summary>
        /// <param name="eventData">List of the cards that have changed</param>
        private void CardGroupButtonsChangedHandler(CardGroupButtonsChanged eventData)
        {
            if (_zoneButtons == default)
            {
                return;
            }

            var zoneButtonsFound = new List <ZoneButton>();

            //look through all the zone buttons and if this group of changed (presumably added) buttons contains a match we can use to create the button
            foreach (var zoneButton in _zoneButtons)
            {
                var matchingButton = eventData.Buttons.FirstOrDefault(x => x.Name == zoneButton.Name);
                if (matchingButton == default)
                {
                    continue;
                }

                //we'll need to remove this once we are done, so we don't keep trying to add it
                zoneButtonsFound.Add(zoneButton);

                var cardGroup = _appData.Game.GetCardGroup(matchingButton.CardGroupId);
                var button    = cardGroup.GetButton(matchingButton) as CardImageButton;
                _appData.Game.AddCardToZone(zoneButton.CardGroupId, zoneButton.ZoneIndex, button);
            }

            //once we've loaded this zone button we can stop loading it
            foreach (var zoneButtonFound in zoneButtonsFound)
            {
                _zoneButtons.Remove(zoneButtonFound);
            }
        }
コード例 #2
0
        /// <summary>
        /// Clear the current list of buttons for this card group and replace it with a new list
        /// </summary>
        /// <param name="eventData">Event data containing list of new buttons</param>
        private void CardGroupButtonsChangedHandler(CardGroupButtonsChanged eventData)
        {
            IList <DynamicActionInfo> actionsUpdated = new List <DynamicActionInfo>();

            lock (_cacheLock) {
                var removedActions = _dynamicActionInfoList.Where(x => x.CardGroupId == eventData.CardGroupId).ToList();

                _dynamicActionInfoList.RemoveAll(x => x.CardGroupId == eventData.CardGroupId);

                foreach (var button in eventData.Buttons)
                {
                    var changedAction = new DynamicActionInfo(button);
                    changedAction.UpdateFromCardInfo(button);
                    _dynamicActionInfoList.Add(changedAction);
                    actionsUpdated.Add(changedAction);
                }

                //if we removed in pool buttons that were not replaced, we need to issue an update for them
                foreach (var removedAction in removedActions)
                {
                    if (removedAction.ButtonMode != ButtonMode.Pool)
                    {
                        continue;
                    }

                    if (actionsUpdated.FirstOrDefaultWithContext(removedAction) != default)
                    {
                        continue;
                    }

                    actionsUpdated.Add(new DynamicActionInfo(removedAction));
                }
            }

            PublishChangeEventsForChangedActions(actionsUpdated);
        }