예제 #1
0
    public void Shoot()
    {
        if (ammoTracker.shootUpdate())          // if enough ammo to shoot
        {
            soundSource.clip = shootSound;
            soundSource.Play();

            RaycastHit hit;
            if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit))                // see if raycast hit an object
            {
                Debug.Log(hit.transform.name);

                ZombieBehavior target = hit.transform.GetComponent <ZombieBehavior> ();
                if (target != null)                    // check if object hit was a zombie
                {
                    target.TakeDamage(damage);
                }
                ZombieBehaviorGroundPlane target2 = hit.transform.GetComponent <ZombieBehaviorGroundPlane> ();
                if (target2 != null)
                {
                    target2.TakeDamage(damage);
                }

                GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));                   // for bullet impact effect
                Destroy(impactGO, 2f);
            }
        }
        else         // no ammo
        {
            soundSource.clip = dryFireSound;
            soundSource.Play();
        }
    }
예제 #2
0
 protected virtual void OnEnable()
 {
     controller = GetComponent <ZombieCtrl>();
     zombieData = controller.zombieData;
     behavior   = GetComponent <ZombieBehavior>();
     behavior.AddStateReceiver(StateChanged);
 }
예제 #3
0
    public void zombieKeyboardInput(GameObject obj)
    {
        ZombieBehavior  z        = obj.GetComponent <ZombieBehavior>();
        MainGameManager instance = (MainGameManager)this.GetComponent <MainGameManager>();

        if (z != null)
        {
            if (Input.GetKeyDown("f"))
            {
                z.GoToTag("Player");
                instance.zombieGroupSize = GameObject.FindGameObjectsWithTag("Zombie").Length;
            }

            if (Input.GetKeyDown("r"))
            {
                z.GoToTag("Human");
                instance.zombieGroupSize = GameObject.FindGameObjectsWithTag("Zombie").Length;
            }

            if (Input.GetKeyDown("b"))
            {
                z.GoToTag("Barricade");
                instance.zombieGroupSize = GameObject.FindGameObjectsWithTag("Zombie").Length;
            }

            if (Input.GetKeyDown("g"))
            {
                z.GoToTag("Window");
                instance.zombieGroupSize = GameObject.FindGameObjectsWithTag("Zombie").Length;
            }
        }
    }
예제 #4
0
    void Update()
    {
        DebugTint d = GetComponent <DebugTint> ();

        if (m_cooldown > 0.0f)
        {
            m_cooldown -= Time.deltaTime;
            if (m_cooldown <= 0.0f)
            {
                m_s_recentlyFocusedHuman = null;
                m_cooldown = 0.0f;
            }
        }
        if (d != null)
        {
            Ray        ray = Camera.main.GetComponent <Camera> ().ScreenPointToRay(Input.mousePosition);
            RaycastHit hit = new RaycastHit();
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider != null && hit.collider.gameObject != null && hit.collider.gameObject.transform != null && hit.collider.gameObject.transform.parent != null)
                {
                    GameObject obj = ZombieBehavior.getRootObject(hit.collider.gameObject.transform.parent.gameObject);
                    if (obj.tag == "Human")
                    {
                        m_cooldown = 0.5f;
                        m_s_recentlyFocusedHuman = obj;
                    }
                }
            }
            d.tintColor = getCrosshairColor();
        }
    }
예제 #5
0
    public void updateScreenText(int itemNumber)
    {
        screenText.Clear();
        screenText.Add(zombieCount().ToString() + " Flesheaters");
        screenText.Add(humanCount().ToString() + " Meals");

        screenText.Add("\nCommanding: " + instance.zombieGroupSize + "\nStalking:");
        string groupsText = "";

        foreach (GameObject z in GameObject.FindGameObjectsWithTag("Zombie"))
        {
            ZombieBehavior zb = z.GetComponent <ZombieBehavior>();
            if (zb != null && zb.taskObject != null)
            {
                string n = zb.taskObject.name;
                if (!groupsText.Contains(n))
                {
                    groupsText = groupsText + "    " + n + " \n";
                }
            }
        }
        screenText.Add(groupsText);
        screenText.Add("\n\n\n" + udg2helpcontrolstext.text);
        string screenTextOut = "";

        for (int i = 0; i < screenText.Count; i++)
        {
            screenTextOut = screenTextOut + "\n" + screenText[i];
        }
        screenText.Add(screenTextOut);
        GUI.contentColor = slowColor();
        GUI.Label(new Rect(10, 10, 700, 400), screenText[screenText.Count - 1]);
    }
