Exemplo n.º 1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "wall")
     {
         Destroy(gameObject);
     }
     else if (other.tag == "Bullet")
     {
         bulletMove_L6 bullet = other.GetComponent <bulletMove_L6>();
         target = bullet.comeFrom;
         target.SendMessage("SetFrozen");
         got(target);
     }
     else if (other.tag == "Missile")
     {
         MissileMove_L6 missile = other.GetComponent <MissileMove_L6>();
         target = missile.comeFrom;
         target.SendMessage("SetFrozen");
         got(target);
     }
     else if (other.tag == "Player")
     {
         other.transform.parent.SendMessage("SetFrozen");
         Destroy(gameObject);
     }
 }
Exemplo n.º 2
0
    void FixedUpdate()
    {
        Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        //L6
        transform.position = new Vector3(transform.position.x + platformVelocity * Time.deltaTime, transform.position.y, transform.position.z);
        if (rigid.position.y < -7)
        {
            rigid.position = new Vector3(rigid.position.x, 7f, rigid.position.z);
        }
        else if (rigid.position.y > 7.9f)
        {
            rigid.position = new Vector3(rigid.position.x, -6.3f, rigid.position.z);
            rigid.velocity = new Vector3(0f, 2f, 0f);
        }
        if (gameObject.transform.position.x < -12)
        {
            gameObject.transform.position = new Vector3(11.5f, gameObject.transform.position.y, gameObject.transform.position.z);
        }
        else if (gameObject.transform.position.x > 12f)
        {
            gameObject.transform.position = new Vector3(-11.5f, gameObject.transform.position.y, gameObject.transform.position.z);
        }//
        rigid.position = new Vector3
                         (
            Mathf.Clamp(rigid.position.x, boundary1mouse.xMin, boundary1mouse.xMax),
            Mathf.Clamp(rigid.position.y, boundary1mouse.yMin, boundary1mouse.yMax),
            Mathf.Clamp(rigid.position.z, boundary1mouse.zMin, boundary1mouse.zMax)
                         );
        Vector3 pos       = rigid.position;
        Vector3 direction = mousePos - pos;

        angle = Mathf.Atan2(direction.x, direction.y) * Mathf.Rad2Deg;
        Quaternion rotation = Quaternion.AngleAxis(angle, new Vector3(0f, 0f, -1f));

        transform.GetChild(activeTurret).rotation = rotation;

        float h_axis = Input.GetAxis("Horizontal");

        //recoil = direction.y < 0f ? new Vector3(0f, 0f, 0f) : recoilIntensity * -direction.normalized;
        recoil = recoilIntensity * -direction.normalized;

        testbuff();
        if (buff_frozen)//
        {
            gameObject.transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().material = ice;
            buff = 0.6f;
        }
        else
        {
            gameObject.transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().material = normal;
            buff = 1f;
        }

        rigid.velocity = new Vector3(buff * Accelrate * h_axis, rigid.velocity.y, 0f);

        if (rigid.velocity.magnitude > MaxSpeed)
        {
            rigid.velocity = rigid.velocity.normalized * MaxSpeed;
        }

        if (h_axis != 0)
        {
            MoveAnim.Play("body Animation");
        }

        if ((Input.GetMouseButton(0) || Input.GetKey(KeyCode.Space)) && remainAmmo >= 1) //fire
        {
            isFireing = true;
        }
        else
        {
            isFireing = false;
        }

        if (isFireing)
        {
            shotCounter -= Time.deltaTime;
            if (shotCounter <= 0)
            {
                shotCounter   = timeBetweenShots;
                audioS.volume = 0.3f;

                if (isMulti)
                {
                    special -= 1;
                    bulletMove_L6 newBullet1 = Instantiate(bullet, firepoint.position, firepoint.rotation) as bulletMove_L6; //L6
                    bulletMove_L6 newBullet2 = Instantiate(bullet, firepoint.position, firepoint.rotation) as bulletMove_L6; //L6

                    newBullet1.gameObject.SetActive(true);
                    newBullet1.transform.Translate(new Vector3(0.2f, 0f, 0f));
                    newBullet1.transform.Rotate(new Vector3(0f, 0f, -5f));
                    newBullet1.bulletSpeed = bulletSpeed;
                    newBullet1.SendMessage("SetMulti", true);

                    newBullet2.gameObject.SetActive(true);
                    newBullet2.transform.Translate(new Vector3(-0.2f, 0f, 0f));
                    newBullet2.transform.Rotate(new Vector3(0f, 0f, 5f));
                    newBullet2.bulletSpeed = bulletSpeed;
                    newBullet2.SendMessage("SetMulti", true);

                    //CameraShaker.Instance.ShakeOnce(1.5f, 4f, 0f, 1.5f);
                    rigid.AddForce(1.5f * recoil, ForceMode.Impulse);
                    audioS.pitch = Random.Range(1f, 5f);
                    anim.Play("Double gun Animation");
                }
                else
                {
                    if (isMissile)
                    {
                        special -= 1;
                        MissileMove_L6 newMissile = Instantiate(missile, firepoint.position, firepoint.rotation) as MissileMove_L6;//L6
                        newMissile.gameObject.SetActive(true);
                        //CameraShaker.Instance.ShakeOnce(2f, 4f, 0f, 1.5f);
                        anim.Play("Missile Launcher Animation");
                    }
                    else
                    {
                        bulletMove_L6 newBullet = Instantiate(bullet, firepoint.position, firepoint.rotation) as bulletMove_L6;//L6
                        newBullet.gameObject.SetActive(true);
                        newBullet.bulletSpeed = bulletSpeed;
                        if (isBig)
                        {
                            audioSB.pitch  = Random.Range(0.2f, 0.3f);
                            audioSB.volume = 0.5f;
                            special       -= 1;
                            newBullet.transform.localScale = new Vector3(1f, 0.1f, 1f);
                            Animator a = newBullet.GetComponent <Animator>();
                            //                           ParticleSystem p = newBullet.GetComponent<ParticleSystem>();
                            a.enabled = false;
                            newBullet.SendMessage("SetBig", true);
                            //CameraShaker.Instance.ShakeOnce(2.5f, 4f, 0f, 3f);
                            rigid.AddForce(2.0f * recoil, ForceMode.Impulse);
                        }
                        else if (isFrozen)//
                        {
                            special -= 1;
                            newBullet.SendMessage("SetFrozen", true);
                            newBullet.transform.GetChild(0).gameObject.SetActive(true);
                            newBullet.GetComponent <ParticleSystemRenderer>().material = ice;
                            //CameraShaker.Instance.ShakeOnce(1.25f, 4f, 0f, 1.5f);
                            rigid.AddForce(recoil, ForceMode.Impulse);
                            audioS.pitch = Random.Range(1f, 5f);
                        }
                        else
                        {
                            //CameraShaker.Instance.ShakeOnce(1.25f, 4f, 0f, 1.5f);
                            audioS.pitch = Random.Range(1f, 5f);
                            rigid.AddForce(recoil, ForceMode.Impulse);
                        }
                        anim.Play("Gun Animation");
                    }
                }

                SetAmmo(-1);
                if (!isMissile)
                {
                    if (isBig)
                    {
                        audioSB.Play();
                    }
                    else
                    {
                        audioS.Play();
                    }
                }
                else
                {
                    audioM.pitch = Random.Range(0.8f, 1.2f);
                    audioM.Play();
                }
            }
        }
        else
        {
            //shotCounter = 0;
            shotCounter -= Time.deltaTime;
        }
        AmmoCount.SendMessage("SetAmmo", Mathf.Floor(remainAmmo));

        float liftRatio = ((maxLife - 1) / maxLife) * remainLife / maxLife + 1f / maxLife;

        transform.GetChild(0).transform.localScale = new Vector3(1.5f * liftRatio, 0.3f, 0.5f);

        LifeCount.SendMessage("SetLife", remainLife);

        if (remainLife <= 0)
        {
            StartCoroutine(DelayTime(0.3f));
            Time.timeScale = 0.2f;
            GameObject[] score = GameObject.FindGameObjectsWithTag("Score");
            if (!SetScore)
            {
                score[0].SendMessage("rightPlus");
                SetScore = !SetScore;
            }
        }

        if (isSpecial && special <= 0)
        {
            isBig     = false;
            isMulti   = false;
            isMissile = false;
            isFrozen  = false;//
            gameObject.transform.GetChild(1).transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
            this.transform.GetChild(1).GetChild(1).GetChild(1).gameObject.SetActive(false);
            UseTurret1();
            isSpecial = !isSpecial;
        }

        SpeCount.SendMessage("SetSpe", special);
    }