public void TryToTriggerGun() { if (shootCounter <= 0) { this.transform.DOShakeRotation(MinimumShootPeriod * 0.8f, 3f); muzzleCounter = muzzleShowPeriod; muzzleFlash.transform.localEulerAngles = new Vector3(0, 0, Random.Range(0, 360)); shootCounter = MinimumShootPeriod; GameObject newBullet = GameObject.Instantiate(bulletCandidate); BulletScript bullet = newBullet.GetComponent <BulletScript>(); bullet.transform.position = muzzleFlash.transform.position; bullet.transform.rotation = muzzleFlash.transform.rotation; if (this.tag == "Player") { gunShootSound.Stop(); gunShootSound.pitch = Random.Range(0.8f, 1); gunShootSound.Play(); bullet.InitAndShoot(muzzleFlash.transform.forward); } else if (this.tag == "soldier") { bullet.InitAndShoot(ep.transform.position - this.transform.position + new Vector3(0, 1.4f, 0)); } //Debug.Log(ep.transform.position - this.transform.position); } }
public void TryToTriggerGun() { if (shootCounter <= 0) { Debug.Log("Hi"); /* * gunShootSound.Stop (); * gunShootSound.pitch = Random.Range (0.8f, 1); * gunShootSound.Play (); */ this.transform.DOShakeRotation(MinimumShootPeriod * 0.8f, 3f); muzzleCounter = muzzleShowPeriod; muzzleFlash.transform.localEulerAngles = new Vector3(0, -6, Random.Range(0, 360)); shootCounter = MinimumShootPeriod; GameObject newBullet = GameObject.Instantiate(bulletCandidate); BulletScript bullet = newBullet.GetComponent <BulletScript> (); bullet.transform.position = muzzleFlash.transform.position; bullet.transform.rotation = muzzleFlash.transform.rotation; bullet.InitAndShoot(muzzleFlash.transform.forward); AttackSensor.CollisionObjects [0].transform.GetChild(0).GetChild(0).SendMessage("Hit", 1); Debug.Log("bye"); } }
public void Shoot() { if (m_playerBullets.Count < m_iMaxBulletNum && m_fShootingIntervalCounter >= m_fShootingInterval && m_player.isActiveAndEnabled) { m_fShootingIntervalCounter = 0; GameObject bulletPrefab = BulletPool.Instance.GetBulletPrefab(m_player.Team); BulletScript bulletScript = bulletPrefab.GetComponent <BulletScript>(); bulletScript.SetReuse(BulletPool.Instance.BackToBulletPool); //再生出子彈後,接著告訴那顆子彈在消失後該歸還至何處 bulletScript.InitAndShoot(this.transform.up, (Vector2)m_player.transform.position + m_v2BulletOffset, Unit.ETeam.Player); m_playerBullets.Add(bulletScript); } }
public void PlayShootAnimation() { _animator.SetTrigger("shoot"); GameCamera.transform.DOShakePosition(CameraShakeDuration, CameraShakeStrenth); GameObject bulletobj = GameObject.Instantiate(bulletCandidate); BulletScript bulletScript = bulletobj.GetComponent <BulletScript> (); bulletScript.transform.position = this.transform.position + bulletOffset * this.gameObject.transform.right; bulletScript.transform.rotation = this.transform.rotation; Vector3 shootDirection3D = this.gameObject.transform.right; Vector2 shootDirection2D = new Vector2(shootDirection3D.x, shootDirection3D.y); bulletScript.InitAndShoot(shootDirection2D); }
public void PlayShootAnimation() { m_kAnimator.SetTrigger("Shoot"); MainCamera.transform.DOShakePosition(CameraShakeDuration, CameraShakeStrength); m_kScoreManager.AddScore(1); GameObject bulletObj = GameObject.Instantiate(bulletCandidate); BulletScript bulletScript = bulletObj.GetComponent <BulletScript> (); bulletScript.transform.position = this.transform.position + DF_BULLET_OFFESET * this.transform.right; bulletScript.transform.rotation = this.transform.rotation; bulletScript.InitAndShoot(new Vector2(this.transform.right.x, this.transform.right.y)); m_kGameLoopManager.bullets.Add(bulletScript); }
public void TryToTriggerGun() { if (shootCounter <= 0) { this.transform.DOShakeRotation(MinimunShootPeriod * 0.8f, 3f); muzzleCounter = MuzzleShowPeriod; muzzleFlash.transform.localEulerAngles = new Vector3(0, 0, Random.Range(0, 360)); shootCounter = MinimunShootPeriod; GameObject newBullet = GameObject.Instantiate(bulletCandidate); BulletScript bullet = newBullet.GetComponent <BulletScript>(); bullet.transform.position = muzzleFlash.transform.position; bullet.transform.rotation = muzzleFlash.transform.rotation; bullet.InitAndShoot(muzzleFlash.transform.forward); } }
public void PlayShootAnimation() { _animator.SetTrigger("Shoot"); GameCamera.transform.DOShakePosition(CameraShakeDuration, CameraShakeStrength); //以上此行在開砲後呼叫DOTween套件中的DOShakePosition,做出震盪效果 scoreManager.AddScore(1); GameObject bulletobj = GameObject.Instantiate(bulletCandidate); BulletScript bulletScript = bulletobj.GetComponent <BulletScript>(); bulletScript.transform.position = this.transform.position + bulletOffset * this.gameObject.transform.right; bulletScript.transform.rotation = this.transform.rotation; Vector3 shootDirection3D = this.gameObject.transform.right; Vector2 shootDirection2D = new Vector2(shootDirection3D.x, shootDirection3D.y); bulletScript.InitAndShoot(shootDirection2D); gameLoopManager.bullets.Add(bulletScript); }
public void TryToTriggerGun(GameObject FollowTarget) { if (shootCounter <= 0) { gunShootSound.Stop(); gunShootSound.pitch = Random.Range(0.8f, 1); gunShootSound.Play(); this.transform.DOShakeRotation(MinimumShootPeriod * 0.8f, 3f); muzzleCounter = muzzleShowPeriod; muzzleFlash.transform.localEulerAngles = new Vector3(0, 0, Random.Range(0, 360)); shootCounter = MinimumShootPeriod; GameObject newBullet = GameObject.Instantiate(bulletCandidate); BulletScript bullet = newBullet.GetComponent <BulletScript>(); Vector3 aim = FollowTarget.transform.position - muzzleFlash.transform.position; bullet.transform.position = muzzleFlash.transform.position; bullet.transform.rotation = muzzleFlash.transform.rotation; bullet.InitAndShoot(aim.normalized); } }