Exemplo n.º 1
0
    private void EvaluationPhase()
    {
        displayManager.RpcHideAllTimers();
        Dictionary <UInt32, int> numOfSuccessfulDeceptionsPerPlayer = new Dictionary <uint, int>();

        // eval points
        foreach (var choice in choices)
        {
            UInt32 playerId = choice.Key;
            UInt32 answerId = choice.Value;

            //player choose own answer -> -1 point
            if (Utils.ClickedOnOwnAnswer(playerId, answerId, sameAnswers))
            {
                GetPoints(playerId, -1);
                Utils.GetIdentity(playerId).gameObject.GetComponent <Player>().TargetSendNotification(new Notification(Notification.NotificationTypes.bad, "Du hast deine eigene Antwort ausgewählt...", "-" + 1 + " Punkte"));
            }
            //player choose right answer -> +3 points
            else if (answerId == this.netId)
            {
                GetPoints(playerId, 3);
                Utils.GetIdentity(playerId).gameObject.GetComponent <Player>().TargetSendNotification(new Notification(Notification.NotificationTypes.good, "Gut! Du hast die richtige Antwort gewählt!", "+" + 3 + " Punkte"));
            }
            else
            {
                //player choose answer of other player -> other player get +1 point
                GetPoints(answerId, 1);
                if (numOfSuccessfulDeceptionsPerPlayer.ContainsKey(answerId))
                {
                    numOfSuccessfulDeceptionsPerPlayer[answerId]++;
                }
                else
                {
                    numOfSuccessfulDeceptionsPerPlayer.Add(answerId, 0);
                    numOfSuccessfulDeceptionsPerPlayer[answerId]++;
                }

                //all players who gave this anwer get +1 point
                if (sameAnswers.ContainsKey(answerId))
                {
                    foreach (UInt32 p in sameAnswers[answerId])
                    {
                        GetPoints(p, 1);
                    }
                }
            }
        }

        foreach (var p in numOfSuccessfulDeceptionsPerPlayer)
        {
            if (p.Value == 0)
            {
                Utils.GetIdentity(p.Key).gameObject.GetComponent <Player>().TargetSendNotification(new Notification(Notification.NotificationTypes.regular, "Niemand hat auf deine Antwort geklickt.", "+" + 0 + " Punkte"));
            }
            else
            {
                Utils.GetIdentity(p.Key).gameObject.GetComponent <Player>().TargetSendNotification(new Notification(Notification.NotificationTypes.good, "Sehr gut, du hast " + p.Value + " deiner Mitspieler getäuscht", "+" + p.Value + " Punkte"));
            }
        }

        UpdateCards();

        UpdateScoreResultsOverlay(false);
        UpdatePlayerCanvas();

        StartCoroutine(WaitAndShowResults());
    }
Exemplo n.º 2
0
 /// <summary>
 /// Checks wether a player has clicked on there own answer
 /// </summary>
 /// <param name="clicker"> The player who clicked on the answer card </param>
 /// <param name="clickedOn"> The answer card the player clicked on </param>
 /// <param name="sameAnswers"> A dictionary to store all duplicate answers </param>
 /// <returns> If the player gave a duplicate answer </returns>
 /// \author SWT-P_SS_20_Dixit
 public static bool ClickedOnOwnAnswer(UInt32 clicker, UInt32 clickedOn, MultivalDictionary <UInt32, UInt32> sameAnswers) =>
 (clicker == clickedOn) || (sameAnswers.ContainsKey(clickedOn) && sameAnswers[clickedOn].Contains(clicker));