// Update is called once per frame
    void Update()
    {
        delayTime = (Random.Range(delayMin, delayMax));

        if (canShoot == true)
        {
            //The Bullet Instantiation happens here.
            GameObject Temporary_Bullet_handler;

            Temporary_Bullet_handler = Instantiate(projectile, gameObject.transform.position, gameObject.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);

            //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 * projectileForce, ForceMode.Impulse);

            //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, projectileLifetime);

            canShoot = false;
            StartCoroutine(ShootDelay());
        }
    }
Esempio n. 2
0
    public void ShootFunction()
    {
        //The Bullet Instantiation happens here.
        GameObject Temporary_Bullet_handler;


        Temporary_Bullet_handler = Instantiate(bullet, gameObject.transform.position, gameObject.transform.rotation) as GameObject;
        Temporary_Bullet_handler.GetComponent <BulletScript> ().myPlayer = gameObject;
        Temporary_Bullet_handler.GetComponent <BulletScript> ().myParticles.startColor = myColor;
        //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);
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        highScoreText.text = topScore.ToString();

        if (menuRef == false)
        {
            if (wallKillsPlayer == true)
            {
                //    wallWarnings.SetActive(true);
                fogFX.SetActive(true);
            }
            if (wallKillsPlayer == false)
            {
                //    wallWarnings.SetActive(false);
                fogFX.SetActive(false);
            }

            if (Input.GetKeyDown(KeyCode.P))
            {
                PauseGame();
            }



            if (paused == true)
            {
                pauseMenu.SetActive(true);
            }
            if (paused == false)
            {
                pauseMenu.SetActive(false);
            }

            scoreText.text = playerScore.ToString();

            if (playerScore > baseHighScore)
            {
                topScore = playerScore;
                newHighScore.SetActive(true);
            }



            rend.material = currentMat;

            Ray        cameraRay   = mainCamera.ScreenPointToRay(Input.mousePosition);
            Plane      groundPlane = new Plane(Vector3.up, Vector3.zero);
            float      rayLength;
            RaycastHit hit;

            if (groundPlane.Raycast(cameraRay, out rayLength) && paused == false)
            {
                Vector3 pointToLook = cameraRay.GetPoint(rayLength);
                Debug.DrawLine(cameraRay.origin, pointToLook, Color.blue);


                //            gunRotate.transform.LookAt(new Vector3(pointToLook.x, transform.position.y, pointToLook.z));
                //mainCamera.transform.LookAt (new Vector3(pointToLook.x,transform.position.y, pointToLook.z));
                gunRotate.transform.LookAt(new Vector3(pointToLook.x, transform.position.y, pointToLook.z));
                gunRotate.transform.rotation = Quaternion.Euler(new Vector3(0, gunRotate.transform.rotation.eulerAngles.y, 0));
            }

            if (Input.GetMouseButtonDown(0) && paused == false)
            {
                //The Bullet Instantiation happens here.
                GameObject Temporary_Bullet_handler;

                Temporary_Bullet_handler = Instantiate(bullet, emitter.transform.position, 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);

                //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(gunRotate.transform.forward * bulletForce, ForceMode.Impulse);

                //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, bulletLifetime);
                myRigidbody.AddForce(gunRotate.transform.forward * -thrust);
            }

            //        if (Input.GetMouseButtonDown(1) && lightMode == true && darkMode == false)
            //        {
            //            lightMode = false;
            //            darkMode = true;
            //        }
            //        if (Input.GetMouseButtonDown(1) && darkMode == true && lightMode == false)
            //        {
            //            darkMode = false;
            //            lightMode = true;
            //        }

            //        if (lightMode == false)
            //        {
            //            darkMode = true;
            //        }
            //        if (darkMode == false)
            //        {
            //            lightMode = true;
            //        }

            if (Input.GetMouseButtonDown(1))
            {
                lightMode = !lightMode;
                darkMode  = !darkMode;
            }

            if (lightMode == true)
            {
                bullet           = lightBullet;
                gameObject.layer = 11;
                currentMat       = lightMat;
                lightParticles.SetActive(true);
                darkParticles.SetActive(false);
            }
            if (darkMode == true)
            {
                bullet           = darkBullet;
                gameObject.layer = 12;
                currentMat       = darkMat;
                darkParticles.SetActive(true);
                lightParticles.SetActive(false);
            }

            if (playerScore <= 100)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 50;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 50;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 50;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 50;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 20;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 20;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 20;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 20;
            }

            if (playerScore > 100 && playerScore <= 200)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 45;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 45;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 45;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 45;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 19;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 19;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 19;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 19;
            }

            if (playerScore > 200 && playerScore <= 300)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 45;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 45;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 45;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 45;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 18;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 18;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 18;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 18;
            }

            if (playerScore > 300 && playerScore <= 400)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 40;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 40;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 40;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 40;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 17;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 17;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 17;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 17;
            }

            if (playerScore > 400 && playerScore <= 500)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 35;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 35;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 35;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 35;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 16;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 16;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 16;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 16;
            }

            if (playerScore > 500 && playerScore <= 600)
            {
                //emitterSide1.SetActive(true);
                //emitterSide2.SetActive(true);
                emitterSide1.GetComponent <EmitterScript>().delayMax = 35;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 35;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 35;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 35;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 15;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 15;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 15;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 15;
            }

            if (playerScore > 600 && playerScore <= 700)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 30;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 30;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 30;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 30;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 14;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 14;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 14;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 14;
            }

            if (playerScore > 700 && playerScore <= 800)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 27;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 27;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 27;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 27;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 13;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 13;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 13;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 13;
            }

            if (playerScore > 800 && playerScore <= 900)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 25;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 25;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 25;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 25;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 13;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 13;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 13;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 13;
            }

            if (playerScore > 900 && playerScore <= 1000)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 25;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 25;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 25;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 25;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 12;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 12;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 12;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 12;
            }

            if (playerScore > 1000 && playerScore <= 1100)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 22;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 22;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 22;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 22;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 12;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 12;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 12;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 12;
            }

            if (playerScore > 1100 && playerScore <= 1200)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 20;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 20;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 20;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 20;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 12;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 12;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 12;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 12;
            }

            if (playerScore > 1200 && playerScore <= 1300)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 20;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 20;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 20;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 20;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 11;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 11;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 11;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 11;
            }

            if (playerScore > 1300 && playerScore <= 1400)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 18;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 18;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 18;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 18;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 11;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 11;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 11;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 11;
            }

            if (playerScore > 1400 && playerScore <= 1500)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 17;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 17;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 17;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 17;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 11;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 11;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 11;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 11;
            }

            if (playerScore > 1500 && playerScore <= 1600)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 15;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 15;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 15;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 15;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 11;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 11;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 11;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 11;
            }

            if (playerScore > 1600 && playerScore <= 1700)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 15;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 15;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 15;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 15;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 10;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 10;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 10;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 10;
            }

            if (playerScore > 1700 && playerScore <= 1800)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 13;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 13;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 13;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 13;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 9;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 9;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 9;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 9;
            }

            if (playerScore > 1800 && playerScore <= 1900)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 12;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 12;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 12;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 12;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 8;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 8;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 8;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 8;
            }

            if (playerScore > 1900 && playerScore <= 2000)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 10;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 7;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 7;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 7;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 7;
            }

            if (playerScore > 2000 && playerScore <= 2100)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 10;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 6;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 6;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 6;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 6;
            }

            if (playerScore > 2100 && playerScore <= 2200)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 10;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 5;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 5;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 5;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 5;
            }

            if (playerScore > 2200 && playerScore <= 2300)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 10;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 4;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 4;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 4;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 4;
            }

            if (playerScore > 2300 && playerScore <= 2400)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 10;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 3;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 3;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 3;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 3;
            }

            if (playerScore > 2400 && playerScore <= 2500)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 10;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 10;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 2;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 2;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 2;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 2;
            }

            if (playerScore > 2500 && playerScore <= 2600)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 9;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 9;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 9;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 9;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 2;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 2;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 2;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 2;
            }

            if (playerScore > 2600 && playerScore <= 2700)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 8;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 8;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 8;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 8;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 2;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 2;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 2;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 2;
            }

            if (playerScore > 2700 && playerScore <= 2800)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 7;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 7;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 7;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 7;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 1;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 1;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 1;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 1;
            }

            if (playerScore > 2800 && playerScore <= 2900)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 6;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 6;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 6;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 6;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 1;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 1;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 1;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 1;
            }

            if (playerScore > 2900 && playerScore <= 3000)
            {
                emitterSide1.GetComponent <EmitterScript>().delayMax = 5;
                emitterSide2.GetComponent <EmitterScript>().delayMax = 5;
                emitterSide3.GetComponent <EmitterScript>().delayMax = 5;
                emitterSide4.GetComponent <EmitterScript>().delayMax = 5;

                emitterSide1.GetComponent <EmitterScript>().delayMin = 0.5f;
                emitterSide2.GetComponent <EmitterScript>().delayMin = 0.5f;
                emitterSide3.GetComponent <EmitterScript>().delayMin = 0.5f;
                emitterSide4.GetComponent <EmitterScript>().delayMin = 0.5f;
            }
        }
