Ejemplo n.º 1
0
 //On collision with a zombie, grab the zombie's controller from the dictionary and store it in queue
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Zombie")
     {
         ZombieController otherController = zombieLookup.GetFromDictionary(other.name);
         otherController.currentTargetIndex = targetIndex;
         targets.Enqueue(otherController);
     }
 }
Ejemplo n.º 2
0
    void Shoot(RaycastHit hit)
    {
        transform.LookAt(hit.transform);
        ZombieController zombieHit = zombieLookup.GetFromDictionary(hit.transform.name);

        if (zombieHit != null)
        {
            bool targetDead = zombieHit.health.DealDamage(myWeapon.CalculateWeaponDamage(true));
            if (targetDead)
            {
                gameManager.AddCurrency(zombieHit.currencyReward);
            }
        }
    }
Ejemplo n.º 3
0
    //Grabs zombie from pool, setting its status to alive and placing it on spawner
    public void SpawnZombie()
    {
        //Grab zombie game object from pool and set its position to this spawner and set the object as active
        GameObject newZombie = zombiePool.GetZombie();

        newZombie.transform.position = new Vector3(transform.position.x, transform.position.y + 2f, transform.position.z);
        newZombie.SetActive(true);

        //Then grab its controller from the zombie lookup and recalculate max health based on player level
        ZombieController newZombieController = zombieLookup.GetFromDictionary(newZombie.name);

        newZombieController.health.CalculateMaxHealth();

        //Finally instruct zombie to reset its max health and status to alive
        newZombieController.health.SetAlive();
    }