Exemple #1
0
    void Update()
    {
        if (currentHeath >= maxhealth)
        {
            currentHeath = maxhealth;
        }
        if ((Scaledowntime == true) && (gameUI.isPause == false))
        {
            timeScale.DoSlowmotion(0.55f);
        }
        else if ((Scaledowntime == false) && (gameUI.isPause == false))
        {
            timeScale.DoSlowmotion(1f);
        }
        if (isSpeedUp == true)
        {
            ExistEnemy = EnemiesFound();
            SpeedDonwnEnemy(CurrentspeedEnemy);
            SpeedUp();
        }
        else if (isSpeedUp == false)
        {
            ExistEnemy = EnemiesFound();
            ResetSpeedEnemy();
            ResetSpeed();
            ResetTrail();
        }


        if (currentHeath < 30)
        {
            if (OnetimeSmoke == false)
            {
                smokeObj = Instantiate(smoke, transform.position, transform.rotation);
                smokeObj.transform.parent = transform;
                OnetimeSmoke = true;
            }
            StartCoroutine(Lowhealth());
        }
        else if (currentHeath >= 30)
        {
            Destroy(smokeObj);
            OnetimeSmoke = false;
            NormalHealth();
        }

        if ((Input.GetKey(KeyCode.Space)) && Time.time > nextFire)
        {
            StartCoroutine(waitMuzzle());
            nextFire = Time.time + fireRate;
            Instantiate(bullet, firePoint1.position, firePoint1.rotation);
            Instantiate(bullet, firePoint2.position, firePoint2.rotation);
            light_point.SetActive(true);
            light_point.GetComponent <Light>().color = Color.red;
        }


        else if (Input.GetKeyUp(KeyCode.Space))
        {
            light_point.SetActive(false);
            muzzle1.SetActive(false);
            muzzle2.SetActive(false);
        }


        if (Input.GetKey(KeyCode.E) && Time.time > nextRocket)
        {
            nextRocket = Time.time + fireRocketRate;
            StartCoroutine(rocketLauncher.launchRocket());
        }
        if (Input.GetKey(KeyCode.Q) && Time.time > nextFire)
        {
            nextFire = Time.time + 0.025f;
            light_point.SetActive(true);
            light_point.GetComponent <Light>().color = Color.red;
            Instantiate(haze, hazePoint.position, hazePoint.rotation);
        }
        else if (Input.GetKeyUp(KeyCode.Q))
        {
            light_point.SetActive(false);
        }
        if (Input.GetKey(KeyCode.R))
        {
            light_point.SetActive(true);
            light_point.GetComponent <Light>().color = Color.red;
            this.objParticleLaze = Instantiate(lazeStartParticle, lazePoint.position, lazePoint.rotation);
            this.objParticleLaze.transform.parent = this.transform;
            Destroy(this.objParticleLaze, 0.2f);
        }
        if ((Input.GetKeyDown(KeyCode.R)) && !Rpressed)
        {
            Rpressed = true;
        }
        else if (Input.GetKeyUp(KeyCode.R))
        {
            light_point.SetActive(false);
            Rpressed = false;
            if (this.objLaze != null)
            {
                Destroy(this.objLaze);
                this.objLaze = null;
            }
        }
        if (Rpressed && this.objLaze == null && Time.time > nextFire)
        {
            nextFire     = Time.time + 1f;
            this.objLaze = Instantiate(laze, lazePoint.position, transform.rotation);
            this.objLaze.transform.parent = this.transform;
        }
        if (currentHeath <= 0)
        {
            StartCoroutine(Death());
        }
    }