Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        Check();
        foreach (float chairValues in chairValue)
        {
            totalrate += chairValues;
        }
        if (!allfalse)
        {
            total.gameObject.SetActive(false);
        }
        else
        {
            total.gameObject.SetActive(true);
        }
        totalrate = totalrate / (chairs.Length * 2);
        if (total.value == total.maxValue)
        {
            isRunning = false;
            StopCoroutine(begin);
            total.value = 0;
            totalrate   = 0f;
            Bells.Instance.ChangeLife(false);
//			foreach (GameObject chair in chairs)
//			{
//				Chair chairscript = chair.GetComponent<Chair> ();
//				chairscript.DestroyStudent ();
//			}
            for (int i = 0; i < chairs.Length; i++)
            {
                Chair chairscript = chairs [i].GetComponent <Chair> ();
                if (chairscript.student != null)
                {
                    Debug.Log("Destroyed " + i + " Table.");
                    chairscript.DestroyStudent();
                }
            }
        }
//		if (seatedNum != 0)
//		{
//			total.gameObject.SetActive (true);
//		}
//		else
//		{
//			total.gameObject.SetActive (false);
//		}
//		foreach (GameObject chair in chairs)
//		{
//			if (chair.GetComponent<Chair> ().student != null)
//			{
//				x++;
//				if (x > 1)
//				{
//					onlyOne = false;
//				}
//				else if (x <= 1)
//				{
//					onlyOne = true;
//				}
//			}
//		}
//		if (seatedNum > 0)
//		{
//			isRunning = true;
//		}
    }