Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        float distance = Vector3.Distance(target.position, transform.position);

        if (distance <= lookRadius)
        {
            agent.SetDestination(target.position);
            anim.SetBool("running", true);

            if (distance <= agent.stoppingDistance)
            {
                anim.SetBool("running", false);
            }
        }
        if (distance > lookRadius)
        {
            anim.SetBool("running", false);
        }
        if (numero == 1)
        {
            anim.SetTrigger("ataque1");

            GameObject Temporary_Bullet_Handler2;

            Temporary_Bullet_Handler2 = Instantiate(prefab2, spawpoint2.transform.position, spawpoint2.transform.rotation) as GameObject;
            Temporary_Bullet_Handler2.transform.Rotate(Vector3.left * 90);
            Rigidbody Temporary_RigidBody2;
            Temporary_RigidBody2 = Temporary_Bullet_Handler2.GetComponent <Rigidbody>();
            Temporary_RigidBody2.AddForce(transform.forward * speed2);
            Destroy(Temporary_Bullet_Handler2, 10.0f);


            numero = 0;
            sa.SetAudio(Random.Range(41, 43), gameObject.transform);
        }
        if (numero == 2)
        {
            anim.SetTrigger("ataque2");
            GameObject Temporary_Bullet_Handler;

            Temporary_Bullet_Handler = Instantiate(prefab, spawpoint.transform.position, spawpoint.transform.rotation) as GameObject;
            Temporary_Bullet_Handler.transform.Rotate(Vector3.left * 90);
            Rigidbody Temporary_RigidBody;
            Temporary_RigidBody = Temporary_Bullet_Handler.GetComponent <Rigidbody>();
            Temporary_RigidBody.AddForce(transform.forward * speed);
            Destroy(Temporary_Bullet_Handler, 10.0f);

            numero = 0;
            sa.SetAudio(44, gameObject.transform);
        }
    }
