Esempio n. 1
0
 // Use this for initialization
 void Start()
 {
     instance = this;
     balls    = new List <GameObject>();
     bouncec  = 0;
     size     = 100;
     kash     = 0;
     text     = GameObject.Find("BounceCounter");
     kashText = GameObject.Find("Kash");
 }
Esempio n. 2
0
    public void createBall(float bounciness, float size)
    {
        GameObject obj = Instantiate(prefab, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;

        obj.GetComponent <SpriteRenderer>().color = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f));
        obj.GetComponent <Collider2D>().sharedMaterial.bounciness = bounciness;
        obj.GetComponent <Collider2D>().sharedMaterial.friction   = 1.0f;
        obj.GetComponent <Transform>().localScale = new Vector3(size, size, 1);
        bc = GetComponentInParent <BounceCount>();
        BounceCount.instance.addBall(obj);
        GameObject[] balls = GameObject.FindGameObjectsWithTag("Ball");
        foreach (GameObject ball in balls)
        {
            foreach (GameObject ballx in balls)
            {
                Physics2D.IgnoreCollision(ball.GetComponent <Collider2D>(), ballx.GetComponent <Collider2D>());
            }
        }
    }