private void OnTriggerEnter(Collider other) { if (other.tag == "wall") { Destroy(gameObject); } else if (other.tag == "Bullet") { BulletMove_test bullet = other.GetComponent <BulletMove_test>(); target = bullet.comeFrom; target.SendMessage("SetMissile"); got(target); } else if (other.tag == "Missile") { MissileMove_test missile = other.GetComponent <MissileMove_test>(); target = missile.comeFrom; target.SendMessage("SetMissile"); got(target); } }
void FixedUpdate() { rigid.position = new Vector3 ( Mathf.Clamp(rigid.position.x, boundary2stick.xMin, boundary2stick.xMax), Mathf.Clamp(rigid.position.y, boundary2stick.yMin, boundary2stick.yMax), Mathf.Clamp(rigid.position.z, boundary2stick.zMin, boundary2stick.zMax) ); Vector3 pos = rigid.position; float v_dir = Input.GetAxis("J-V-Direct"); float h_dir = Input.GetAxis("J-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("J-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("Fire1") < 0 && remainAmmo >= 1) //fire { isFireing = true; } else { isFireing = false; } if (isFireing) { shotCounter -= Time.deltaTime; if (shotCounter <= 0) { shotCounter = timeBetweenShots; audioS.volume = 0.3f; if (special_missile > 0)//missile { float type = 1; special_missile -= 1; MissileMove_test newMissile1 = Instantiate(missile, firepoint.position, firepoint.rotation) as MissileMove_test; newMissile1.gameObject.SetActive(true); if (special_big > 0) { type = 2; special_big -= 1; newMissile1.SendMessage("SetBig", true); audioSB.pitch = Random.Range(0.2f, 0.3f); audioSB.volume = 0.5f; newMissile1.transform.localScale = new Vector3(1f, 1f, 1f); } if (special_frozen > 0) { newMissile1.SendMessage("SetFrozen", true); special_frozen -= 1; newMissile1.transform.GetChild(3).gameObject.SetActive(true); newMissile1.transform.GetChild(0).gameObject.SetActive(true); } if (special_multi > 0) { type = 1.5f; special_multi -= 1; MissileMove_test newMissile2 = Instantiate(newMissile1, firepoint.position, firepoint.rotation) as MissileMove_test; newMissile1.transform.Translate(new Vector3(0.2f, 0f, 0f)); newMissile1.transform.Rotate(new Vector3(0f, 0f, -5f)); newMissile1.SendMessage("SetMulti", true); newMissile2.transform.Translate(new Vector3(-0.2f, 0f, 0f)); newMissile2.transform.Rotate(new Vector3(0f, 0f, 5f)); newMissile2.SendMessage("SetMulti", true); } audioM.pitch = Random.Range(0.8f, 1.2f); audioM.Play(); anim.Play("Missile Launcher Animation"); } else//No-missile { float type = 1; BulletMove_test newBullet1 = Instantiate(bullet, firepoint.position, firepoint.rotation) as BulletMove_test; newBullet1.gameObject.SetActive(true); newBullet1.bulletSpeed = bulletSpeed; if (special_big > 0) { type = 2; special_big -= 1; newBullet1.SendMessage("SetBig", true); audioSB.pitch = Random.Range(0.2f, 0.3f); audioSB.volume = 0.5f; newBullet1.transform.localScale = new Vector3(1f, 1f, 1f); Animator a = newBullet1.GetComponent <Animator>(); a.enabled = false; } if (special_frozen > 0) { newBullet1.SendMessage("SetFrozen", true); special_frozen -= 1; newBullet1.GetComponent <ParticleSystemRenderer>().material = ice; newBullet1.transform.GetChild(0).gameObject.SetActive(true); } if (special_multi > 0) { type = 1.5f; special_multi -= 1; newBullet1.transform.Translate(new Vector3(0.2f, 0f, 0f)); newBullet1.transform.Rotate(new Vector3(0f, 0f, -5f)); newBullet1.SendMessage("SetMulti", true); BulletMove_test newBullet2 = Instantiate(newBullet1, firepoint.position, firepoint.rotation) as BulletMove_test; newBullet2.gameObject.SetActive(true); newBullet2.transform.Translate(new Vector3(-0.2f, 0f, 0f)); newBullet2.transform.Rotate(new Vector3(0f, 0f, -5f)); newBullet2.SendMessage("SetMulti", true); } if (updownrecoil == 0) { rigid.AddForce(type * left, ForceMode.Impulse); } else if (updownrecoil == 1) { rigid.AddForce(type * right, ForceMode.Impulse); } audioS.pitch = Random.Range(1f, 5f); if (type >= 2) { audioSB.Play(); } else { audioS.Play(); } anim.Play("Gun Animation"); } SetAmmo(-1); } } 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))); }