コード例 #1
0
ファイル: BusGameController.cs プロジェクト: theorclord/bus
    private bool CheckCardActionGuitar(Card selectedCard, CardType type, int sips)
    {
        StringBuilder actionsToTake = new StringBuilder();
        var           playerFound   = false;

        // The loop when playing the guitar
        var busCreated = false;

        foreach (var p in Players)
        {
            if (p.Hand.Exists(c => c.Value == selectedCard.Value))
            {
                playerFound = true;
                // flag all cards for actions
                switch (type)
                {
                case CardType.Give:
                    // handle give
                    // save player in action queue
                    foreach (Card c in p.Hand)
                    {
                        if (c.Value == selectedCard.Value)
                        {
                            GiveActionPlayers.Add(new PlayerCardPair()
                            {
                                Card = c, Player = p, Sips = sips
                            });
                        }
                    }
                    break;

                case CardType.Take:
                    actionsToTake.AppendLine(p.Name + " skal tage " + sips + " tåre");
                    break;

                case CardType.Bus:
                    // Handle bus
                    PlayersOnBus.Add(p);
                    // create the bus
                    if (!busCreated)
                    {
                        StartBus();
                        busCreated = true;
                    }
                    break;

                default:
                    break;
                }
            }
        }
        SetBusNames();

        ActionText.GetComponent <Text>().text = actionsToTake.ToString();
        return(playerFound);
    }