//        if (playerScore > Top10Scores[0])
//        {
//            Debug.Log("Score 1 beaten");
//            Top10Scores[9] = Top10Scores[8];
//            Top10Scores[8] = Top10Scores[7];
//            Top10Scores[7] = Top10Scores[6];
//            Top10Scores[6] = Top10Scores[5];
//            Top10Scores[5] = Top10Scores[4];
//            Top10Scores[4] = Top10Scores[3];
//            Top10Scores[3] = Top10Scores[2];
//            Top10Scores[2] = Top10Scores[1];
//            Top10Scores[1] = Top10Scores[0];
//
//            playerScore = Top10Scores[0];
//            newHighScore.SetActive(true);
//
//
//        }
//        if (playerScore > Top10Scores[1] && playerScore <= Top10Scores[0])
//        {
//            Debug.Log("Score 2 beaten");
//
//            Top10Scores[9] = Top10Scores[8];
//            Top10Scores[8] = Top10Scores[7];
//            Top10Scores[7] = Top10Scores[6];
//            Top10Scores[6] = Top10Scores[5];
//            Top10Scores[5] = Top10Scores[4];
//            Top10Scores[4] = Top10Scores[3];
//            Top10Scores[3] = Top10Scores[2];
//            Top10Scores[2] = Top10Scores[1];
//            playerScore = Top10Scores[1];
//            newHighScore.SetActive(true);
//
//
//        }
//        if (playerScore > Top10Scores[2] && playerScore <= Top10Scores[1])
//        {
//            Debug.Log("Score 3 beaten");
//
//            Top10Scores[9] = Top10Scores[8];
//            Top10Scores[8] = Top10Scores[7];
//            Top10Scores[7] = Top10Scores[6];
//            Top10Scores[6] = Top10Scores[5];
//            Top10Scores[5] = Top10Scores[4];
//            Top10Scores[4] = Top10Scores[3];
//            Top10Scores[3] = Top10Scores[2];
//
//            playerScore = Top10Scores[2];
//            newHighScore.SetActive(true);
//
//
//        }
//        if (playerScore > Top10Scores[3] && playerScore <= Top10Scores[2])
//        {
//            Debug.Log("Score 4 beaten");
//
//            Top10Scores[9] = Top10Scores[8];
//            Top10Scores[8] = Top10Scores[7];
//            Top10Scores[7] = Top10Scores[6];
//            Top10Scores[6] = Top10Scores[5];
//            Top10Scores[5] = Top10Scores[4];
//            Top10Scores[4] = Top10Scores[3];
//
//            playerScore = Top10Scores[3];
//            newHighScore.SetActive(true);
//
//
//        }
//        if (playerScore > Top10Scores[4] && playerScore <= Top10Scores[3])
//        {
//            Debug.Log("Score 5 beaten");
//
//            Top10Scores[9] = Top10Scores[8];
//            Top10Scores[8] = Top10Scores[7];
//            Top10Scores[7] = Top10Scores[6];
//            Top10Scores[6] = Top10Scores[5];
//            Top10Scores[5] = Top10Scores[4];
//
//            playerScore = Top10Scores[4];
//            newHighScore.SetActive(true);
//
//
//        }
//        if (playerScore > Top10Scores[5] && playerScore <= Top10Scores[4])
//        {
//            Debug.Log("Score 6 beaten");
//
//            Top10Scores[9] = Top10Scores[8];
//            Top10Scores[8] = Top10Scores[7];
//            Top10Scores[7] = Top10Scores[6];
//            Top10Scores[6] = Top10Scores[5];
//
//            playerScore = Top10Scores[5];
//            newHighScore.SetActive(true);
//
//
//        }
//        if (playerScore > Top10Scores[6] && playerScore <= Top10Scores[5])
//        {
//            Debug.Log("Score 7 beaten");
//
//            Top10Scores[9] = Top10Scores[8];
//            Top10Scores[8] = Top10Scores[7];
//            Top10Scores[7] = Top10Scores[6];
//
//            playerScore = Top10Scores[6];
//            newHighScore.SetActive(true);
//
//
//        }
//        if (playerScore > Top10Scores[7] && playerScore <= Top10Scores[6])
//        {
//            Debug.Log("Score 8 beaten");
//
//            Top10Scores[9] = Top10Scores[8];
//            Top10Scores[8] = Top10Scores[7];
//
//            playerScore = Top10Scores[7];
//            newHighScore.SetActive(true);
//
//
//        }
//        if (playerScore > Top10Scores[8] && playerScore <= Top10Scores[7])
//        {
//            Debug.Log("Score 9 beaten");
//
//            Top10Scores[9] = Top10Scores[8];
//            playerScore = Top10Scores[8];
//            newHighScore.SetActive(true);
//
//
//        }
//        if (playerScore > Top10Scores[9] && playerScore <= Top10Scores[8])
//        {
//            Debug.Log("Score 10 beaten");
//
//            playerScore = Top10Scores[9];
//            newHighScore.SetActive(true);
//
//
//        }

