public void Pop() { //Spawn Level + 4 amount of Candies int amount = Candy.GetCandyCount(); for (int i = 0; i < amount; i++) { //Spawn them on the bag's position var newPos = transform.position; newPos.x += Random.Range(-0.01f, 0.01f); newPos.y += Random.Range(-0.01f, 0.01f); Candy.InstantiateAtPos(newPos); } //activate point effector for cool physics effect in action Sprite.SetActive(false); pe.forceMagnitude = 30; Destroy(this.gameObject, 0.1f); }
public void Pop() { var a = Instantiate(GameControl.Instance.bagPop, transform.position, Quaternion.identity); Destroy(a, 2.0f); int amount = Candy.GetCandyCount(); for (int i = 0; i < amount; i++) { //Spawn them on the bag's position var newPos = transform.position; newPos.x += Random.Range(-0.01f, 0.01f); newPos.y += Random.Range(-0.01f, 0.01f); Candy.InstantiateAtPos(newPos); } //activate point effector for cool physics effect in action Sprite.SetActive(false); pe.forceMagnitude = 15; Destroy(this.gameObject, 0.1f); //Decrement total number of bag count GameControl.Instance.DecrementBagCount(); }