Esempio n. 1
0
    private void ShootZombieDisease(Vector3 position)
    {
        RaycastHit2D[] hits = Physics2D.CircleCastAll(position, radius * 2, Vector3.zero);
        foreach (RaycastHit2D hit in hits)
        {
            HerbivoreBehaviour herbivore = hit.collider.GetComponent <HerbivoreBehaviour>();
            if (herbivore == null || herbivore.GetComponent <ZombieHerbivoreBehaviour>() != null)
            {
                continue;
            }

            ZombieHerbivoreBehaviour zombie = herbivore.gameObject.AddComponent <ZombieHerbivoreBehaviour>();
            GameObject diseaseEffect        = Instantiate(diseaseEffectPrefab, hit.collider.transform.position, transform.rotation, hit.collider.transform);
            zombie.DiseaseEffect = diseaseEffect;
        }
    }
Esempio n. 2
0
    public void TurnIntoZombie()
    {
        if (isZombie)
        {
            return;
        }

        isZombie = true;
        tag      = "Zombie";
        if (DiseaseEffect != null)
        {
            Destroy(DiseaseEffect);
        }

        HerbivoreBehaviour herbivore = GetComponent <HerbivoreBehaviour>();

        if (herbivore != null)
        {
            Destroy(herbivore);
        }
        age = GetComponent <AgingBehaviour>();
        if (age != null)
        {
            Destroy(age);
        }
        hunger = GetComponent <HungerBehaviour>();
        hunger.HungerDamage = 0;
        reproduce           = GetComponent <ReproductionBehaviour>();
        if (reproduce != null)
        {
            Destroy(reproduce);
        }

        locator    = GetComponent <LocatorBehaviour>();
        eating     = GetComponent <EatingBehaviour>();
        carnivores = GameObject.FindGameObjectWithTag("CarnivoreContainer").transform;

        move       = GetComponent <MovingBehaviour>();
        move.Speed = ZombieSpeed;
        move.Flee  = false;

        transform.parent = GameObject.FindGameObjectWithTag("ZombieContainer").transform;

        GetComponent <Animator>().runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animations/Zombie/ZombieSheet_0");
    }