Exemplo n.º 1
0
    //"recebe" uma poção no calderão e ajusta a pontuação de acordo
    private void ReceivePotion(PotColi potion)
    {
        int potionType  = (int)potion.potionType;
        int throwerTeam = potion.getThrower();

        if (gameEnd || throwerTeam < 0)
        {
            return;
        }
        switch (victoryCondition)
        {
        case VictoryCondition.PotionSequence:

            //K: por enquanto está sendo feito este cast de enum pra int, o que é válido e seguro. Porém, seria mais organizado mudar tudo logo
            //J: se a orbe jogada é o objetivo atual do time, marca ponto. Também impede erros caso uma orbe spawne dentro do poço
            if (potionType == objective[teamObjIndex[throwerTeam]])
            {
                if (potionType == objective[teamObjIndex[throwerTeam]])
                {
                    teamObjIndex[throwerTeam]++;
                    Debug.Log("team " + throwerTeam + " scores!");
                }
            }
            break;

        case VictoryCondition.FirstToMaxPoints:
            teamPoints[throwerTeam] += potion.pointValueOnCauldron;
            break;

        default:
            Debug.LogError("Victory condition not implemented!");
            break;
        }

        if (HasWonGame(throwerTeam))
        {
            Debug.Log("team " + throwerTeam + " wins!");
            gameEnd        = true;
            victoriousTeam = throwerTeam;
        }
    }