public void FireAndExplode() { Rigidbody shellInstance = Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody; ShellExplosion shellExplosion = shellInstance.GetComponent <ShellExplosion>(); shellExplosion.Explode(15.0f); }
//生成并发射炮弹 private void Fire() { // Instantiate and launch the shell. m_Fired = true; //设置发射状态为已发射 //Object Instantiate(Object original, Vector3 position, Quaternion rotation); //克隆 original 对象的所有子对象和组件并返回 //original 要复制的现有对象。 position 新对象的位置。rotation 新对象的方向。 //as Rigidbody:强制转换为刚体组件; Rigidbody shellInstance = Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody; //在坦克炮口处生成一个炮弹刚体; if (m_Plus) { ShellExplosion targetShell = shellInstance.GetComponent <ShellExplosion>(); targetShell.m_ExplosionRadius = 30f; } if (m_Multiple) { Rigidbody shellInstance2 = Instantiate(m_Shell, m_FireTransform2.position, m_FireTransform2.rotation) as Rigidbody; Rigidbody shellInstance3 = Instantiate(m_Shell, m_FireTransform3.position, m_FireTransform3.rotation) as Rigidbody; shellInstance2.velocity = m_CurrentLaunchForce * m_FireTransform2.forward; shellInstance3.velocity = m_CurrentLaunchForce * m_FireTransform3.forward; } shellInstance.velocity = m_CurrentLaunchForce * m_FireTransform.forward; //给炮弹一个速度矢量; //Vector3 Rigidbody.velocity ;刚体的速度矢量。它表示刚体位置的变化率。 m_ShootingAudio.clip = m_FireClip; //将音频源m_ShootingAudio的默认音频片段设置为开火音效; m_ShootingAudio.Play(); //播放开火音效; m_CurrentLaunchForce = m_MinLaunchForce; //重置发射力度为最小发射力度; }
private void BlowUp() { ShellExplosion currentExplosion = Instantiate(explosion, transform.position, Quaternion.identity); currentExplosion.Explode(explosionForce, explosionRadius); Destroy(currentExplosion.gameObject, 3f); Destroy(gameObject); }
/// <summary> /// Rework this method! /// </summary> private void BonusDamage() { TankShooting ts = _rb.GetComponent <TankShooting>(); ShellExplosion se = ts.m_Shell.GetComponent <ShellExplosion>(); se.m_MaxDamage = _maxDamage; Destroy(gameObject); }
private void OnCollisionEnter(Collision collision) { ParticleSystem particles = GetComponentInChildren <ParticleSystem>(); particles.transform.parent = null; Destroy(particles.gameObject, 1f); ShellExplosion currentExplosion = Instantiate(explosion, transform.position, Quaternion.identity); Destroy(currentExplosion.gameObject, 3f); currentExplosion.Explode(explosionForce, explosionRadius); Destroy(gameObject); }
private void Fire() { // Instantiate and launch the shell. m_Fired = true; Rigidbody shellInstance = Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody; shellInstance.velocity = m_CurrentLaunchForce * m_FireTransform.forward; ShellExplosion explosion = shellInstance.GetComponent <ShellExplosion> (); explosion.m_PlayerNumber = this.m_PlayerNumber; m_ShootingAudio.clip = m_FireClip; m_ShootingAudio.Play(); m_CurrentLaunchForce = m_MinLaunchForce; m_ShellAmmo--; }
public void Fire() { // Create an instance of the shell and store a reference to it's rigidbody. Rigidbody shellInstance = Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody; ShellExplosion exp = shellInstance.GetComponent <ShellExplosion>(); exp.Initialize(m_ShellGravity, m_MaxShellBounces, m_ProjectileSpeed * m_FireTransform.forward); // Set the shell's velocity to the launch force in the fire position's forward direction. //shellInstance.velocity = m_ProjectileSpeed * m_FireTransform.forward; // Change the clip to the firing clip and play it. m_ShootingAudio.clip = m_FireClip; m_ShootingAudio.Play(); }
private void OnCollisionEnter(Collision collision) { Rigidbody rb = collision.gameObject.GetComponent <Rigidbody>(); if (collision.gameObject.GetComponent <Rigidbody>() != null) { if (rb.velocity.magnitude + velocity > forceToExplode) { ShellExplosion currentExplosion = Instantiate(explosion, transform.position, transform.rotation); currentExplosion.Explode(explosionForce, explosionRadius); Destroy(currentExplosion.gameObject, 5f); Destroy(gameObject); } } }
private void Fire() { // Create an instance of the shell and store a reference to it's rigidbody. ShellExplosion shellInstance = Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation).GetComponent <ShellExplosion>(); shellInstance.Initialize(false, 1, m_ProjectileSpeed * m_FireTransform.forward); m_ShootingMuzzle.gameObject.SetActive(true); m_ShootingSmoke.gameObject.SetActive(true); // Change the clip to the firing clip and play it. m_ShootingAudio.clip = m_FireClip; m_ShootingAudio.Play(); }
private void OnCollisionEnter(Collision collision) { if (ai != null) { ai.SetProjectileTime(totalFlightTime); } ShellExplosion thisExplosion = Instantiate(explosion, explosionPoint.position, explosionPoint.rotation); Destroy(thisExplosion.gameObject, 5f); if (ai != null) { thisExplosion.SetExplosionFromAI(); } thisExplosion.Explode(explosionForce, explosionRadius); Destroy(gameObject); }
private void CreateShellAndFire(float rotationY = 0.0f, float positionX = 0.0f) { FireTransformRotateYandTranslateX(rotationY, positionX); Rigidbody shellInstance = m_HasBigBullet ? Instantiate(m_BigShell, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody : Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody; ShellExplosion explosion = shellInstance.GetComponent <ShellExplosion>(); explosion.m_IsBigBullet = m_HasBigBullet; shellInstance.velocity = m_CurrentLaunchForce * m_FireTransform.forward; explosion.m_ShootingPlayer = m_PlayerNumber; if (m_HasAlienSwarmBullet) { explosion.m_IsAlienSwarmShot = true; m_HasAlienSwarmBullet = false; } m_ShootingAudio.clip = m_FireClip; m_ShootingAudio.Play(); }
public void Fire(bool isShellOrNot) { // Instantiate and launch the shell. Rigidbody ballInstance = Instantiate(m_Ball, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody; ballInstance.velocity = m_CurrentLaunchForce * m_FireTransform.forward; ShellExplosion shellExplosion = ballInstance.GetComponent <ShellExplosion>(); shellExplosion.isShell = isShellOrNot; shellExplosion.m_TankInstance = m_TankInstance; m_ShootingAudio.clip = m_FireClip; m_ShootingAudio.Play(); m_CurrentLaunchForce = 0f; }
// Start is called before the first frame update void Start() { dropdown = GetComponent <Dropdown>(); tankShooting = tank.GetComponent <TankShooting>(); tankHealth = tank.GetComponent <TankHealth>(); tankDamage = shell.GetComponent <ShellExplosion>(); slider = gameObject.GetComponent <Slider>(); if (gameObject.name == "SFXSlider") { masterMixer.GetFloat("SFXVol", out sfxLevel); slider.value = sfxLevel; } if (gameObject.name == "BGSSlider") { masterMixer.GetFloat("MusicVol", out bgsLevel); slider.value = bgsLevel; } }
public void CmdFire() { // Instantiate and launch the shell. m_Fired = true; print("Player: " + playerName); print("m_FireTransform: " + m_FireTransform); print("m_CurrentLaunchForce: " + m_CurrentLaunchForce); Rigidbody shellInstance = Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody; shellInstance.velocity = m_CurrentLaunchForce * m_FireTransform.forward; ShellExplosion s = shellInstance.GetComponent <ShellExplosion> (); s.playerFrom = playerName; m_ShootingAudio.clip = m_FireClip; m_ShootingAudio.Play(); m_CurrentLaunchForce = m_MinLaunchForce; }
private void GuidedFire() { // Instantiate and launch the shell. if (m_GuidedShellAmmo == 0) { return; } m_Fired = true; Rigidbody shellInstance = Instantiate(m_GuidedShell, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody; GuidedShellScript shell = shellInstance.GetComponent <GuidedShellScript>(); shell.m_TargetPlayer = m_TargetGuided; ShellExplosion explosion = shell.GetComponent <ShellExplosion> (); explosion.m_PlayerNumber = this.m_PlayerNumber; //shellInstance.velocity = m_CurrentLaunchForce * m_FireTransform.forward; //TankManager targetTank = GameManager.m_Instance.FindTargetTank (m_TargetGuided); m_ShootingAudio.clip = m_FireClip; m_ShootingAudio.Play(); m_CurrentLaunchForce = m_MinLaunchForce; m_GuidedShellAmmo--; }
void Awake() { fuerzaParticles.gameObject.SetActive(false); damage = gameObject.GetComponent <ShellExplosion>(); }