/// <summary> /// 添加篮环爆炸粒子. /// </summary> public void AddLanHuanExplosionToList(GameObject obj, PlayerIndex index) { if (obj != null && index != PlayerIndex.Null) { DestroyThisTimed desCom = obj.GetComponent <DestroyThisTimed>(); desCom.Init(DestroyThisTimed.DestroyState.LanHuanExp); m_LanHuanExpList[(int)index].Add(obj); } }
/// <summary> /// 检测是否配置有DestroyThisTimed组件 /// </summary> internal void CheckDestroyThisTimed(GameObject obj) { if (obj != null) { DestroyThisTimed com = obj.GetComponent <DestroyThisTimed>(); if (com == null) { obj.AddComponent <DestroyThisTimed>(); } } }
// Use this for initialization void Awake() { ParticleObj = gameObject; GunParticles = GetComponentInChildren <ParticleSystem> (); DestroyScript = GetComponent <DestroyThisTimed>(); if (DestroyScript != null) { TimeDestroy = DestroyScript.TimeRemove; } else { TimeDestroy = 3f; } }
public GameObject SpawnParticleObject(GameObject particleObj, Vector3 pos, Quaternion rot, bool isCanDestory = false) { DestroyThisTimed destroyThisCom = FindeParticleManageFromList(particleObj); if (destroyThisCom == null) { ParticleDt particleDt = new ParticleDt(); GameObject obj = (GameObject)Instantiate(particleObj, pos, rot); destroyThisCom = obj.GetComponent <DestroyThisTimed>(); obj.name = particleObj.name; particleDt.ParticleObject = obj; particleDt.DestroyThisCom = destroyThisCom; ParticleDtList.Add(particleDt); destroyThisCom.Init(isCanDestory); } else { destroyThisCom.transform.position = pos; destroyThisCom.transform.rotation = rot; } destroyThisCom.PlayGamePartidle(); return(destroyThisCom.gameObject); }
public void OnDestroyThis() { if (Application.loadedLevel == 0) { return; } if (IsDestroyThis) { return; } IsDestroyThis = true; if (LiZiPrefab != null) { //Instantiate(LiZiPrefab, PlayerController.GetInstance().DaoJuLiZiSpawnTr.position, // PlayerController.GetInstance().DaoJuLiZiSpawnTr.rotation); GameObject obj = (GameObject)Instantiate(LiZiPrefab, transform.position, transform.rotation); SSMissionCleanup.GetInstance().AddObj(obj); } if (PlayerController.GetInstance() != null) { if (JiFenVal > 0) { PlayerController.GetInstance().PlayerJiFen += JiFenVal; PlayerController.GetInstance().m_UIController.ShowJiFenInfo(PlayerController.GetInstance().PlayerJiFen); } if (JiFenPrefab != null) { PlayerController.GetInstance().SpawnDaoJuJiFen(JiFenPrefab); } } switch (DaoJuState) { case DaoJuType.PenQiJiaSu: case DaoJuType.FeiXingYi: case DaoJuType.JiaSuFengShan: case DaoJuType.ShuangYiFeiJi: case DaoJuType.QianTing: case DaoJuType.Tank: { PlayerController.GetInstance().OpenPlayerDaoJuAni(DaoJuState); break; } case DaoJuType.ZhangAiWu: { GameObject childObj = null; DestroyThisTimed destroyCom = null; for (int i = 0; i < transform.childCount; i++) { childObj = transform.GetChild(i).gameObject; destroyCom = childObj.AddComponent <DestroyThisTimed>(); destroyCom.InitInfo(LiZiPrefab, BaoXiangPrefab, i * TimeDestroyZhangAiWu); } transform.DetachChildren(); //将子集从自身解除. break; } case DaoJuType.CiTie: { PlayerController.GetInstance().OpenPlayerCiTieDaoJu(); break; } case DaoJuType.DaoDan: { PlayerController.GetInstance().OnPlayerHitDaoDanDaoJu(ZhangAiWuObj); break; } case DaoJuType.DiLei: { PlayerController.GetInstance().OnPlayerHitDiLeiDaoJu(ZhangAiWuObj); break; } } Destroy(gameObject); }