Example #1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "wall")
     {
         Destroy(gameObject);
     }
     else if (other.tag == "Bullet")
     {
         bulletmove_3_1 bullet = other.GetComponent <bulletmove_3_1>();
         target = bullet.comeFrom;
         target.SendMessage("SetMissile");
         got(target);
     }
     else if (other.tag == "Missile")
     {
         Missilemove_3_1 missile = other.GetComponent <Missilemove_3_1>();
         target = missile.comeFrom;
         target.SendMessage("SetMissile");
         got(target);
     }
 }
Example #2
0
    void FixedUpdate()
    {
        flagcheck();
        rigid.position = new Vector3
                         (
            Mathf.Clamp(rigid.position.x, boundary1stick.xMin, boundary1stick.xMax),
            Mathf.Clamp(rigid.position.y, boundary1stick.yMin, boundary1stick.yMax),
            Mathf.Clamp(rigid.position.z, boundary1stick.zMin, boundary1stick.zMax)
                         );
        Vector3 pos = rigid.position;

        float v_dir = Input.GetAxis("J2-V-Direct");
        float h_dir = Input.GetAxis("J2-H-Direct");

        Vector3 direction = Vector3.zero;

        direction.x = -h_dir;
        direction.y = v_dir;

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

        recoiltest(firepoint.transform.position - gameObject.transform.position);
        if (direction.magnitude >= 0.5)
        {
            transform.GetChild(activeTurret).rotation = rotation;
            LastDirection = rotation;
        }
        else
        {
            transform.GetChild(activeTurret).rotation = LastDirection;
        }

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

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

        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 (Input.GetAxis("J2-Fire2") < 0 && remainAmmo >= 1 && fireflag == true) //fire

        {
            isFireing = true;
        }
        else
        {
            isFireing = false;
        }

        if (isFireing)
        {
            shotCounter -= Time.deltaTime;
            if (shotCounter <= 0)
            {
                shotCounter   = timeBetweenShots;
                audioS.volume = 0.3f;
                if (heatmode)
                {
                    gameObject.SendMessage("Add", Time.time);
                }
                if (isMulti)
                {
                    special_multi -= 1;
                    bulletmove_3_1 newBullet1 = Instantiate(bullet, firepoint.position, firepoint.rotation) as bulletmove_3_1;
                    bulletmove_3_1 newBullet2 = Instantiate(bullet, firepoint.position, firepoint.rotation) as bulletmove_3_1;

                    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);
                    if (isBig)
                    {
                        special_big -= 1;
                        newBullet1.SendMessage("setBig", true);
                        newBullet1.transform.localScale = new Vector3(1f, 1f, 1f);
                        Animator a = newBullet1.GetComponent <Animator>();
                        a.enabled = false;
                    }
                    if (isFrozen)
                    {
                        special_frozen -= 1;
                        newBullet1.SendMessage("SetFrozen", true);
                        newBullet1.transform.GetChild(0).gameObject.SetActive(true);
                        newBullet1.GetComponent <ParticleSystemRenderer>().material = ice;
                    }



                    newBullet2.gameObject.SetActive(true);
                    newBullet2.transform.Translate(new Vector3(-0.2f, 0f, 0f));
                    newBullet2.transform.Rotate(new Vector3(0f, 0f, 5f));
                    newBullet2.bulletSpeed = bulletSpeed;
                    if (isFrozen)
                    {
                        newBullet2.SendMessage("SetFrozen", true);
                        newBullet2.transform.GetChild(0).gameObject.SetActive(true);
                        newBullet2.GetComponent <ParticleSystemRenderer>().material = ice;
                    }
                    if (isBig)
                    {
                        newBullet2.SendMessage("setBig", true);
                        newBullet2.transform.localScale = new Vector3(1f, 1f, 1f);
                        Animator a = newBullet2.GetComponent <Animator>();
                        a.enabled = false;
                    }
                    newBullet2.SendMessage("SetMulti", true);

                    //CameraShaker.Instance.ShakeOnce(1.5f, 4f, 0f, 1.5f);
                    //rigid.AddForce(1.5f * recoil, ForceMode.Impulse);
                    if (updownrecoil == 0)
                    {
                        rigid.AddForce(1.5f * left, ForceMode.Impulse);
                    }
                    else if (updownrecoil == 1)
                    {
                        rigid.AddForce(1.5f * right, ForceMode.Impulse);
                    }
                    audioS.pitch = Random.Range(1f, 5f);
                    anim.Play("Double gun Animation");
                }
                else
                {
                    if (isMissile)
                    {
                        special_missile -= 1;
                        Missilemove_3_1 newMissile = Instantiate(missile, firepoint.position, firepoint.rotation) as Missilemove_3_1;
                        newMissile.gameObject.SetActive(true);
                        //CameraShaker.Instance.ShakeOnce(2f, 4f, 0f, 1.5f);
                        anim.Play("Missile Launcher Animation");


                        if (isFrozen)
                        {
                            newMissile.SendMessage("SetFrozen", true);
                            special_frozen -= 1;
                        }
                    }
                    else
                    {
                        bulletmove_3_1 newBullet = Instantiate(bullet, firepoint.position, firepoint.rotation) as bulletmove_3_1;
                        newBullet.gameObject.SetActive(true);
                        newBullet.bulletSpeed = bulletSpeed;
                        if (isBig)
                        {
                            newBullet.SendMessage("SetBig", true);
                            audioSB.pitch  = Random.Range(0.2f, 0.3f);
                            audioSB.volume = 0.5f;
                            special_big   -= 1;
                            newBullet.transform.localScale = new Vector3(1f, 1f, 1f);
                            Animator a = newBullet.GetComponent <Animator>();
                            //                           ParticleSystem p = newBullet.GetComponent<ParticleSystem>();
                            a.enabled = false;
                            if (updownrecoil == 0)
                            {
                                rigid.AddForce(2 * left, ForceMode.Impulse);
                            }
                            else if (updownrecoil == 1)
                            {
                                rigid.AddForce(2 * right, ForceMode.Impulse);
                            }
                        }

                        if (isFrozen)
                        {
                            newBullet.SendMessage("SetFrozen", true);
                            special_frozen -= 1;
                            newBullet.GetComponent <ParticleSystemRenderer>().material = ice;
                            newBullet.transform.GetChild(0).gameObject.SetActive(true);
                        }

                        //CameraShaker.Instance.ShakeOnce(2.5f, 4f, 0f, 3f);



                        else if (isBig == false)
                        {
                            //CameraShaker.Instance.ShakeOnce(1.25f, 4f, 0f, 1.5f);
                            if (updownrecoil == 0)
                            {
                                rigid.AddForce(left, ForceMode.Impulse);
                            }
                            else if (updownrecoil == 1)
                            {
                                rigid.AddForce(right, ForceMode.Impulse);
                            }
                            audioS.pitch = Random.Range(1f, 5f);
                        }
                        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;
            Application.targetFrameRate = 150;
            GameObject[] score = GameObject.FindGameObjectsWithTag("Score");
            if (!SetScore)
            {
                score[0].SendMessage("rightPlus");
                SetScore = !SetScore;
            }
        }


        SpeCount.SendMessage("SetSpe", Mathf.Max(special_big, Mathf.Max(special_frozen, Mathf.Max(special_missile), special_multi)));
    }