//        if (menuRef == true)
//        {
//            score1Text.text = Top10Scores[0].ToString();
//            score2Text.text = Top10Scores[1].ToString();
//            score3Text.text = Top10Scores[2].ToString();
//            score4Text.text = Top10Scores[3].ToString();
//            score5Text.text = Top10Scores[4].ToString();
//            score6Text.text = Top10Scores[5].ToString();
//            score7Text.text = Top10Scores[6].ToString();
//            score8Text.text = Top10Scores[7].ToString();
//            score9Text.text = Top10Scores[8].ToString();
//            score10Text.text = Top10Scores[9].ToString();
//
//        }
    }
    // Update is called once per frame
    void Update()
    {
        Ray        cameraRay   = mainCamera.ScreenPointToRay(Input.mousePosition);
        Plane      groundPlane = new Plane(Vector3.up, Vector3.zero);
        float      rayLength;
        RaycastHit hit;

        if (groundPlane.Raycast(cameraRay, out rayLength))
        {
            Vector3 pointToLook = cameraRay.GetPoint(rayLength);
            Debug.DrawLine(cameraRay.origin, pointToLook, Color.blue);


//            gunRotate.transform.LookAt(new Vector3(pointToLook.x, transform.position.y, pointToLook.z));
            //mainCamera.transform.LookAt (new Vector3(pointToLook.x,transform.position.y, pointToLook.z));
            gunRotate.transform.LookAt(new Vector3(pointToLook.x, transform.position.y, pointToLook.z));
        }

        if (Input.GetMouseButtonDown(0))
        {
            //The Bullet Instantiation happens here.
            GameObject Temporary_Bullet_handler;

            Temporary_Bullet_handler = Instantiate(bullet, emitter.transform.position, 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);

            //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 * bulletForce, ForceMode.Impulse);

            //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, bulletLifetime);
            myRigidbody.AddForce(gunRotate.transform.forward * -thrust);
        }


//        if (Input.GetMouseButtonDown(1) && lightMode == true && darkMode == false)
//        {
//            lightMode = false;
//            darkMode = true;
//        }
//        if (Input.GetMouseButtonDown(1) && darkMode == true && lightMode == false)
//        {
//            darkMode = false;
//            lightMode = true;
//        }

//        if (lightMode == false)
//        {
//            darkMode = true;
//        }
//        if (darkMode == false)
//        {
//            lightMode = true;
//        }

        if (Input.GetMouseButtonDown(1) && lightMode == true)
        {
            lightMode = false;
            //darkMode = true;
        }
        if (Input.GetMouseButtonDown(1) && lightMode == false)
        {
            //darkMode = false;
            lightMode = true;
        }
    }
