// Update is called once per frame
    void LateUpdate()
    {
        if (sharedobj.getBallsVector3().Count == 0)
        {
            BallVector3_temp = new List <Vector3>();
            BallNames_temp   = new List <string>();
            GameObject[] Ball_temp = new GameObject[GameObject.FindGameObjectsWithTag("Ball").Length];

            Ball_temp = GameObject.FindGameObjectsWithTag("Ball");
            //Debug.Log(Ball_temp[0].name);

            for (int i = 0; i < Ball_temp.Length; i++)
            {
                BallVector3_temp.Add(Ball_temp[i].transform.position);
                //Debug.Log(Ball_temp[i].name);
                BallNames_temp.Add(Ball_temp[i].name);
                Debug.Log(Ball_temp[i].name);
            }
            sharedobj.setBallsVector3(BallVector3_temp);
            sharedobj.setBallsName(BallNames_temp);
        }
    }
Beispiel #2
0
    void Start()
    {
        setshared();
        Balls_temp2 = new GameObject[sharedobj.getCountNum()];

        if (sharedobj.getIsGameStarted())
        {
            BallVector3_temp = new List <Vector3>();
            BallNames_temp   = new List <string>();
            GameObject[] Ball_temp = new GameObject[sharedobj.getBallsVector3().Count];
            BallVector3_temp = sharedobj.getBallsVector3();
            BallNames_temp   = sharedobj.getBallsName();
            for (int i = 0; i < BallVector3_temp.Count; i++)
            {
                ShowAgainBalls(i);
            }

            //Debug.Log(sharedobj.getBalls().Count);
            // Balls_temp2 = sharedobj.getBalls();
            // foreach (GameObject g in Balls_temp2)
            // {
            //  Debug.Log(g.GetComponent<Text>().text);
            // }
            // for (int i = 1; i <= sharedobj.getBalls().Count; i++)
            // {
            //  GameObject newItem = Instantiate(sharedobj.getBalls() as GameObject;
            // }
        }
        else
        {
            numCount = sharedobj.getCountNum();
            //Debug.Log(sharedobj.getIsGameStarted() + "asasasasasasaasasasas");
            // GameObject newItem = Instantiate(itemPrefab) as GameObject;
            // RectTransform r =  newItem.GetComponent<RectTransform>();
            // r.position = new Vector3(100,100,0);
            // Debug.Log(newItem.transform.position);
            //create ();
            //createtest();
            if (numCount > 70)
            {
                width  = 0.9f * width;
                height = 0.9f * height;
                itemPrefab.GetComponent <CircleCollider2D>().radius = width / 2;
            }
            else if (numCount > 130)
            {
                width  = 0.8f * width;
                height = 0.8f * height;
                itemPrefab.GetComponent <CircleCollider2D>().radius = width / 2;
            }
            else if (numCount > 200)
            {
                width  = 0.5f * width;
                height = 0.5f * height;
                itemPrefab.GetComponent <CircleCollider2D>().radius = width / 2;
            }

            if (sharedobj.getIsGameStarted() == false)
            {
                //Debug.Log("te0");
                //Balls_temp = new List<GameObject>();

                //Debug.Log("te1");

                for (int i = 0; i < numCount; i++)
                {
                    CreateWithFor((i + 1).ToString());
                }
                sharedobj.setIsGameStarted(true);

                //Debug.Log("te3");
                //sharedobj.setBalls(Balls_temp);
                //Debug.Log("te4");
                // for (int i = 0; i < numCount; i++)
                // {
                //  Debug.Log("x: " + Balls_temp[i].GetComponent<Transform>().position.x + " y: "
                //              + Balls_temp[i].GetComponent<Transform>().position.y);
                // }
            }
            else
            {
                //SetSpriteBallSelected();
            }
            //Debug.Log("jjjjjjjjjjjjjjjjj :"+ Balls_temp.Count);
        }
    }