private void OnTriggerStay(Collider other) { if (CooldownCounter > 0) { return; } if (other.CompareTag("Debri")) { Debri debri = other.GetComponentInParent <Debri>(); if (debri.IsGrabbed || debri.Size == Size.Small) { return; } // Compactor Particle System GameObject particleGO = Instantiate(CompactorParticleSystem.gameObject, debri.transform.position, Quaternion.identity) as GameObject; Destroy(particleGO, 1f); CooldownCounter = debri.CompactorCooldown; cooldown.Show(debri.CompactorCooldown); // Show cooldown UI StartCoroutine(SpawnCoroutine(debri.Size, debri.CompactorCooldown)); Destroy(other.transform.parent.gameObject); } }
private void OnTriggerStay(Collider other) { if (CooldownCounter > 0) { return; } IGrabable grabable = other.GetComponentInParent <IGrabable>(); if (grabable != null) { Debri debri = other.GetComponentInParent <Debri>(); if (debri.IsGrabbed) { return; } GameObject particleGO = Instantiate(IncineratorDestruction, debri.transform.position, Quaternion.identity) as GameObject; Destroy(particleGO, 1f); CooldownCounter = debri.IncineratorCooldown; cooldown.Show(debri.IncineratorCooldown); // Show cooldown UI GameManager.Instance.AddScore(debri.Score); GameManager.Instance.DecrementMessValue(grabable.GetMassValue()); // TODO play with random pitch - and maybe with a particle animation SoundEffects.Instance.Play(SfxDestroy, true); Destroy(debri.gameObject); } }