Esempio n. 5
0
    // Update is called once per frame
    void Update()
    {
        //if (npc.GetComponent<BasicAI> ().currentTarget != null) {
        //	chaseTarget = npc.GetComponent<BasicAI> ().currentTarget;
        //}

        if (laserHeat >= heatMax)
        {
            laserHeat = heatMax;
            overheat  = true;
        }
        if (laserHeat > heatMin)
        {
            laserHeat -= laserCool * Time.deltaTime;
        }
        if (laserHeat <= heatMin)
        {
            laserHeat = heatMin;
        }
        if (laserHeat <= afterOverheat)
        {
            overheat = false;
        }

        if (team1 == true)
        {
            Bullet.GetComponent <BulletScript> ().forTeam1 = true;
        }
        if (team2 == true)
        {
            Bullet.GetComponent <BulletScript> ().forTeam2 = true;
        }
        if (team1 == false)
        {
            Bullet.GetComponent <BulletScript> ().forTeam1 = false;
        }
        if (team2 == false)
        {
            Bullet.GetComponent <BulletScript> ().forTeam2 = false;
        }

        if (detectedHostile.Count > 0)
        {
            permitShoot = true;
        }
        if (detectedHostile.Count == 0)
        {
            detectedHostile.Clear();
            permitShoot = false;
        }

        //       if (detectedHostile[0] != null && team2 == true)
        //       {
        //           permitShoot = true;
        //       }
        //       if (detectedHostile[0] == null && team2 == true)
        //       {
        //           detectedHostile.Clear();
        //           permitShoot = false;
        //       }

        if (canTrack == true)
        {
            if (trackingEmitter1 != null)
            {
                trackingEmitter1.transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(chaseTarget.transform.position + transform.position), trackRotSpeed * Time.deltaTime);
            }
            if (trackingEmitter2 != null)
            {
                trackingEmitter2.transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(chaseTarget.transform.position + transform.position), trackRotSpeed * Time.deltaTime);
            }
            if (trackingEmitter3 != null)
            {
                trackingEmitter3.transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(chaseTarget.transform.position + transform.position), trackRotSpeed * Time.deltaTime);
            }
            if (trackingEmitter4 != null)
            {
                trackingEmitter4.transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(chaseTarget.transform.position + transform.position), trackRotSpeed * Time.deltaTime);
            }
        }

        if (canTrack == false)
        {
            if (trackingEmitter1 != null)
            {
                trackingEmitter1.transform.rotation = Quaternion.Euler(0, 0, 0);
            }
            if (trackingEmitter2 != null)
            {
                trackingEmitter2.transform.rotation = Quaternion.Euler(0, 0, 0);
            }
            if (trackingEmitter3 != null)
            {
                trackingEmitter3.transform.rotation = Quaternion.Euler(0, 0, 0);
            }
            if (trackingEmitter4 != null)
            {
                trackingEmitter4.transform.rotation = Quaternion.Euler(0, 0, 0);
            }
        }

        if (npc != null && npc.GetComponent <BasicAI>().onOffense == true && permitShoot == true && canShoot == true && overheat == false ||
            npc == null && permitShoot == true && canShoot == true && overheat == false)
        {
            //The Bullet Instantiation happens here.
            GameObject Temporary_Bullet_handler;

//			Temporary_Bullet_handler = Instantiate (Bullet, bulletEmitter1.transform.position, bulletEmitter1.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);

            //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, ForceMode.Impulse);
//
//			//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, bulletLifetime);
            if (bulletEmitter1 != null)
            {
                Temporary_Bullet_handler = Instantiate(Bullet, bulletEmitter1.transform.position, bulletEmitter1.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);

                //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                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, ForceMode.Impulse);

                //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, bulletLifetime);
            }

            if (bulletEmitter2 != null)
            {
                Temporary_Bullet_handler = Instantiate(Bullet, bulletEmitter2.transform.position, bulletEmitter2.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);

                //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                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, ForceMode.Impulse);

                //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, bulletLifetime);
            }
            if (bulletEmitter3 != null)
            {
                Temporary_Bullet_handler = Instantiate(Bullet, bulletEmitter3.transform.position, bulletEmitter3.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);

                //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                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, ForceMode.Impulse);

                //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, bulletLifetime);
            }
            if (bulletEmitter4 != null)
            {
                Temporary_Bullet_handler = Instantiate(Bullet, bulletEmitter4.transform.position, bulletEmitter4.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);

                //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                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, ForceMode.Impulse);

                //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, bulletLifetime);
            }
            if (trackingEmitter1 != null)
            {
                Temporary_Bullet_handler = Instantiate(Bullet, trackingEmitter1.transform.position, trackingEmitter1.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);

                //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                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, ForceMode.Impulse);

                //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, bulletLifetime);
            }
            if (trackingEmitter2 != null)
            {
                Temporary_Bullet_handler = Instantiate(Bullet, trackingEmitter2.transform.position, trackingEmitter2.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);

                //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                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, ForceMode.Impulse);

                //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, bulletLifetime);
            }
            if (trackingEmitter3 != null)
            {
                Temporary_Bullet_handler = Instantiate(Bullet, trackingEmitter3.transform.position, trackingEmitter3.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);

                //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                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, ForceMode.Impulse);

                //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, bulletLifetime);
            }
            if (trackingEmitter4 != null)
            {
                Temporary_Bullet_handler = Instantiate(Bullet, trackingEmitter4.transform.position, trackingEmitter4.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);

                //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                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, ForceMode.Impulse);

                //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, bulletLifetime);
            }

            laserHeat += laserHeatPlus;
            canShoot   = false;
            StartCoroutine(fireDelay());
        }

        detectedHostile.Clear();
    }