Exemplo n.º 2
0
    void Update()
    {
        if (CanIShoot)
        {
            Timer -= Time.deltaTime;
            if ((int)Timer <= 0)
            {
                TimerMax     = Random.Range(3, 10);
                myRandomBall = Random.Range(0, 4);
                switch (myRandomBall)
                {
                case 3:
                    //The Bullet instantiation happens here.
                    GameObject Temporary_Bullet_Handler5;
                    fire.Play(true);
                    explosion.Play(true);
                    FireSFX.PlayOneShot(Boom);
                    Temporary_Bullet_Handler5 = Instantiate(Bullet, Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation) as GameObject;

                    //Sometimes bullets may appear rotated incorrectly due to the way its pivot was set from the original modeling package.
                    //This is EASILY corrected here, you might have to rotate it from a different axis and or angle based on your particular mesh.
                    Temporary_Bullet_Handler5.transform.Rotate(Vector3.left * 90);

                    //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                    Rigidbody Temporary_RigidBody5;
                    Temporary_RigidBody5 = Temporary_Bullet_Handler5.GetComponent <Rigidbody>();

                    //Tell the bullet to be "pushed" forward by an amount set by Bullet_Forward_Force.
                    Temporary_RigidBody5.AddForce(transform.forward * Bullet_Forward_Force);

                    //Basic Clean Up, set the Bullets to self destruct after 10 Seconds, I am being VERY generous here, normally 3 seconds is plenty.
                    Destroy(Temporary_Bullet_Handler5, TProjectile);
                    break;

                case 2:
                    //The Bullet instantiation happens here.
                    GameObject Temporary_Bullet_Handler3;
                    fire.Play(true);
                    explosion.Play(true);
                    FireSFX.PlayOneShot(Boom);
                    Temporary_Bullet_Handler3 = Instantiate(Calice, Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation) as GameObject;

                    //Sometimes bullets may appear rotated incorrectly due to the way its pivot was set from the original modeling package.
                    //This is EASILY corrected here, you might have to rotate it from a different axis and or angle based on your particular mesh.
                    Temporary_Bullet_Handler3.transform.Rotate(Vector3.left * 90);

                    //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                    Rigidbody Temporary_RigidBody3;
                    Temporary_RigidBody3 = Temporary_Bullet_Handler3.GetComponent <Rigidbody>();

                    //Tell the bullet to be "pushed" forward by an amount set by Bullet_Forward_Force.
                    Temporary_RigidBody3.AddForce(transform.forward * Bullet_Forward_Force);

                    //Basic Clean Up, set the Bullets to self destruct after 10 Seconds, I am being VERY generous here, normally 3 seconds is plenty.
                    Destroy(Temporary_Bullet_Handler3, TProjectile);
                    break;

                case 1:
                    //The Bullet instantiation happens here.
                    GameObject Temporary_Bullet_Handler;
                    fire.Play(true);
                    explosion.Play(true);
                    FireSFX.PlayOneShot(Boom);
                    Temporary_Bullet_Handler = Instantiate(Bullet, Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation) as GameObject;

                    //Sometimes bullets may appear rotated incorrectly due to the way its pivot was set from the original modeling package.
                    //This is EASILY corrected here, you might have to rotate it from a different axis and or angle based on your particular mesh.
                    Temporary_Bullet_Handler.transform.Rotate(Vector3.left * 90);

                    //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                    Rigidbody Temporary_RigidBody;
                    Temporary_RigidBody = Temporary_Bullet_Handler.GetComponent <Rigidbody>();

                    //Tell the bullet to be "pushed" forward by an amount set by Bullet_Forward_Force.
                    Temporary_RigidBody.AddForce(transform.forward * Bullet_Forward_Force);

                    //Basic Clean Up, set the Bullets to self destruct after 10 Seconds, I am being VERY generous here, normally 3 seconds is plenty.
                    Destroy(Temporary_Bullet_Handler, TProjectile);
                    break;

                case 0:
                    //The Bullet instantiation happens here.
                    GameObject Temporary_Bullet_Handler2;
                    fire.Play(true);
                    explosion.Play(true);
                    FireSFX.PlayOneShot(Boom);
                    Temporary_Bullet_Handler2 = Instantiate(Bomb, Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation) as GameObject;

                    //Sometimes bullets may appear rotated incorrectly due to the way its pivot was set from the original modeling package.
                    //This is EASILY corrected here, you might have to rotate it from a different axis and or angle based on your particular mesh.
                    Temporary_Bullet_Handler2.transform.Rotate(Vector3.left * 90);

                    //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                    Rigidbody Temporary_RigidBody2;
                    Temporary_RigidBody2 = Temporary_Bullet_Handler2.GetComponent <Rigidbody>();

                    //Tell the bullet to be "pushed" forward by an amount set by Bullet_Forward_Force.
                    Temporary_RigidBody2.AddForce(transform.forward * Bullet_Forward_Force);

                    //Basic Clean Up, set the Bullets to self destruct after 10 Seconds, I am being VERY generous here, normally 3 seconds is plenty.
                    Destroy(Temporary_Bullet_Handler2, TProjectile);
                    break;

                default:
                    break;
                }
                Timer = TimerMax;
            }
        }
        if (GetComponentInParent <Timer>().tgame <= 1)
        {
            CanIShoot = false;
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (gm.allowFireTemp == true)
        {
            allowFire        = true;
            gm.allowFireTemp = false;
        }

        if (ld.tempBulletSpeed == true)
        {
            Bullet_Forward_Force = 1000f;
            ld.tempBulletSpeed   = false;
        }

        //Check if Character
        if (Character)
        {
            //shotgun
            if (shotgun)
            {
                gm.currentDamage = shotgunDamage * ld.tempBulletDamageMult;
                if (ld.tempFireChange == true)
                {
                    shotgunAttackSpeed = shotgunAttackSpeed - (shotgunAttackSpeed * ld.attackSpeedChange);
                    ld.tempFireChange  = false;
                }
                if (gm.allowFireFinal == true && allowFire == true && Input.GetKey(KeyCode.Mouse0))
                {
                    effectOfGun.Emit(1);
                    StartCoroutine(WaitASecondShotgun());
                    //bullet 1 transform
                    GameObject Temporary_Bullet_Handler;
                    Temporary_Bullet_Handler = Instantiate(Bullet, Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation) as GameObject;
                    //bullet 2 transform
                    GameObject Temporary_Bullet_Handler2;
                    Temporary_Bullet_Handler2 = Instantiate(Bullet2, Bullet_Emitter_Shotgun.transform.position, Bullet_Emitter_Shotgun.transform.rotation) as GameObject;

                    //bullet 1 rigidbody
                    Rigidbody Temporary_RigidBody;
                    Temporary_RigidBody = Temporary_Bullet_Handler.GetComponent <Rigidbody>();
                    //bullet 2 rigidbody
                    Rigidbody Temporary_RigidBody2;
                    Temporary_RigidBody2 = Temporary_Bullet_Handler2.GetComponent <Rigidbody>();

                    //bullet 1 movement
                    Temporary_RigidBody.AddForce(transform.forward * Bullet_Forward_Force);
                    //bullet 2 movement
                    Temporary_RigidBody2.AddForce(transform.forward * Bullet_Forward_Force);

                    //destroy bullets
                    Destroy(Temporary_Bullet_Handler, 10.0f);
                    Destroy(Temporary_Bullet_Handler2, 10.0f);
                }
            }
            //pistol

            if (pistol)
            {
                gm.currentDamage = pistolDamage * ld.tempBulletDamageMult;
                if (ld.tempFireChange == true)
                {
                    pistolAttackSpeed = pistolAttackSpeed - (pistolAttackSpeed * ld.attackSpeedChange);
                    ld.tempFireChange = false;
                }
                if (gm.allowFireFinal == true && allowFire == true && Input.GetKey(KeyCode.Mouse0))
                {
                    effectOfGun.Emit(1);
                    StartCoroutine(WaitASecondPistol());

                    GameObject Temporary_Bullet_Handler;
                    Temporary_Bullet_Handler = Instantiate(Bullet, Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation) as GameObject;

                    Rigidbody Temporary_RigidBody;
                    Temporary_RigidBody = Temporary_Bullet_Handler.GetComponent <Rigidbody>();


                    Temporary_RigidBody.AddForce(transform.forward * Bullet_Forward_Force);

                    Destroy(Temporary_Bullet_Handler, 10.0f);
                }
            }
            if (m4)
            {
                gm.currentDamage = m4Damage * ld.tempBulletDamageMult;
                if (ld.tempFireChange == true)
                {
                    m4AttackSpeed     = m4AttackSpeed - (m4AttackSpeed * ld.attackSpeedChange);
                    ld.tempFireChange = false;
                }
                if (gm.allowFireFinal == true && allowFire == true && Input.GetKey(KeyCode.Mouse0))
                {
                    effectOfGun.Emit(1);
                    StartCoroutine(WaitASecondM4());

                    GameObject Temporary_Bullet_Handler;
                    Temporary_Bullet_Handler = Instantiate(Bullet, Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation) as GameObject;

                    Rigidbody Temporary_RigidBody;
                    Temporary_RigidBody = Temporary_Bullet_Handler.GetComponent <Rigidbody>();


                    Temporary_RigidBody.AddForce(transform.forward * Bullet_Forward_Force);

                    Destroy(Temporary_Bullet_Handler, 10.0f);
                }
            }
            if (rpg)
            {
                gm.currentDamage = rpgDamage * ld.tempBulletDamageMult;
                if (ld.tempFireChange == true)
                {
                    rpgAttackSpeed    = rpgAttackSpeed - (rpgAttackSpeed * ld.attackSpeedChange);
                    ld.tempFireChange = false;
                }
                if (gm.allowFireFinal == true && allowFire == true && Input.GetKey(KeyCode.Mouse0))
                {
                    effectOfGun.Emit(1);
                    StartCoroutine(WaitASecondrpg());

                    GameObject Temporary_Bullet_Handler;
                    Temporary_Bullet_Handler = Instantiate(Bullet, Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation) as GameObject;

                    Rigidbody Temporary_RigidBody;
                    Temporary_RigidBody = Temporary_Bullet_Handler.GetComponent <Rigidbody>();


                    Temporary_RigidBody.AddForce(transform.forward * Bullet_Forward_Force);

                    Destroy(Temporary_Bullet_Handler, 10.0f);
                }
            }
        }
    }
Exemplo n.º 4
0
    //&& Time.time > nextFire
    // Update is called once per frame
    public void Update()
    {
        if (Time.time > nextFire && AmmoShot == true)
        {
            FlakShell.SetActive(true);
        }
        if (Ammo >= 60)
        {
            Ammo = 60;
            SetCountAmmo();
        }
        if (Ammo <= 0)
        {
            FlakShell.SetActive(false);
            Ammo = 0;
            SetCountAmmo();
            AmmoShot = false;
        }
        if (Input.GetButtonDown("Pause"))
        {
            paused         = !paused;
            Time.timeScale = paused ? 0 : 1;
            if (Input.GetMouseButtonDown(0) && paused == true)
            {
                Ammo -= 0;
            }
            if (paused == true)
            {
                AmmoShot         = false;
                Cursor.lockState = CursorLockMode.None;
                Cursor.visible   = true;
                CursorCrosshair.SetActive(false);
                OptionsMenu.SetActive(true);
                FlakCannonGun.SetActive(false);
                pauseText.text = "Game Paused";
                levelMusic.Pause();
            }
            else
            {
                OptionsMenu.SetActive(false);
                ConfirmMenu.SetActive(false);
                AudioMenu.SetActive(false);
                VideoMenu.SetActive(false);
                ControlsMenu.SetActive(false);
                CursorCrosshair.SetActive(true);
                FlakCannonGun.SetActive(true);
                AmmoShot         = true;
                Cursor.visible   = false;
                Cursor.lockState = CursorLockMode.Locked;
                Cursor.visible   = false;
                pauseText.text   = "";
                levelMusic.Play();
            }
        }
        if (Input.GetMouseButton(0) && Time.time > nextFire && AmmoShot == true)
        {
            FlakShell.SetActive(false);
            recoilComponent.StartRecoil(0.2f, -10f, 10f);
            Ammo -= 1;
            SetCountAmmo();
            nextFire = Time.time + fireRate;

            muzzleFlashEnabled = true;
            //nextFire = Time.time + fireRate;
            Shoot.Play();
            RandomizeForce();

            GameObject Temporary_Bullet_Handler;
            Temporary_Bullet_Handler = Instantiate(ShellBullet, Bullet_Emitter1.transform.position, Bullet_Emitter1.transform.rotation) as GameObject;
            Temporary_Bullet_Handler.transform.Rotate(Vector3.left * 90);
            Rigidbody Temporary_RigidBody;
            Temporary_RigidBody = Temporary_Bullet_Handler.GetComponent <Rigidbody>();
            Temporary_RigidBody.AddForce(CameraPosition.transform.forward * Bullet_Forward_Force1);
            Temporary_RigidBody.AddForce(CameraPosition.transform.right * Bullet_Side_Force1);
            Temporary_RigidBody.AddForce(CameraPosition.transform.up * Bullet_Up_Force1);
            Destroy(Temporary_Bullet_Handler, 10.0f);

            GameObject Temporary_Bullet_Handler2;
            Temporary_Bullet_Handler2 = Instantiate(ShellBullet, Bullet_Emitter2.transform.position, Bullet_Emitter2.transform.rotation) as GameObject;
            Temporary_Bullet_Handler2.transform.Rotate(Vector3.left * 90);
            Rigidbody Temporary_RigidBody2;
            Temporary_RigidBody2 = Temporary_Bullet_Handler2.GetComponent <Rigidbody>();
            Temporary_RigidBody2.AddForce(CameraPosition.transform.forward * Bullet_Forward_Force2);
            Temporary_RigidBody2.AddForce(CameraPosition.transform.right * Bullet_Side_Force2);
            Temporary_RigidBody2.AddForce(CameraPosition.transform.up * Bullet_Up_Force2);
            Destroy(Temporary_Bullet_Handler2, 10.0f);

            GameObject Temporary_Bullet_Handler3;
            Temporary_Bullet_Handler3 = Instantiate(ShellBullet, Bullet_Emitter3.transform.position, Bullet_Emitter3.transform.rotation) as GameObject;
            Temporary_Bullet_Handler3.transform.Rotate(Vector3.left * 90);
            Rigidbody Temporary_RigidBody3;
            Temporary_RigidBody3 = Temporary_Bullet_Handler3.GetComponent <Rigidbody>();
            Temporary_RigidBody3.AddForce(CameraPosition.transform.forward * Bullet_Forward_Force3);
            Temporary_RigidBody3.AddForce(CameraPosition.transform.right * Bullet_Side_Force3);
            Temporary_RigidBody3.AddForce(CameraPosition.transform.up * Bullet_Up_Force3);
            Destroy(Temporary_Bullet_Handler3, 10.0f);

            GameObject Temporary_Bullet_Handler4;
            Temporary_Bullet_Handler4 = Instantiate(ShellBullet, Bullet_Emitter4.transform.position, Bullet_Emitter4.transform.rotation) as GameObject;
            Temporary_Bullet_Handler4.transform.Rotate(Vector3.left * 90);
            Rigidbody Temporary_RigidBody4;
            Temporary_RigidBody4 = Temporary_Bullet_Handler4.GetComponent <Rigidbody>();
            Temporary_RigidBody4.AddForce(CameraPosition.transform.forward * Bullet_Forward_Force4);
            Temporary_RigidBody4.AddForce(CameraPosition.transform.right * Bullet_Side_Force4);
            Temporary_RigidBody4.AddForce(CameraPosition.transform.up * Bullet_Up_Force4);
            Destroy(Temporary_Bullet_Handler4, 10.0f);


            GameObject Temporary_Bullet_Handler5;
            Temporary_Bullet_Handler5 = Instantiate(ShellBullet, Bullet_Emitter5.transform.position, Bullet_Emitter5.transform.rotation) as GameObject;
            Temporary_Bullet_Handler5.transform.Rotate(Vector3.left * 90);
            Rigidbody Temporary_RigidBody5;
            Temporary_RigidBody5 = Temporary_Bullet_Handler5.GetComponent <Rigidbody>();
            Temporary_RigidBody5.AddForce(CameraPosition.transform.forward * Bullet_Forward_Force5);
            Temporary_RigidBody5.AddForce(CameraPosition.transform.right * Bullet_Side_Force5);
            Temporary_RigidBody5.AddForce(CameraPosition.transform.up * Bullet_Up_Force5);
            Destroy(Temporary_Bullet_Handler5, 10.0f);
        }
        if (Ammo <= 10)
        {
            FlakcountAmmo.color = new Color(Mathf.Sin(Time.time * 10), 0f, 0f, 1.0f);
        }
        else if (Ammo >= 11)
        {
            FlakcountAmmo.color = new Color(1f, 1f, 1f, 1f);
        }
        if (muzzleFlashEnabled == true)
        {
            FlakShell.SetActive(false);
            MuzzleFlashObject.transform.Rotate(Random.Range(0, 90), Random.Range(0, 90), Random.Range(0, 90));
            MuzzleFlashObject.SetActive(true);
            muzzleFlashTimer -= Time.deltaTime;
        }
        if (muzzleFlashTimer <= 0)
        {
            MuzzleFlashObject.SetActive(false);
            muzzleFlashEnabled = false;
            muzzleFlashTimer   = muzzleFlashTimerStart;
        }
        if (whiteScreenFlashEnabled == true)
        {
            whiteScreen.SetActive(true);
            whiteScreenFlashTimer -= Time.deltaTime;
        }
        if (whiteScreenFlashTimer <= 0)
        {
            whiteScreen.SetActive(false);
            whiteScreenFlashEnabled = false;
            whiteScreenFlashTimer   = whiteScreenFlashTimerStart;
        }
    }