Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        bulletPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z + 2.0f);

        if (Input.GetKey(KeyCode.W))
        {
            transform.Translate(Vector3.up * Time.deltaTime * planeSpeed);
        }

        if (Input.GetKey(KeyCode.S))
        {
            transform.Translate(-Vector3.up * Time.deltaTime * planeSpeed);
        }

        if (Input.GetKey(KeyCode.A))
        {
            transform.Translate(-Vector3.right * Time.deltaTime * planeSpeed);
        }

        if (Input.GetKey(KeyCode.D))
        {
            transform.Translate(Vector3.right * Time.deltaTime * planeSpeed);
        }


        if (Input.GetKeyDown(KeyCode.Space))
        {
            audioSource.PlayOneShot(shoot);
            GameObject Clone;
            Clone = (Instantiate(bullet, bulletPosition, transform.rotation)) as GameObject;
            Clone.GetComponent <Rigidbody> ().AddForce(transform.forward * shootingForce);
            Destroy(Clone, 3.0f);
            Vector3 clonePosition = Clone.transform.position;

            if (PowerUpOne.PickedUpPowerUp == true)
            {
                firstUpgrade      = true; // for when player takes damage
                bulletPositionTwo = new Vector3(bulletPosition.x + 0.6f, bulletPosition.y, bulletPosition.z - 1.2f);
                GameObject CloneOne;
                CloneOne = (Instantiate(bullet, bulletPositionTwo, transform.rotation)) as GameObject;
                CloneOne.GetComponent <Rigidbody>().AddForce((transform.forward) * shootingForce);
                Destroy(CloneOne, 3.0f);
                if (PowerUpTwo.PickedUpPowerUp == true)
                {
                    secondUpgrade       = true;               // for when player takes damage
                    bulletPositionThree = new Vector3(bulletPosition.x - 0.6f, bulletPosition.y, bulletPosition.z - 1.2f);
                    GameObject CloneTwo;
                    CloneTwo = (Instantiate(bullet, bulletPositionThree, transform.rotation)) as GameObject;
                    CloneTwo.GetComponent <Rigidbody> ().AddForce(transform.forward * shootingForce);
                    CloneOne.GetComponent <Rigidbody> ().AddForce(transform.forward * shootingForce);

                    Destroy(CloneTwo, 3.0f);

                    if (PowerUpThree.PickedUpPowerUp == true)
                    {
                        thirdUpgrade       = true;                   // for when player takes damage
                        bulletPositionFour = new Vector3(bulletPosition.x - 0.4f, bulletPosition.y, bulletPosition.z);
                        GameObject CloneThree;
                        CloneThree = (Instantiate(bullet, bulletPositionFour, transform.rotation)) as GameObject;
                        CloneThree.GetComponent <Rigidbody> ().AddForce((transform.forward) * shootingForce);
                        Destroy(CloneThree, 3.0f);

                        if (PowerUpFour.PickedUpPowerUp == true)
                        {
                            fourthUpgrade      = true;                        // for when player takes damage
                            bulletPositionFive = new Vector3(bulletPosition.x + 0.4f, bulletPosition.y, bulletPosition.z);
                            GameObject CloneFour;
                            CloneFour = (Instantiate(bullet, bulletPositionFive, transform.rotation)) as GameObject;
                            CloneFour.GetComponent <Rigidbody> ().AddForce((transform.forward) * shootingForce);
                            Destroy(CloneFour, 3.0f);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        temporaryRigidBody.velocity = new Vector3(0, 0, -10);
        if (transform.position.z <= 31.7f)
        {
            temporaryRigidBody.velocity = new Vector3(0, 0, 0);
        }

        waitTimeToShoot    -= Time.deltaTime;
        bulletPositionOne   = new Vector3(transform.position.x - 1.0f, transform.position.y, transform.position.z - 12.0f);
        bulletPositionTwo   = new Vector3(bulletPositionOne.x + 1.0f, transform.position.y, transform.position.z - 12.0f);
        bulletPositionThree = new Vector3(bulletPositionOne.x, transform.position.y, transform.position.z - 12.0f);

        if (waitTimeToShoot <= 2.5f && !shotFirstBullet)
        {
            GameObject Clone;
            Clone = (Instantiate(BossBullet, bulletPositionOne, transform.rotation)) as GameObject;
            Clone.GetComponent <Rigidbody>().velocity = new Vector3(GameObject.Find("Player").transform.position.x - transform.position.x, GameObject.Find("Player").transform.position.y - transform.position.y, GameObject.Find("Player").transform.position.z - transform.position.z).normalized * 20.0f;
            Destroy(Clone, 3.0f);
            shotFirstBullet = true;
        }
        else if (waitTimeToShoot <= 1.5f && !shotSecondBullet)
        {
            GameObject CloneTwo;
            CloneTwo = (Instantiate(BossBullet, bulletPositionTwo, transform.rotation)) as GameObject;
            CloneTwo.GetComponent <Rigidbody>().velocity = new Vector3(GameObject.Find("Player").transform.position.x - transform.position.x, GameObject.Find("Player").transform.position.y - transform.position.y, GameObject.Find("Player").transform.position.z - transform.position.z).normalized * 20.0f;
            Destroy(CloneTwo, 3.0f);
            shotSecondBullet = true;
        }

        else if (waitTimeToShoot <= 0.5f && !shotThirdBullet)
        {
            GameObject CloneThree;
            CloneThree = (Instantiate(BossBullet, bulletPositionTwo, transform.rotation)) as GameObject;
            CloneThree.GetComponent <Rigidbody>().velocity = new Vector3(GameObject.Find("Player").transform.position.x - transform.position.x, GameObject.Find("Player").transform.position.y - transform.position.y, GameObject.Find("Player").transform.position.z - transform.position.z).normalized * 20.0f;
            Destroy(CloneThree, 3.0f);
            shotThirdBullet = true;
        }

        if (shotFirstBullet && shotSecondBullet && shotThirdBullet)
        {
            waitTimeToShoot  = 3.0f;
            shotFirstBullet  = false;
            shotSecondBullet = false;
            shotThirdBullet  = false;
        }

        if (Move.destroyed == true)
        {
            GUI.Label(new Rect(300, 90, 200, 40), "GAME OVER!!!");
            Destroy(gameObject);
        }


        if (bossHealth <= 0.0f)
        {
            audioSource.PlayOneShot(die);
            temporaryRigidBody.useGravity = true;
            Destroy(gameObject, 1.0f);
            didWinGame = true;
        }
    }