private void CreatePowerUp(int x, int y) { float random = Random.value; Transform powerupTransform; if (random < addBallProbability) { AddBall addBall = Instantiate(addBallPrefab); addBall.OnCollision += AddBall_OnCollision; powerupTransform = addBall.transform; } else { AddCoin addCoin = Instantiate(addCoinPrefab); addCoin.OnCollision += AddCoin_OnCollision; powerupTransform = addCoin.transform; } powerupTransform.SetParent(gridContainer); powerupTransform.localPosition = GetPositionFromModel(x, y); powerupTransform.localScale *= stepX; cells.Add(powerupTransform); }
private void AddCoin_OnCollision(AddCoin sender) { cells.Remove(sender.transform); Utils.AddCoins(1); uiManager.SetHUDCoins(Utils.GetCoins()); }