Exemplo n.º 1
0
    // on TRIGGER enter
    private void OnTriggerEnter(Collider other)
    {
        //se o player colidir com a poção && o player não estiver segurando outra poção,
        PotColi pc = other.GetComponent <PotColi>();

        if (other.gameObject.CompareTag("Potion") && holding == false && pc != null && !other.GetComponent <PotColi>().getThrown())
        {
            //segura esta poção:
            holding = true;
            other.gameObject.transform.SetParent(holdpoint);
            other.gameObject.transform.position = holdpoint.position;
            potionRigidbody = other.gameObject.GetComponent <Rigidbody>();
            //K: pra que mexer no isKinematic?
            potionRigidbody.isKinematic = false;

            potionRigidbody.gameObject.GetComponent <Collider>().enabled = false;

            //J: adquire script da poção arremessada e altera o valor de qual time carrega/arremessa a poção
            potionScript = pc;
            potionScript.setThrower(throwerTeam);
        }
        else if (other.gameObject.CompareTag("Potion") && holding == true && pc != null && !other.GetComponent <PotColi>().getThrown())
        {
            //J: ao colidir com orbe no chão enquanto carrega outra orbe, desativa sua colisão
            if (numIgnore <= 10)
            {
                Debug.Log("Novo Ignorado");
                other.enabled = false;
                numIgnore++;
                ignorados[numIgnore - 1] = other;
            }
        }
    }
Exemplo n.º 2
0
    private void OnTriggerEnter(Collider other)
    {
        //se o objeto colisor for uma poção, trata dos efeitos que ela terá (basicamente contar pontuação)
        PotColi potion = other.GetComponent <PotColi>();

        if (potion != null)
        {
            ReceivePotion(potion);
        }
    }
Exemplo n.º 3
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;
        }
    }