Exemple #1
0
    private void Init()
    {
        if (_initialize)
        {
            return;
        }

        formatter = GetComponent <ICardFormatter>();
        var actGroup = formatter.ActionGroup;

        if (actGroup != null)
        {
            foreach (ActionEvent ae in actionEvents)
            {
                actGroup.CardActionEvent.AddListener((CardActionData aData) => { if (aData.type == ae.type)
                                                                                 {
                                                                                     ae.actionEvent.Invoke(aData);
                                                                                 }
                                                     });
            }
            actGroup.CardActionEvent.AddListener(afterActionsEvent.Invoke);
        }
        var selGroup = formatter.SelectionGroup;

        if (selGroup != null)
        {
            //TODO: rework - one listener that invoke event for selection
            foreach (SelectionEvent se in selectionEvents)
            {
                selGroup.CardSelectionEvent.AddListener((CardSelectionData sData) => { if (sData.type == se.type && sData.selected)
                                                                                       {
                                                                                           se.selectEvent.Invoke(sData);
                                                                                       }
                                                        });
                selGroup.CardSelectionEvent.AddListener((CardSelectionData sData) => { if (sData.type == se.type && !sData.selected)
                                                                                       {
                                                                                           se.deselectEvent.Invoke(sData);
                                                                                       }
                                                        });
            }
        }
        InitEvent.Invoke();
        _initialize = true;
    }
Exemple #2
0
 private void PrepareActionSelectionGroups(ICardFormatter formatter, ICard card)
 {
     if (formatter.SelectionGroup != null)
     {
         formatter.SelectionGroup.SetChannelForSelections(channelForCardSelection);
         formatter.SelectionGroup.AssignBaseData(new CardSelectionData(_place: this, cardData: card));
         if (selectionsGroups != null)
         {
             formatter.SelectionGroup.RegisterSelectionsInGroups(selectionsGroups);
         }
         formatter.SelectionGroup.ActivateSelections(allowedSelections);
     }
     if (formatter.ActionGroup != null)
     {
         formatter.ActionGroup.SetChannelForActions(channelForCardAction);
         formatter.ActionGroup.AssignBaseData(new CardActionData(_place: this, cardData: card));
         formatter.ActionGroup.ActivateActions(allowedActions);
     }
 }
        public void Draw(XGraphics gfx, XRect bounds, CardData card, PrintOptions options)
        {
            ICardFormatter formatter = formatters[card.GetType()]();

            formatter.Draw(this.context, gfx, bounds, card, options);
        }