public void OnDeadActionCalled() { Destroy(GetComponent <Identity> ()); StopAllCoroutines(); if (GameDataManager.OfflineMode) { playerTracksController.UpdateWheels(0, 0); playerTracksController.enabled = false; } foreach (HitBox temp in transform.root.GetComponentsInChildren <HitBox>()) { Destroy(temp); } #if ClientCode #region 炮塔飞天 TankScript.GetComponent <TurretController> ().Turret.gameObject.AddComponent <Rigidbody> ().AddForce(Vector3.up * 500); TankScript.GetComponent <TurretController> ().Turret.GetComponent <Rigidbody> ().drag = 0.3f; TankScript.GetComponent <TurretController> ().Turret.GetComponent <Rigidbody> ().mass = 1000; TankScript.GetComponent <TurretController> ().Turret.GetComponent <Rigidbody> ().useGravity = true; #endregion PoolManager.CreateObject("DestroyEffect", transform.position, transform.eulerAngles); #endif foreach (HitBox _HitBox in transform.root.GetComponentsInChildren <HitBox>()) { if (_HitBox) { _HitBox.enabled = false; } } //TankScript.GetComponent<MouseTurret> ().target = null; if (ControlByLocal) { #region PTC关闭 playerTracksController.accelG = 0; playerTracksController.steerG = 0; playerTracksController.UpdateWheels(0, 0); playerTracksController.enabled = false; #endregion #region Nav navmeshAgent.enabled = false; Destroy(navmeshAgent.gameObject); #endregion } #region TankScript TankScript.GetComponent <TankFire>().NowTime = 0; TankScript.GetComponent <TankFire>().enabled = false; TankScript.GetComponent <TurretController>().enabled = false; TankScript.SetActive(false); #endregion Destroy(transform.root.gameObject, 10f); this.enabled = false; }
void OnDeadActionCalled() { Debug.Log("OnDeadActionCalled"); if (netType != InstanceNetType.GameNetworkMaster) { PTC.enableUserInput = false; GetComponent <Rigidbody>().velocity = Vector3.zero; GetComponent <Rigidbody>().angularVelocity = Vector3.zero; if (netType == InstanceNetType.GameNetworkClient || netType == InstanceNetType.GameNetWorkOffline) { PTC.enableUserInput = false; PTC.UpdateWheels(0, 0); PTC.enabled = false; Destroy(TankUIRoot.gameObject); //GameNetwork.Instance.OnClientPlayerDead(); //transform.root.GetComponentInChildren<Camera>().gameObject.AddComponent<Grayscale>().shader = Shader.Find("Hidden/Grayscale Effect"); InGameVoiceSoundManager.PlayVoice(InGameVoiceSoundManager.VoiceType.Vehicle_Destroyed, InGameVoiceSoundManager.InGameVoiceLanguage(playerStateParameter.nationType)); PoolManager.CreateObject("DestroyEffect", transform.position, transform.eulerAngles); } if (netType == InstanceNetType.GameNetworkOthers) { GetComponent <Rigidbody>().isKinematic = true; } #region 炮塔飞天 if (Turret.GetComponent <MeshRenderer>() != null) { if (Turret.GetComponent <Rigidbody>() == null) { Turret.AddComponent <Rigidbody>(); } Turret.GetComponent <Rigidbody>().velocity = GetComponent <Rigidbody>().velocity *0.1f; Turret.GetComponent <Rigidbody>().AddForceAtPosition(Vector3.up * -500, Turret.transform.position); Turret.GetComponent <Rigidbody>().drag = 0.1f; Turret.GetComponent <Rigidbody>().mass = 1000; Turret.GetComponent <Rigidbody>().useGravity = true; } #endregion } else { //GameNetwork.Instance.OnPlayerDead(Util.FindPhotonPlayer (tankInitSystem.PlayerID),tankInitSystem.VehicleName); PTC.SwitchRPM = 0; PTC.UpdateWheels(0, 0); PTC.enabled = false; #region 爆炸特效 PoolManagerSpawnModule.CreateObject("DestroyEffect", transform.position, transform.eulerAngles); #endregion } //foreach(Object temp in DiedDestoryObjects){ // if(temp){ // foreach (HitBox tempHB in ((GameObject)temp).GetComponentsInChildren<HitBox>()){ // if(tempHB){ // tempHB.enabled =false; // } // } // } //} transform.tag = "Untagged"; if (TankScript.GetComponent <TankFire>().tankFireParameter.HasMachineGun) { TankScript.GetComponent <TankFire>().GetComponent <MachineGun>().CancelInvoke(); } TankScript.GetComponent <TankFire>().NowTime = 0; TankScript.GetComponent <TankFire>().enabled = false; TankScript.GetComponent <TurretController>().enabled = false; Destroy(GetComponent <Identity> ()); GameEventManager.onPlayerVehicleDestroyed(); if (GameDataManager.OfflineMode) { Destroy(transform.root.gameObject, 5f); } }