Ejemplo n.º 1
0
    public void AddBalls()
    {
        int   randomind = Random.Range(0, 5);
        float shift     = Random.Range(-2f, 2f);

        BallScriptNew ball = Instantiate(BallPrefab, new Vector3(shift, 8, 0), Quaternion.identity, Balls).GetComponent <BallScriptNew>();

        ball.main            = this;
        ball.gameObject.name = $"{BallCount}";

        ball.SetColor(randomind);


        Adds = true;

        BallCount--;

        if (BallCount > 0)
        {
            StartCoroutine(AddsBalls());
        }
        else
        {
            Adds = false;
        }
    }
Ejemplo n.º 2
0
    void FindBalls(Transform trans)
    {
        Collider2D[] contacts = Physics2D.OverlapCircleAll(trans.position, 0.45f);

        foreach (var otherBall in contacts)
        {
            if (otherBall.gameObject.tag == "Ball")
            {
                BallScriptNew ballz = otherBall.gameObject.GetComponent <BallScriptNew>();

                if (ballz.ID == ID)
                {
                    if (!BallsContant.Contains(ballz))
                    {
                        BallsContant.Add(ballz);
                    }
                }
            }
        }
    }