Ejemplo n.º 1
0
    private void OnTriggerEnter(Collider other)
    {
        Unit unit = other.GetComponent <Unit>();

        if (unit == null)
        {
            return;
        }

        teamScore[(int)unit.GetTeam] += unit.GetCost;

        if (capturingTeam == Team.Neutral)
        {
            if (teamScore[(int)TeamServices.GetOpponent(unit.GetTeam)] == 0)
            {
                capturingTeam = unit.GetTeam;
            }
        }
        else
        {
            if (teamScore[(int)TeamServices.GetOpponent(unit.GetTeam)] > 0)
            {
                ResetCapture();
            }
        }
    }
Ejemplo n.º 2
0
    private void OnTriggerExit(Collider other)
    {
        Unit unit = other.GetComponent <Unit>();

        if (unit == null)
        {
            return;
        }

        teamScore[(int)unit.GetTeam] -= unit.GetCost;
        if (teamScore[(int)unit.GetTeam] == 0)
        {
            Team opponentTeam = TeamServices.GetOpponent(unit.GetTeam);
            if (teamScore[(int)opponentTeam] == 0)
            {
                ResetCapture();
            }
            else
            {
                capturingTeam = opponentTeam;
            }
        }
    }