Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (_alive)
        {
            timer += Time.deltaTime;

            if (timer >= wanderTimer)
            {
                Vector3 newPos = RandomNavSphere(transform.position, wanderRadius, -1);
                agent.SetDestination(newPos);
                anim.SetBool("isIdle", false);
                anim.SetBool("isWalking", true);
                timer = 0;
            }

            if (transform.position.y < -1)
            {
                Destroy(this.gameObject);
                GameObject s  = GameObject.FindGameObjectWithTag("Respawn");
                Spawning   sp = s.GetComponent <Spawning> ();
                sp.decrementCounter();
            }

            anim.SetBool("isWalking", false);
            anim.SetBool("isIdle", true);
        }
    }
Beispiel #2
0
    // Use this for initialization

    public void ReactToHit()
    {
        if (shotcounter == 1)
        {
            Shooting behavior = GetComponent <Shooting> ();
            if (behavior != null)
            {
                behavior.SetAlive(false);
            }

            WanderingNPC b = GetComponent <WanderingNPC> ();
            if (b != null)
            {
                b.SetAlive(false);
            }

            GameObject s  = GameObject.FindGameObjectWithTag("Respawn");
            Spawning   sp = s.GetComponent <Spawning> ();
            sp.decrementCounter();


            StartCoroutine(Die());
        }
        else
        {
            shotcounter++;
        }
    }