// Use this for initialization
	void Start () {
//		Debug.Log ("start function ");
		GameObject gC = GameObject.FindGameObjectWithTag("GameController");
		spFood = gC.GetComponent<spawnFood> () as spawnFood;

		outerVolume = GameObject.FindGameObjectWithTag("Growth Volume");
		innerVolume = GameObject.FindGameObjectWithTag("Transition Volume");
		iV = innerVolume.transform.GetComponent<SphereCollider> () as SphereCollider;
		pluto = GameObject.FindGameObjectWithTag ("Player");
		boss = GameObject.FindGameObjectWithTag ("Boss");
		bossSource = boss.GetComponent<AudioSource>();

		attack = boss.GetComponent<bossBehavior> ().attackType;
		hazard = boss.GetComponent<bossBehavior> ().hazardType;
		bossAnimator = boss.GetComponent<bossBehavior> ().findBossAnimator ();

		SphereCollider oV = outerVolume.transform.GetComponent<SphereCollider> () as SphereCollider;
		float max = oV.radius * outerVolume.transform.localScale.x;

		placePluto();

		InvokeRepeating ("hazardTimer", 3f, hazard.GetComponent<attackBehavior>().coolDown);
		InvokeRepeating ("attackTimer", 1f, attack.GetComponent<attackBehavior>().coolDown);

/*		for (int i = 0; i < foodSpawnPodCount; i++){
			spFood.spawnFoodPod (foodPerPod, 3f, innerVolume, outerVolume, minFoodSize, maxFoodSize, foodInitialAngularVelocity, foodTypes);
		}*/

		for (int i =0; i < foodSpawnCount; i++) {
			Vector3 spawnPosition = new Vector3 (0,0,0);
			Vector3 centerPosition = new Vector3 (0,0,0);

			int foodHealth = (int)Random.Range (10, 300);

			GameObject food = foodTypes [Random.Range (0, foodTypes.Length)];
			food.GetComponent<objectHealth> ().instantiateHealth (foodHealth);

			while (spawnPosition == centerPosition) {
//				Debug.Log ("loop is active");
				Vector2 randGen = Random.insideUnitCircle * max;
				Vector3 testPoint = new Vector3 (randGen.x, 0, randGen.y);
				bool test = iV.bounds.Contains (testPoint);
				bool test2 = testNewObjectPosition (food, testPoint, foodHealth/food.GetComponent<objectHealth> ().baseHealth); //assuming base size is 100 here

				if (!test)
				{
//					Debug.Log ("setting Spawn to Test");
					if (test2){
						spawnPosition = new Vector3 (testPoint.x, 0, testPoint.z);
					}
				}
			}

			Quaternion spawnRotation = Random.rotation;
			GameObject actualFood= (GameObject) Instantiate (food, spawnPosition, spawnRotation);
			actualFood.GetComponent<objectHealth> ().instantiateHealth (foodHealth);

			Rigidbody rb = actualFood.GetComponent<Rigidbody> () as Rigidbody;
			rb.velocity = calculateAngularVelocity (actualFood);
//			actualFood.GetComponent<Animator> ().SetTime (((double)(Random.Range (0.0f, 1.0f))));
		}
	}
    // Use this for initialization
    void Start()
    {
//		Debug.Log ("start function ");
        GameObject gC = GameObject.FindGameObjectWithTag("GameController");

        spFood = gC.GetComponent <spawnFood> () as spawnFood;

        outerVolume = GameObject.FindGameObjectWithTag("Growth Volume");
        innerVolume = GameObject.FindGameObjectWithTag("Transition Volume");
        iV          = innerVolume.transform.GetComponent <SphereCollider> () as SphereCollider;
        pluto       = GameObject.FindGameObjectWithTag("Player");
        boss        = GameObject.FindGameObjectWithTag("Boss");
        bossSource  = boss.GetComponent <AudioSource>();

        attack       = boss.GetComponent <bossBehavior> ().attackType;
        hazard       = boss.GetComponent <bossBehavior> ().hazardType;
        bossAnimator = boss.GetComponent <bossBehavior> ().findBossAnimator();

        SphereCollider oV  = outerVolume.transform.GetComponent <SphereCollider> () as SphereCollider;
        float          max = oV.radius * outerVolume.transform.localScale.x;

        placePluto();

        InvokeRepeating("hazardTimer", 3f, hazard.GetComponent <attackBehavior>().coolDown);
        InvokeRepeating("attackTimer", 1f, attack.GetComponent <attackBehavior>().coolDown);

/*		for (int i = 0; i < foodSpawnPodCount; i++){
 *                      spFood.spawnFoodPod (foodPerPod, 3f, innerVolume, outerVolume, minFoodSize, maxFoodSize, foodInitialAngularVelocity, foodTypes);
 *              }*/

        for (int i = 0; i < foodSpawnCount; i++)
        {
            Vector3 spawnPosition  = new Vector3(0, 0, 0);
            Vector3 centerPosition = new Vector3(0, 0, 0);

            int foodHealth = (int)Random.Range(10, 300);

            GameObject food = foodTypes [Random.Range(0, foodTypes.Length)];
            food.GetComponent <objectHealth> ().instantiateHealth(foodHealth);

            while (spawnPosition == centerPosition)
            {
//				Debug.Log ("loop is active");
                Vector2 randGen   = Random.insideUnitCircle * max;
                Vector3 testPoint = new Vector3(randGen.x, 0, randGen.y);
                bool    test      = iV.bounds.Contains(testPoint);
                bool    test2     = testNewObjectPosition(food, testPoint, foodHealth / food.GetComponent <objectHealth> ().baseHealth);        //assuming base size is 100 here

                if (!test)
                {
//					Debug.Log ("setting Spawn to Test");
                    if (test2)
                    {
                        spawnPosition = new Vector3(testPoint.x, 0, testPoint.z);
                    }
                }
            }

            Quaternion spawnRotation = Random.rotation;
            GameObject actualFood    = (GameObject)Instantiate(food, spawnPosition, spawnRotation);
            actualFood.GetComponent <objectHealth> ().instantiateHealth(foodHealth);

            Rigidbody rb = actualFood.GetComponent <Rigidbody> () as Rigidbody;
            rb.velocity = calculateAngularVelocity(actualFood);
//			actualFood.GetComponent<Animator> ().SetTime (((double)(Random.Range (0.0f, 1.0f))));
        }
    }