Esempio n. 6
0
//	IEnumerator coolLaser ()
//	{
//		laserHeat -= laserHeatCooldown * Time.deltaTime;
//		if (laserHeat <= 0f)
//		{
//			laserHeat = 0f;
//			yield return(coolLaser());
//		}
//	}



    // Update is called once per frame
    void Update()
    {
        if (playerObject.GetComponent <PauseScript>().paused == false)
        {
            if (playerObject.GetComponent <WeaponSelectScript>().activePrimary == gameObject)
            {
                isActiveWeapon = true;
            }
            if (playerObject.GetComponent <WeaponSelectScript>().activePrimary != gameObject)
            {
                isActiveWeapon = false;
            }

            if (team1 == true)
            {
                Bullet.GetComponent <BulletScript>().forTeam1 = true;
                Bullet.GetComponent <BulletScript>().forTeam2 = false;
            }
            if (team2 == true)
            {
                Bullet.GetComponent <BulletScript>().forTeam2 = true;
                Bullet.GetComponent <BulletScript>().forTeam1 = false;
            }



            if (laserHeat >= maxLaserHeat && canShoot == true)
            {
                canShoot   = false;
                overheated = true;
            }
            if (laserHeat == laserHeatMin)
            {
                canShoot   = true;
                overheated = false;
            }


            if (Input.GetMouseButton(0) && canShoot == true && isActiveWeapon == true && instantiateAsChild == false)
            {
                Bullet.GetComponent <BulletScript>().player         = playerObject;
                Bullet.GetComponent <BulletScript>().isPlayerBullet = true;

                //Debug.Log ("Player fired");

                //The Bullet Instantiation happens here.
                GameObject Temporary_Bullet_handler;

                Temporary_Bullet_handler = Instantiate(Bullet, bulletEmitter1.transform.position, bulletEmitter1.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);

                //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, ForceMode.Impulse);

                //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, bulletLifetime);


                Temporary_Bullet_handler = Instantiate(Bullet, bulletEmitter2.transform.position, bulletEmitter2.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);

                //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                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, ForceMode.Impulse);

                //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, bulletLifetime);

                laserHeat = laserHeat + laserHeatPlus;
                StartCoroutine(coolDelay());

                StopCoroutine(coolDelay());
                //			StopCoroutine (coolLaser ());
                cantCooldown = true;
                heatCooldown = false;
                canShoot     = false;
                StartCoroutine(fireDelay());
            }

            if (Input.GetMouseButton(0) && canShoot == true && isActiveWeapon == true && instantiateAsChild == true)
            {
                //Bullet.transform.SetParent(gameObject.transform);
                Bullet.GetComponent <BulletScript>().player = playerObject;


                //Debug.Log ("Player fired");

                //The Bullet Instantiation happens here.
                GameObject Temporary_Bullet_handler;

                Temporary_Bullet_handler = Instantiate(Bullet, (bulletEmitter1.transform.position), Quaternion.identity) 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.parent = bulletEmitter1.transform;

                //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, ForceMode.Impulse);

                //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, bulletLifetime);


                Temporary_Bullet_handler = Instantiate(Bullet, (bulletEmitter2.transform.position), Quaternion.identity) 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.parent = bulletEmitter2.transform;

                //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                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, ForceMode.Impulse);

                //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, bulletLifetime);

                laserHeat = laserHeat + laserHeatPlus;
                StartCoroutine(coolDelay());

                StopCoroutine(coolDelay());
                //			StopCoroutine (coolLaser ());
                cantCooldown = true;
                heatCooldown = false;
                canShoot     = false;
                StartCoroutine(fireDelay());
            }
        }
    }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        if (playerObject.GetComponent <WeaponSelectScript>().activeSecondary == gameObject)
        {
            isActiveWeapon = true;
        }
        if (playerObject.GetComponent <WeaponSelectScript>().activeSecondary != gameObject)
        {
            isActiveWeapon = false;
        }

        if (ammoCount > 0 && overShoot == false)
        {
            canFire = true;
        }

        if (ammoCount <= 0)
        {
            //noAmmoText.enabled = true;
            ammoCount = 0;
            canFire   = false;
        }

        if (missileShootValue > 0)
        {
            missileShootValue -= missileCooldown * Time.deltaTime;
        }
        if (missileShootValue >= missileLimit)
        {
            missileShootValue = missileLimit;
        }
        if (missileShootValue > missileMax)
        {
            canFire   = false;
            overShoot = true;
        }
        if (missileShootValue < missileMax)
        {
            overShoot = false;
        }

        if (playerObject.GetComponent <TargettingScript>().currentTarget != null)
        {
            lockedTarget = playerObject.GetComponent <TargettingScript>().currentTarget;
        }
        if (lockedTarget == null)
        {
            lockedOn = false;
        }


        if (playerObject.GetComponent <TargettingScript>().currentTargetIsFriendly == true)
        {
            targetIsHostile = false;
        }
        if (playerObject.GetComponent <TargettingScript>().currentTargetIsFriendly == false)
        {
            targetIsHostile = true;
        }

        Bullet.GetComponent <MissileScript>().playerMissile = true;

        Bullet.GetComponent <MissileScript> ().seekTarget = lockedTarget;
        if (team1 == true)
        {
            Bullet.GetComponent <MissileScript>().team1 = true;
        }
        if (team2 == true)
        {
            Bullet.GetComponent <MissileScript>().team2 = true;
        }

        if (isActiveWeapon == true)
        {
            weaponHighlight.SetActive(true);
            ammoHighlight.SetActive(true);
        }
        if (isActiveWeapon == false)
        {
            weaponHighlight.SetActive(false);
            ammoHighlight.SetActive(false);
            lockedOn = false;
        }

        if (lockedOn == true && targetIsHostile == true && isActiveWeapon == true)
        {
            lockedTarget.GetComponent <Team2LockOnMe> ().isLockedOnByPlayer = true;
            lockText.SetActive(true);


            Bullet.GetComponent <MissileScript> ().lockedOnTarget = true;
            lockedOnSFX.Play();
        }
        if (lockedOn == false)
        {
            lockedOnSFX.Stop();
            //lockText.SetActive(false);
            //lockedTarget.GetComponent<Team2LockOnMe> ().isLockedOnByPlayer = false;

            Bullet.GetComponent <MissileScript> ().lockedOnTarget = false;
        }
        if (isEmitter1 == true)
        {
            currentEmitter = bulletEmitter1;
        }
        if (isEmitter2 == true)
        {
            currentEmitter = bulletEmitter2;
        }

        if (Input.GetMouseButtonDown(2) && canFire == true && isActiveWeapon == true && alternateEmitters == false)
        {
            Bullet.GetComponent <MissileScript>().playerObject    = playerObject;
            Bullet.GetComponent <MissileScript>().isPlayerMissile = true;
            ammoCount          = ammoCount - ammoSpend;
            missileShootValue += missileIncrease;
            //The Bullet Instantiation happens here.
            GameObject Temporary_Bullet_handler;

            Temporary_Bullet_handler = Instantiate(Bullet, bulletEmitter1.transform.position, bulletEmitter1.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);

            //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, ForceMode.Impulse);

            //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, bulletLifetime);
        }
        if (Input.GetMouseButtonDown(2) && canFire == true && isActiveWeapon == true && alternateEmitters == true)
        {
            Bullet.GetComponent <MissileScript>().playerObject    = playerObject;
            Bullet.GetComponent <MissileScript>().isPlayerMissile = true;
            isEmitter1         = !isEmitter1;
            isEmitter2         = !isEmitter2;
            ammoCount          = ammoCount - ammoSpend;
            missileShootValue += missileIncrease;
            //The Bullet Instantiation happens here.
            GameObject Temporary_Bullet_handler;

            Temporary_Bullet_handler = Instantiate(Bullet, currentEmitter.transform.position, currentEmitter.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);

            //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, ForceMode.Impulse);

            //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, bulletLifetime);
        }

        if (lockedTarget != null && lockedTarget.GetComponent <Team2LockOnMe>() == true && lockedTarget.GetComponent <Team2LockOnMe>().isDead == true)
        {
            lockedOn = false;
            lockText.SetActive(false);
        }
        //lockedTarget = null;
    }
    // Update is called once per frame
    void Update()
    {
        if (overShoot == false)
        {
            canFire = true;
        }
        if (missileShootValue > 0)
        {
            missileShootValue -= missileCooldown * Time.deltaTime;
        }
        if (missileShootValue >= missileLimit)
        {
            missileShootValue = missileLimit;
        }
        if (missileShootValue > missileMax)
        {
            canFire   = false;
            overShoot = true;
        }
        if (missileShootValue < missileMax)
        {
            overShoot = false;
        }

        if (NPC.GetComponent <BasicAI>() == true)
        {
            lockedTarget = NPC.GetComponent <BasicAI>().currentTarget;
        }
        if (lockedTarget == null)
        {
            lockedOn = false;
        }

        if (NPC.GetComponent <BasicAI>().playerIsTarget == true)
        {
            Bullet.GetComponent <MissileScript>().targetIsPlayer = true;
        }

        //        if (NPC.GetComponent<BasicAI>().currentTargetIsFriendly == true)
        //        {
        //            targetIsHostile = false;
        //        }
        //        if (NPC.GetComponent<BasicAI>().currentTargetIsFriendly == false)
        //        {
        //            targetIsHostile = true;
        //        }

        Bullet.GetComponent <MissileScript>().seekTarget = lockedTarget;

        if (lockValue <= 0)
        {
            lockValue = 0;
        }
        if (team1 == true)
        {
            Bullet.GetComponent <MissileScript>().team1 = true;
            if (lockedOn == true)
            {
                //lockedTarget.GetComponent<Team2LockOnMe>().isTargetted = true;
                Bullet.GetComponent <MissileScript>().lockedOnTarget = true;
                if (lockValue < lockMax)
                {
                    lockValue += lockIncrease * Time.deltaTime;
                }
            }
            if (lockedOn == false)
            {
                //lockedTarget.GetComponent<Team2LockOnMe>().isTargetted = false;
                //Bullet.GetComponent<MissileScript>().lockedOnTarget = false;
                lockValue -= lockDecrease * Time.deltaTime;
            }
        }
        if (team2 == true)
        {
            Bullet.GetComponent <MissileScript>().team2 = true;
            if (lockedOn == true)
            {
                //lockedTarget.GetComponent<Team2LockOnMe>().isTargetted = true;
                Bullet.GetComponent <MissileScript>().lockedOnTarget = true;
                if (lockValue < lockMax)
                {
                    lockValue += lockIncrease * Time.deltaTime;
                }
            }
            if (lockedOn == false)
            {
                //lockedTarget.GetComponent<Team2LockOnMe>().isTargetted = false;
                //Bullet.GetComponent<MissileScript>().lockedOnTarget = false;
                lockValue -= lockDecrease * Time.deltaTime;
            }
        }
        if (lockValue < lockThresh)
        {
            permitFire = false;
        }

        if (lockValue >= lockThresh && lockedOn == true)
        {
            permitFire = true;
        }

        if (lockValue >= lockMax && snapBack == true)
        {
            lockValue = lockSnap;
        }

        if (missileShootValue > 0)
        {
            missileShootValue -= missileCooldown * Time.deltaTime;
        }
        if (missileShootValue >= missileLimit)
        {
            missileShootValue = missileLimit;
        }
        if (missileShootValue > missileMax)
        {
            canFire   = false;
            overShoot = true;
        }
        if (missileShootValue < missileMax)
        {
            overShoot = false;
        }

        if (overShoot == false)
        {
            canFire = true;
        }
        if (permitFire == true && canFire == true && lockedOn == true && NPC.GetComponent <BasicAI>().onPath == false)
        {
            //canFire = false;
            StartCoroutine(fireDelay());

            if (NPC.GetComponent <BasicAI>().wingman == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().WingmanLockedOn();
            }
            if (NPC.GetComponent <BasicAI>().genericEnemy == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().GenericEnemyLockedOn();
            }
            if (NPC.GetComponent <BasicAI>().genericAlpha == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().GenericEnemyLockedOn();
            }
            if (NPC.GetComponent <BasicAI>().genericBeta == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().GenericBetaLockedOn();
            }
            if (NPC.GetComponent <BasicAI>().genericDelta == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().GenericDeltaLockedOn();
            }
            if (NPC.GetComponent <BasicAI>().genericDelta == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().GenericEnemyLockedOn();
            }
            if (NPC.GetComponent <BasicAI>().genericGamma == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().GenericEnemyLockedOn();
            }
            if (NPC.GetComponent <BasicAI>().genericOmega == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().GenericEnemyLockedOn();
            }
            if (NPC.GetComponent <BasicAI>().genericSigma == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().GenericEnemyLockedOn();
            }
            if (NPC.GetComponent <BasicAI>().genericTheta == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().GenericEnemyLockedOn();
            }
            if (NPC.GetComponent <BasicAI>().genericZeta == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().GenericEnemyLockedOn();
            }
            if (NPC.GetComponent <BasicAI>().usesList1OnLock == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().SubtitleList1();
            }
            if (NPC.GetComponent <BasicAI>().usesList2OnLock == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().SubtitleList2();
            }
            if (NPC.GetComponent <BasicAI>().usesList3OnLock == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().SubtitleList3();
            }
            if (NPC.GetComponent <BasicAI>().usesList4OnLock == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().SubtitleList4();
            }
            if (NPC.GetComponent <BasicAI>().usesList5OnLock == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().SubtitleList5();
            }
            if (NPC.GetComponent <BasicAI>().usesList6OnLock == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().SubtitleList6();
            }
            if (NPC.GetComponent <BasicAI>().usesList7OnLock == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().SubtitleList7();
            }
            if (NPC.GetComponent <BasicAI>().usesList8OnLock == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().SubtitleList8();
            }
            if (NPC.GetComponent <BasicAI>().usesList9OnLock == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().SubtitleList9();
            }
            if (NPC.GetComponent <BasicAI>().usesList10OnLock == true)
            {
                NPC.GetComponent <BasicAI>().subtitleObject.GetComponent <DialogueScript>().SubtitleList10();
            }

            if (isEmitter1 == true)
            {
                currentEmitter = bulletEmitter1;
            }
            if (isEmitter2 == true)
            {
                currentEmitter = bulletEmitter2;
            }
            if (alternateEmitters == false)
            {
                missileShootValue += missileIncrease;
            }
            //The Bullet Instantiation happens here.
            GameObject Temporary_Bullet_handler;

            //Temporary_Bullet_handler = Instantiate(Bullet, bulletEmitter1.transform.position, bulletEmitter1.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);

            //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, ForceMode.Impulse);

            //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, bulletLifetime);
            {
                if (bulletEmitter1 != null)
                {
                    Temporary_Bullet_handler = Instantiate(Bullet, bulletEmitter1.transform.position, bulletEmitter1.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);

                    //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                    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, ForceMode.Impulse);

                    //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, bulletLifetime);
                }

                if (bulletEmitter2 != null)
                {
                    Temporary_Bullet_handler = Instantiate(Bullet, bulletEmitter2.transform.position, bulletEmitter2.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);

                    //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                    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, ForceMode.Impulse);

                    //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, bulletLifetime);
                }
            }
            if (alternateEmitters == true)
            {
                isEmitter1               = !isEmitter1;
                isEmitter2               = !isEmitter2;
                missileShootValue       += missileIncrease;
                Temporary_Bullet_handler = Instantiate(Bullet, currentEmitter.transform.position, currentEmitter.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);

                //Retrieve the Rigidbody component from the instantiated Bullet and control it.
                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, ForceMode.Impulse);

                //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, bulletLifetime);
            }
        }
    }