예제 #6
0
 void GetZombieBehavior()
 {
     if (ZombieWearingthevest != null)
     {
         _zb = ZombieWearingthevest.GetComponent <ZombieBehavior>();
     }
 }
예제 #7
0
    private void propertiesAcquisition()
    {
        if (Time.timeSinceLevelLoad > time_to_transmit)
        {
            last_transmited_time = Time.timeSinceLevelLoad;
            time_to_transmit     = Time.timeSinceLevelLoad + Random.Range(min_delta_time_to_transmit, max_delta_time_to_transmit);
            GameObject[] zombies = GameObject.FindGameObjectsWithTag("Zombie").OrderBy(go => (go.transform.position - transform.position).magnitude).ToArray();
            foreach (GameObject zombie in zombies)
            {
                if (zombie == null)
                {
                    Debug.Log("zombie is null");
                    continue;
                }
                if ((zombie.transform.position - transform.position).magnitude > zombie_transmission_max_distance)
                {
                    break;
                }
                ZombieBehavior other_zombie_behavior = zombie.GetComponent <ZombieBehavior>();
                if (other_zombie_behavior == null)
                {
                    Debug.Log("zombie ZombieBehavior is null");
                }
                if (other_zombie_behavior.agility > agility)
                {
                    other_zombie_behavior.agility -= transfer_amount;
                    agility += transfer_amount;
                }

                if (other_zombie_behavior.cunning > cunning)
                {
                    other_zombie_behavior.cunning -= transfer_amount;
                    cunning += transfer_amount;
                }

                if (other_zombie_behavior.strength > strength)
                {
                    other_zombie_behavior.strength -= transfer_amount;
                    strength += transfer_amount;
                }

                acquisitionZombies.Add(zombie);
                //TODO - ADD visual connection
                // drawLine(transform.position, zombie.transform.position);
            }
        }
        else
        {
            if (Time.timeSinceLevelLoad > last_transmited_time + min_delta_time_to_transmit / 2)
            {
                acquisitionZombies = new List <GameObject>();

                /*foreach (Transform child in line.transform)
                 * {
                 *  GameObject.Destroy(child.gameObject);
                 * }*/
            }
        }
    }
예제 #8
0
    void OnCollisionEnter(Collision collision)
    {
        if (m_impactTarget == null)
        {
            // :BILL: rootColliderObject doesn't play well with nesting child to runtime parents. 10 17 2018
            //note we aren't nested in a parent now, betcause SetParent position error.
            GameObject rootColliderObject = getRootObject(collision.gameObject);
            if (rootColliderObject.tag == "Human")
            {
                HumanBehavior hb = rootColliderObject.GetComponent <HumanBehavior>();
                if (hb != null)
                {
                    hb.handleBulletImpact(collision);
                }
            }
            else if (rootColliderObject.tag == "Zombie")
            {
                ZombieBehavior zb = rootColliderObject.GetComponent <ZombieBehavior>();
                if (zb != null)
                {
                    zb.handleBulletImpact(collision);
                }
            }

            if (rootColliderObject.GetComponent <HealthComponent>() != null)
            {
                m_impactTarget = collision.rigidbody;
                m_lifeTime     = 0.25f;
            }

/*
 *          GameObject childColliderObject = getChildRootObject(collision.gameObject);
 *
 *                      if (childColliderObject.tag == "Human") {
 *                              HumanBehavior hb = childColliderObject.GetComponent<HumanBehavior> ();
 *                              if (hb != null) {
 *                                      hb.handleBulletImpact (collision);
 *                              }
 *                      } else if (childColliderObject.tag == "Zombie") {
 *                              ZombieBehavior zb = childColliderObject.GetComponent<ZombieBehavior> ();
 *                              if (zb != null) {
 *                                      zb.handleBulletImpact (collision);
 *                              }
 *                      }
 *
 *                      if (childColliderObject.GetComponent<HealthComponent> () != null ) {
 *                              m_impactTarget = collision.rigidbody;
 *                              m_lifeTime = 0.25f;
 *                      }
 */
        }

        if (m_impactTarget == null)
        {
            Destroy(gameObject);
        }
    }
