void OnTriggerEnter(Collider other) { if (other.CompareTag("PowerUp")) { PowerUp gainedPowerUp = other.GetComponent <PowerUp>(); // Get the gained power up effect gainedPowerUp.AffectPlayer(rootTentacle); StartCoroutine("AbsorbingAnimation"); SelfDestroy otherScript = other.GetComponent <SelfDestroy>(); otherScript.Death(); } else if (other.CompareTag("BadBacteria")) { StartCoroutine("AbsorbingAnimation"); SelfDestroy otherScript = other.GetComponent <SelfDestroy>(); otherScript.Death(); } else if (other.CompareTag("GoodBacteria")) { StartCoroutine("AbsorbingAnimation"); SelfDestroy otherScript = other.GetComponent <SelfDestroy>(); otherScript.Death(); } }
void Awake() { SelfDestroy destroyScript = GetComponent <SelfDestroy>(); ParticleSystem particleSystem = GetComponent <ParticleSystem>(); destroyScript.life = particleSystem.main.duration + particleSystem.main.startLifetime.constantMax; }
public void disposeArrow() { List <Vector3> keys = new List <Vector3>(sceneArrowMap.Keys); foreach (Vector3 key in keys) { sceneArrowMap[key].SetActive(false); SelfDestroy.Destroy(sceneArrowMap[key]); } sceneArrowMap.Clear(); if (tipsLightObj != null) { SelfDestroy.Destroy(tipsLightObj); } }
public void GenerateWalls(float x) { for (int i = 1; i <= generationDistance / (wallUnitLength * 2); i++) { for (int j = 0; j < 2; j++) { int index = Random.Range(0, wallPrefabs.Count); Vector2 position = new Vector2(x + i * wallUnitLength * 2, (borderBoundaries[j] - Mathf.Pow((-1), j) * wallOffset)); Quaternion rotation = Quaternion.Euler(0, 0, 90 * Mathf.Pow((-1), j)); GameObject wall = Instantiate(wallPrefabs[index], position, rotation, wallParent) as GameObject; SelfDestroy sd = wall.AddComponent <SelfDestroy>(); sd.target = target; sd.destroyThreshold = wallUnitLength + generationCheckDistance; } } }
// Update is called once per frame void Update() { //Atira com o 'Z' if (Input.GetKeyDown(KeyCode.Space)) { audior.clip = tiro; audior.pitch = Random.Range(0.7f, 2.0f); audior.Play(); CameraShaker.Instance.ShakeOnce(2.5f, 30f, 0.25f, 0.25f); GameObject tempObject; tempObject = Instantiate(laserBeam, this.transform.position, player.transform.rotation); SelfDestroy sd = tempObject.AddComponent <SelfDestroy>() as SelfDestroy; tempObject.transform.Rotate(Vector3.left * 90); rb = tempObject.GetComponent <Rigidbody>(); rb.velocity = transform.forward * -1 * (laserSpeed); } }
private void Update() { if (trapQueue.Count <= 0) { return; } do { Vector2 position = trapQueue.Dequeue(); int index = Random.Range(0, trapPrefabs.Count); float zAngle = Random.Range(-180, 180); Vector3 size = Vector3.one * Random.Range(minSize, maxSize); Quaternion randomZRotation = Quaternion.Euler(0, 0, zAngle); GameObject trap = Instantiate(trapPrefabs[index], position, randomZRotation, trapParrent ?? transform) as GameObject; trap.transform.localScale = size; SelfDestroy sd = trap.AddComponent <SelfDestroy>(); sd.target = target; sd.destroyThreshold = generationCheckDistance; } while (trapQueue.Count > 0); }
// Token: 0x06001126 RID: 4390 RVA: 0x00068634 File Offset: 0x00066834 public Vector3 Explode() { Vector3 result = Vector3.zero; try { if (this._explosionSound != null) { AutoMonoBehaviour <SfxManager> .Instance.Play3dAudioClip(this._explosionSound, base.transform.position, 1f); } if (this._explosionSfx) { GameObject gameObject = UnityEngine.Object.Instantiate(this._explosionSfx) as GameObject; if (gameObject) { gameObject.transform.position = base.transform.position; SelfDestroy selfDestroy = gameObject.AddComponent <SelfDestroy>(); if (selfDestroy) { selfDestroy.SetDelay(2f); } } } else { ParticleEffectController.ShowExplosionEffect(ParticleConfigurationType.LauncherDefault, SurfaceEffectType.None, base.transform.position, Vector3.up); } if (this.OnProjectileExploded != null) { this.OnProjectileExploded(this); } result = base.transform.position; this.Destroy(); } catch (Exception exception) { Debug.LogException(exception); } return(result); }
public virtual void removeObj(GameObject obj) { _listObj.Remove(obj); GameObjectController controller = obj.GetComponent <GameObjectController>(); _mapObj.Remove(controller.baseAttribute.aoId); controller.On_ChangeChunk -= HandleOn_ChangeChunk; List <GameObject> list; WorldPos pos = controller.gameObjectState.attachChunk.worldPos; _mapChunkPosObj.TryGetValue(pos, out list); if (list != null) { list.Remove(obj); if (list.Count <= 0) { _mapChunkPosObj.Remove(pos); } } obj.SetActive(false); SelfDestroy.Destroy(obj); }
void CrushDie() { Renderer rr = deathEffect.GetComponent <Renderer>(); if (rr != null) { Material newMat = new Material(rr.sharedMaterial); newMat.color = this.bodyParts[0].GetComponent <Renderer>().sharedMaterial.color; rr.material = newMat; } SelfDestroy sd = deathEffect.GetComponent <SelfDestroy>(); if (sd != null) { sd.delay = deathEffect.main.startLifetimeMultiplier + 0.1f; sd.enabled = true; } deathEffect.transform.SetParent(null); deathEffect.gameObject.SetActive(true); Destroy(this.gameObject); }
// Use this for initialization void Awake() { Instance = this; }