// Start is called before the first frame update void Start() { for (int i = 0; i < 20; i++) { Vector2 pos = transform.position; GameObject go = Instantiate(meteoPrefab, pos + Random.insideUnitCircle * Random.Range(-20f, 20f), Quaternion.identity); MeteoroliteController stone = go.GetComponent <MeteoroliteController>(); stone.FallAfter(Random.Range(5f, 25f)); stone.SetCenter(transform.position, 40f); } }
private void OnCollisionEnter2D(Collision2D collision) { string objectTag = collision.gameObject.tag; switch (objectTag) { case "Stone": MeteoroliteController stone = collision.gameObject.GetComponent <MeteoroliteController>(); int attack = stone.GetAttack(); if (attack > 0) { Attacked(collision.gameObject, attack); } break; case "Saw": case "Bullet": Attacked(collision.gameObject); break; default: break; } }