예제 #9
0
    private void SpawnRegularZombie(SpawnPoint spawnPoint)
    {
        // Debug.Log("wavestd spawning");
        int randZombieIndex = Random.Range(0, zombies.Length);
        int randZombieHP    = Random.Range(minZombieHP, maxZombieHP);

        GameObject     z      = manager.CreateEnemy(spawnPoint.gameObject, zombies[randZombieIndex]);
        ZombieBehavior zombie = z.GetComponent <ZombieBehavior>();

        zombie.SetHP(randZombieHP);
        CurCountOfZOmbiesOnScreen++;
    }
예제 #10
0
    private void SpawnZombieSpecial(SpawnPoint spawnPoint)
    {
        Debug.Log("wavestd spawning");
        int        randSpecialZombieIndex = Random.Range(0, specialZombies.Length);
        int        randZombieHP           = maxZombieHP + SpecialZombieExtraHitPoints;
        GameObject z = manager.CreateEnemy(spawnPoint.gameObject, specialZombies[randSpecialZombieIndex]);

        _isSpawningSpetialZombie = false;
        ZombieBehavior zombie = z.GetComponent <ZombieBehavior>();

        zombie.SetHP(randZombieHP);
        CurCountOfZOmbiesOnScreen++;
    }
 private void Awake()
 {
     _ZBEH = GetComponent <ZombieBehavior>();
     if (GameSettings.Instance != null)
     {
         _useRootMotion = GameSettings.Instance.IsZombieRootMotionOn;
     }
     else
     {
         Debug.Log("no GameSettings , so defaolt is USE ROOTMOTION");
         _useRootMotion = true;
     }
 }
예제 #12
0
        void zombieTargetUpdate(RaycastHit hit)
        {
            GameObject[] zombies          = GameObject.FindGameObjectsWithTag("Zombie");
            GameObject   commandCandidate = null;
            bool         acceptedTaskFlag = false;

            for (uint i = 0; i < 2; ++i)
            {
                float minSqrDistance = -1.0f;
                foreach (GameObject zombie in zombies)
                {
                    ZombieBehavior              zb = zombie.GetComponent <ZombieBehavior>();
                    HealthComponent             hc = zombie.GetComponent <HealthComponent>();
                    UnityEngine.AI.NavMeshAgent na = zombie.GetComponent <UnityEngine.AI.NavMeshAgent>();
                    if (zb != null && zb.enabled && zb.hasPlayerTask() == acceptedTaskFlag &&
                        hc != null && hc.enabled && !hc.isDead() && na != null && na.enabled)
                    {
                        float sqrDistance = (hit.point - zb.transform.position).sqrMagnitude;
                        if (minSqrDistance == -1.0f || sqrDistance < minSqrDistance)
                        {
                            commandCandidate = zombie;
                            minSqrDistance   = sqrDistance;
                        }
                    }
                }

                if (commandCandidate != null)
                {
                    // add dummy destination marker:
                    UnityEngine.AI.NavMeshPath path = new UnityEngine.AI.NavMeshPath();
                    Vector3 hitPoint = CrosshairBehaviour.getRecentlyFocusedHuman() != null?CrosshairBehaviour.getRecentlyFocusedHuman().transform.position : hit.point;

                    UnityEngine.AI.NavMesh.CalculatePath(commandCandidate.transform.position, hitPoint, UnityEngine.AI.NavMesh.AllAreas, path);
                    if (path.corners.Length > 0)
                    {
                        Vector3    destinationPosition = path.corners[path.corners.Length - 1];
                        GameObject destinationMarker   = (GameObject)Instantiate(MainGameManager.instance.destinationMarker);
                        destinationMarker.transform.position    = new Vector3(destinationPosition.x, destinationPosition.y + 0.01f, destinationPosition.z);
                        destinationMarker.transform.eulerAngles = new Vector3(90.0f, 0.0f, 0.0f);
                        commandCandidate.GetComponent <ZombieBehavior>().setTargetFromRaycastHit(hit);
                    }
                    break;
                }
                else
                {
                    acceptedTaskFlag = !acceptedTaskFlag;
                }
            }
        }
예제 #13
0
    void DestroyDeadEnemy()
    {
        //DebugConsole.print("gm sending MELT");
        GameObject enemy = deadEnemies.Dequeue();

        if (enemy != null)
        {
            ZombieBehavior zb = enemy.GetComponent <ZombieBehavior>();
            if (zb != null)
            {
                zb.CurZombieState = ZombieState.MELTING;
            }
        }
        //enemy.SendMessage("Melt");
    }
