Пример #1
0
    public void SelectCard(CardInfo selectedCard)
    {
        if (SelectedCards.Contains(selectedCard))
        {
            selectedCard.Selected = false;
            SelectedCards.Remove(selectedCard);
            return;
        }

        if (SelectedCards.Count >= NumberOfChanges && SelectedCards.Count > 0)
        {
            SelectedCards[0].Selected = false;
            SelectedCards.RemoveAt(0);
        }

        selectedCard.Selected = true;
        SelectedCards.Add(selectedCard);
    }
Пример #2
0
        internal void OnCardSelected(ClientCard card)
        {
            Debug.Log(string.Format("-->{0} is selected by clicking", DataService.GetName(card.Data.Code)));
            switch (GameInfo.Instance.CurrentMessage)
            {
            case GameMessage.SelectCounter:
                card.SelectionParam--;
                if ((card.SelectionParam & 0xffff) == 0)
                {
                    card.Selectable = false;
                }
                SelectMin--;
                if (SelectMin == 0)
                {
                    byte[]       response = new byte[SelectableCards.Count * 2];
                    BinaryWriter writer   = new BinaryWriter(new MemoryStream(response));
                    for (int i = 0; i < SelectableCards.Count; ++i)
                    {
                        writer.Write((ushort)((SelectableCards[i].SelectionParam >> 16) - (SelectableCards[i].SelectionParam & 0xffff)));
                    }
                    ResetSelection();
                    MainGame.Instance.SendCToSResponse(response);
                }
                else
                {
                    MainGame.Instance.DuelWindow.ShowSelectHint(
                        string.Format(DataService.SysString(204), SelectMin, DataService.CounterName(CounterToBeSelected)));
                }
                break;

            case GameMessage.SelectCard:
                if (card.Selected)
                {
                    SelectedCards.Remove(card);
                    card.Selected = false;
                }
                else
                {
                    SelectedCards.Add(card);
                    card.Selected = true;
                }
                if ((SelectedCards.Count >= SelectMax) || (SelectedCards.Count == SelectableCards.Count))
                {
                    SendSelectResponse();
                }
                else if (SelectedCards.Count >= SelectMin)
                {
                    Finishable = true;
                    MainGame.Instance.DuelWindow.SetCancelOrFinish(2);
                }
                break;

            case GameMessage.SelectTribute:
                if (card.Selected)
                {
                    SelectedCards.Remove(card);
                    card.Selected = false;
                }
                else
                {
                    SelectedCards.Add(card);
                    card.Selected = true;
                }
                if (SelectedCards.Count == SelectMax || (SelectedCards.Count == SelectableCards.Count))
                {
                    SendSelectResponse();
                    return;
                }
                int acc = 0;
                foreach (var c in SelectedCards)
                {
                    acc += c.SelectionParam;
                }
                if (acc > SelectMin)
                {
                    MainGame.Instance.DuelWindow.SetCancelOrFinish(2);
                    Finishable = true;
                }
                break;

            case GameMessage.SelectSum:
                if (card.Selected)
                {
                    SelectedCards.Remove(card);
                    card.Selected = false;
                }
                else
                {
                    SelectedCards.Add(card);
                    card.Selected = true;
                }
                UpdateSelectSum(spreadingTranforms.Count != 0);
                break;

            case GameMessage.SelectUnSelectCard:
                SelectedCards.Add(card);
                SendSelectResponse();
                break;

            case GameMessage.SortCard:
                //todo impl
                break;

            default: break;
            }
        }