private void OnCollisionEnter2D(Collision2D collision) { explosionSound.play(); RocketExplosion exp = Instantiate(explosion); exp.transform.position = transform.position; Destroy(gameObject); }
private void shoot() { fireSound.play(); currentReloadTime = reloadTime; Projectile p = Instantiate(projectile); p.transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(0, Random.Range(-10, 10), 0)); p.transform.position = transform.position + transform.forward; }
private void OnCollisionEnter(Collision collision) { if (!dead) { gameObject.layer = 11; dead = true; Rigidbody rb = GetComponent <Rigidbody>(); rb.constraints = RigidbodyConstraints.None; UIController.instance.increaseScore(); lr.enabled = false; deathSound.play(); } }
public override void place(Transform parent) { if (canPlace && GameController.instance.canAfford(cost)) { GameController.instance.removeGold(cost); disableDragMode(); CreateJoints(); transform.parent = parent; isPlaced = true; placeSound.play(); UIController.Instance.tutorialPart(2); } else { DestroySelf(); } }
private void fire() { Collider2D target = getTarget(); if (target != null) { if (minxRange < Mathf.Abs(transform.position.x - target.transform.position.x)) { anim.Play("Fire"); if (fireSound != null) { fireSound.play(); } PlayerProjectile p = Instantiate(projectile); p.init(transform.rotation.eulerAngles.z, transform.position, new Vector2(target.transform.position.x, target.transform.position.y - target.transform.localScale.y / 2)); transform.rotation = p.transform.rotation; } } }