public void ZombieAttackedPlayer(WordZombie zombie) { Debug.Log("zombie killed you! " + zombie.GetWord()); print("zombies killed: " + zombieKilled); //call deathevent DeathEvent(); }
// Use this for initialization //spawns zombie and returns public WordZombie SpawnZombie(ZombieInfo info) { Vector3 spawnPoint = Vector3.forward * Radius + Vector3.up * 0.4f; float randomAngle = Random.value * spawnArcAngle - spawnArcAngle / 2f; spawnPoint = Quaternion.Euler(0, randomAngle, 0) * spawnPoint; GameObject thisZombie = Object.Instantiate(ZombiePrefab, spawnPoint, Quaternion.identity) as GameObject; thisZombie.transform.LookAt(GameObject.FindGameObjectWithTag("Player").transform); WordZombie wordZombie = thisZombie.GetComponent <WordZombie> (); wordZombie.SetInfo(info); return(wordZombie); }
// Use this for initialization void OnTriggerEnter(Collider other) { if (other.tag == "Player") { //should tell the game manager that this zombie attacked the player WordZombie zombie = GetComponent <WordZombie>(); GameManager gameManager = GameObject.FindGameObjectWithTag("Game Manager").GetComponent <GameManager>(); if (zombie != null && gameManager != null) { gameManager.ZombieAttackedPlayer(zombie); } else { Debug.Log("word zombie or game manager is null, shouldn't be null"); } } }