예제 #14
0
    public bool turnIntoRagdoll()
    {
        UnityEngine.AI.NavMeshAgent n = GetComponent <UnityEngine.AI.NavMeshAgent>();
        Animator        a             = GetComponent <Animator>();
        HumanBehavior   h             = GetComponent <HumanBehavior>();
        ZombieBehavior  z             = GetComponent <ZombieBehavior>();
        RagdollHelper   r             = GetComponent <RagdollHelper> ();
        HealthComponent hc            = GetComponent <HealthComponent>();

        setCollidersEnabled(true);

        bool result = false;

        if (n != null && a != null && r != null && a.enabled)
        {
            r.ragdolled = true;
            m_time      = 0.0f;
            if (h != null)
            {
                h.die();
                if (!hc.wasKilledBy(null))
                {
                    m_postProcessHumanRagdoll = 1u;
                }
                result = true;
            }
            else if (z != null)
            {
                if (hc.isDead())
                {
                    z.die();
                }
                result = true;
            }
            n.enabled = false;
        }
        return(result);
    }
예제 #15
0
 void Awake()
 {
     _ZBEH = GetComponent <ZombieBehavior>();
 }
예제 #16
0
 private void Awake()
 {
     _ZBEH = GetComponent <ZombieBehavior>();
     rb    = gameObject.GetComponent <Rigidbody>();
     cc    = GetComponent <CapsuleCollider>();
 }
예제 #17
0
    GameObject GenerateUMA(string name)
    {
        // Create a new game object and add UMA components to it

        GameObject GO = new GameObject(name);

        GO.transform.position = this.transform.position;
        //parentAtPosition(GO);


        umaDynamicAvatar = GO.AddComponent <UMADynamicAvatar>();
        umaDynamicAvatar.animationController = animationController;
        GO.AddComponent <RagdollCreatorTest>();
        if (name.Contains("Zombie"))
        {
            ZombieBehavior zbh = GO.AddComponent <ZombieBehavior> ();
            zbh.speedMultiplier = Random.Range(0.5f, 2.5f);
            GO.tag = "Zombie";
            GameObject[] zombies = GameObject.FindGameObjectsWithTag("Zombie");
            GO.name = "Zombie" + zombies.Length;
        }
        else
        {
            HumanBehavior hb = GO.AddComponent <HumanBehavior> ();
            GO.tag = "Human";
            //  GameObject[] humans = GameObject.FindGameObjectsWithTag("Human");
            //GO.name = "Human" + humans.Length;
        }

        GO.AddComponent <UnityEngine.AI.NavMeshAgent> ();
        GO.AddComponent <HealthComponent> ();

        // Initialize Avatar and grab a reference to its data component
        umaDynamicAvatar.Initialize();
        umaData = umaDynamicAvatar.umaData;

        // Attach our generator
        umaDynamicAvatar.umaGenerator = generator;
        umaData.umaGenerator          = generator;

        // Set up slot Array
        umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots];

        // Set up our Morph references
        umaDna         = new UMADnaHumanoid();
        umaTutorialDNA = new UMADnaTutorial();
        umaData.umaRecipe.AddDna(umaDna);
        umaData.umaRecipe.AddDna(umaTutorialDNA);


        if (name.Contains("Female"))
        {
            CreateFemale();
        }
        else
        {
            CreateMale();
        }

        // Generate our UMA
        setupDna(umaDna);
        umaDynamicAvatar.UpdateNewRace();

        if (name.Contains("Human"))
        {
            if (name.Contains("Female"))
            {
                GO.name = createName("Female");
            }
            else
            {
                GO.name = createName("Male");
            }
        }

        return(GO);
    }
예제 #18
0
    //Gamesettings as well
    #endregion

    #region INITandListeners
    void Awake()
    {
        _ZBEH      = GetComponent <ZombieBehavior>();
        _zinfoMesh = GetComponentInChildren <TextMesh>();
    }
예제 #19
0
 void Awake()
 {
     _ZBEH         = GetComponent <ZombieBehavior>();
     _audioManager = GetComponent <UAudioManager>();
 }
예제 #20
0
 // Use this for initialization
 void Start()
 {
     sprt        = this.GetComponent <SpriteRenderer>();
     zb          = this.transform.parent.GetComponent <ZombieBehavior>();
     sprt.sprite = As.sprite;
 }