Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (sharedobj.getPlayersCount() != 1)
        {         // مود چند نفره
            if (StartTime >= 0.0f && cancount)
            {
                StartTime -= Time.deltaTime;
                //alarm.SetActive(true);
                //Debug.Log((int) StartTime + "    " + (int)StartTime % 2);
                if (((int)StartTime <= 5) && ((int)StartTime % 2 == 1) && cancount)
                {
                    alarm.SetActive(act);
                    act = !act;
                    //Debug.Log(StartTime);
                }
            }
            else if (StartTime <= 0.0f && !doonce)
            {
                cancount  = false;
                doonce    = true;
                StartTime = 0.0f;
                //Debug.Log(StartTime);
                alarm.SetActive(false);
                EndTime();
            }
        }
        else
        {         // مود تک نفره
            //StartTime = 0.0f;
            float t = Time.time;
            // h = h+ (int)(t/3600);
            // m =m+ (int) ((t % 3600)/60);
            // float s =((t % 3600) % 60);
            m = ((int)t / 60);
            string s = (t % 60).ToString("f2");
            TimerText.GetComponent <Text>().text = m.ToString() + ":" + s;
            //Debug.Log(t);
            if (sharedobj.getCurentNumber() > sharedobj.getCountNum())
            {
                sharedobj.setRecordOnePersonMode(m.ToString() + ":" + s);
            }
        }


        // float t =Time.time - StartTime;
        // Debug.Log(int.Parse( sharedobj.getTimerForEveryone()) + "    " + (int)(t % 60 ) + " sssssssss");
        // string secend = ((t % 60 ) ).ToString("00");
        // if(sharedobj.getTimerForEveryone() == secend ) //5 secend aakhar
        // {
        //  Debug.Log("end");
        //  alarm.SetActive(true);
        //  //alarm.SetActive(!act)	 ;
        //  //act = !act;
        //  // if (int.Parse( sharedobj.getTimerForEveryone()) == ( (int)(t % 60 )))
        //  // {
        //  //  SceneManager.LoadScene("mainpage");
        //  // }
        // }
    }
Пример #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);
        }
    }