Exemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (GameObject.FindGameObjectsWithTag("Enemy").Length == 0)
     {
         return;
     }
     else
     {
         target = GameObject.FindGameObjectWithTag("Enemy").GetComponent <Transform>();
         Vector3 xpos = new Vector3(target.position.x, 1, 1f);
         transform.position = Vector3.Lerp(transform.position, xpos, 0.1f);
     }
     if (Reloaded == true)
     {
         shoot.Play();
         GameObject TempoBullet;
         TempoBullet = Instantiate(Bullet, Emitter.transform.position, Emitter.transform.rotation) as GameObject;
         TempoBullet.transform.Rotate(Vector3.left * 0);
         Rigidbody TempoRigidBody;
         TempoRigidBody = TempoBullet.GetComponent <Rigidbody>();
         TempoRigidBody.AddForce(transform.forward * BulletSpeed);
         Destroy(TempoBullet, 1.0f);
         StartCoroutine(Reload());
         GetComponent <CameraShaker>().shouldShake = true;
     }
 }
Exemplo n.º 2
0
    public IEnumerator Shoot()
    {
        shootenemy.Play();
        GameObject TempoBullet;

        TempoBullet = Instantiate(Bullet, Emitter.transform.position, Emitter.transform.rotation) as GameObject;
        TempoBullet.transform.Rotate(Vector3.left * 0);
        Rigidbody TempoRigidBody;

        TempoRigidBody = TempoBullet.GetComponent <Rigidbody>();
        TempoRigidBody.AddForce(transform.forward * BulletSpeed * -1);
        Destroy(TempoBullet, 4.0f);
        yield return(new WaitForSeconds(ShootTime));

        CanShoot = true;
    }
Exemplo n.º 3
0
    void Update()
    {
        transform.position = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10f));

        if (Input.GetButton("Fire1") && AbleToShoot == true)
        {
            if (Reloaded == true)
            {
                shoot.Play();
                GetComponent <CameraShaker>().shouldShake = true;
                GameObject TempoBullet;
                TempoBullet = Instantiate(Bullet, Emitter.transform.position, Emitter.transform.rotation) as GameObject;
                TempoBullet.transform.Rotate(Vector3.left * 0);
                Rigidbody TempoRigidBody;
                TempoRigidBody = TempoBullet.GetComponent <Rigidbody>();
                TempoRigidBody.AddForce(transform.forward * BulletSpeed);
                Destroy(TempoBullet, 1.0f);
                StartCoroutine(Reload());
            }
        }

        else if (Input.GetButton("Fire2") && AbleToShoot == true)
        {
            if (Reloaded2 == true)
            {
                middle.Play();
                GetComponent <CameraShaker>().shouldShake = true;
                GameObject TempoBullet2;
                TempoBullet2 = Instantiate(Bullet2, Emitter.transform.position, Emitter.transform.rotation) as GameObject;
                TempoBullet2.transform.Rotate(Vector3.left * 0);
                Rigidbody TempoRigidBody;
                TempoRigidBody = TempoBullet2.GetComponent <Rigidbody>();
                TempoRigidBody.AddForce(transform.forward * BulletSpeed2);
                Destroy(TempoBullet2, 1.0f);
                StartCoroutine(Reload2());
            }
        }

        else if (Input.GetButtonDown("Fire3") && Grenaded == true && AbleToShoot == true)
        {
            mine.Play();
            GetComponent <CameraShaker>().shouldShake = true;
            ThrowGrenade();
            StartCoroutine(GrenadeReload());
        }
    }