void fire()
    {
        weaponSound = sounds[1];
        RaycastHit hit;

        PS = weapON.GetComponentInChildren <ParticleSystem>();
        if (Ammo.ammo > 0)
        {
            PS.Play();
            if (weaponSound.isPlaying == false)
            {
                weaponSound.Play();
            }
            Ammo.ammo--;
        }
        if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, 100f) && Ammo.ammo != 0)
        {
            if (hit.transform.tag == "enemy")
            {
                zh         = hit.transform.GetComponent <zombieHealth>();
                zh.health -= 10;
            }
        }
        StartCoroutine("Reload");
    }
Beispiel #2
0
// Use this for initialization
    void Start()
    {
        ZH         = GetComponent <zombieHealth>();
        zombieAnim = GetComponent <Animator>();
        nma        = GetComponent <NavMeshAgent>();
        player     = GameObject.Find("character");
    }
Beispiel #3
0
 // Start is called before the first frame update
 void Start()
 {
     theZombieHealthScript         = GetComponent <zombieHealth>();
     animatedRigTransformsChildren = animatedRig.GetComponentsInChildren <Transform>();
     ragdollChildrenTransforms     = ragdollRig.GetComponentsInChildren <Transform>();
     ragdollObject.SetActive(false);
 }
Beispiel #4
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;

        if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, 100f) && Ammo.ammo != 0)
        {
            if (hit.transform.tag == "enemy")
            {
                zh = hit.transform.GetComponent <zombieHealth>();
                if (zh.health == 0)
                {
                    allScore      += 10;
                    scoreText.text = "score : " + allScore;
                    saveScore();
                }
            }
        }
    }
    void fire1shot()
    {
        weaponSound = sounds[2];
        RaycastHit hit;

        PS = weapON.GetComponentInChildren <ParticleSystem>();
        if (Ammo.ammo1shot > 0)
        {
            PS.Play();
            Ammo.ammo1shot--;
            weaponSound.Play();
        }
        if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, 100f) && Ammo.ammo != 0)
        {
            if (hit.transform.tag == "enemy")
            {
                zh         = hit.transform.GetComponent <zombieHealth>();
                zh.health -= 34;
            }
        }
        StartCoroutine("Reload1Weapon");
    }
Beispiel #6
0
    void RaycastSegment(Vector3 start, Vector3 end, Bullet bullet)
    {
        Vector3 direction = end - start;
        float   range     = direction.magnitude;

        ray.origin    = start;
        ray.direction = direction;
        if (Physics.Raycast(ray, out hitInfo, range))
        {
            Debug.DrawLine(ray.origin, hitInfo.point, Color.red, 1.0f);

            target tgt = hitInfo.transform.GetComponent <target>();
            if (tgt != null)
            {
                tgt.damageTake(damage);
            }

            zombieHealth chesttgt = hitInfo.transform.GetComponent <zombieHealth>();
            if (chesttgt != null)
            {
                chesttgt.damageTake(damage);
            }

            hitEffect.transform.position = hitInfo.point;
            hitEffect.transform.forward  = hitInfo.normal;
            hitEffect.Emit(1);

            bullet.tracer.transform.position = hitInfo.point;
            bullet.time = maxLifetime;
        }
        else
        {
            if (bullet.tracer != null)
            {
                bullet.tracer.transform.position = end;
            }
        }
    }
 // Use this for initialization
 void Start()
 {
     CHH = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterHealth>();
     zh  = GetComponent <zombieHealth>();
 }