/// <summary> /// Adds the health crate. /// </summary> public void addHealthCrate(GameObject zombieSpawner, int _difficulty) { int newDifficulty = _difficulty; //what the difficulty currently is GameObject goZ = (GameObject)Instantiate(Resources.Load("HealthBox")); //Instantiate the zombie prefab from resources //Assign to an enemyManager //1:Randomly choose an enemyManager es = GameObject.FindGameObjectsWithTag("Spawner"); //Es now contains all of the enemy spawners int emi = (int)Random.Range(0, es.Length); //stands for enemy manager index //2:Set parent child relationship Transform pT = es[emi].transform; //pt stands for parent transform goZ.transform.parent = pT; Vector3 spawnPos = zombieSpawner.transform.position; ///goZ.transform.position.x += es[emi].transform.localScale.x; ///goZ.transform.position.y += es[emi].transform.localScale.y; goZ.transform.position = spawnPos; DestroyableObject ZAI = goZ.GetComponent <DestroyableObject>(); //get words for this zombie. Upgrades knows the difficulty settting so it can effectively determine //how many words to give numWords = Difficulty_difficulty.getNumWords(); ZAI.setWords(dictionary.pickWords(int_difficulty, numWords * 10)); ZAI.setStats(int_difficulty, numWords); ZAI.setMeshWord(); }