void OnTriggerEnter2D(Collider2D other)
    {
        ballMovement = other.GetComponent <BallMovement>();

        if (ballMovement != null && canScore)
        {
            if (team == 1)
            {
                GameManager.instance.AddScore(1);
            }
            else
            {
                GameManager.instance.AddScore(0);
            }

            canScore = false;

            other.gameObject.GetComponent <SpriteRenderer>().enabled            = false;
            other.transform.GetChild(0).GetComponent <SpriteRenderer>().enabled = false;
            other.gameObject.GetComponent <TrailRenderer>().enabled             = false;
            other.transform.position = spawnPoint;
            ballMovement.ResetSpeed();

            StartCoroutine(SpawnDelay(other.transform));
            return;
        }

        GetTarget(other);

        if (target != null)
        {
            Debug.Log("Gottem");
            target.Hit(100, DamageType.physical, Vector2.zero, 0.25f);
        }
    }
示例#2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        ballMovement = other.GetComponent <BallMovement>();
        if (ballMovement != null && canScore)
        {
            points++;
            pointsLeft.text = points.ToString();

            canScore = false;

            other.gameObject.GetComponent <SpriteRenderer>().enabled = false;
            other.gameObject.GetComponent <TrailRenderer>().enabled  = false;
            other.transform.position = spawnPoint;
            ballMovement.ResetSpeed();

            StartCoroutine(SpawnDelay(other.transform));
        }
    }