Exemple #1
0
    private void InstantiateCoinsRandomly()
    {
        int numberOfCoins = Random.Range(3, 5);

        for (int i = 0; i < numberOfCoins; i++)
        {
            GameObject coin       = Instantiate(coinPrefab, new Vector2(transform.position.x, transform.position.y + 0.5f), Quaternion.identity);
            Coin       coinScript = coin.GetComponent <Coin>();
            coinScript.AddForce(true);
        }
    }
Exemple #2
0
    private void LoseCoins()
    {
        int numberOfCoins = FindObjectOfType <GameManager>().GetCoinsAmount() / 10;

        FindObjectOfType <GameManager>().DecrementCoins(numberOfCoins);
        for (int i = 0; i < numberOfCoins; i++)
        {
            GameObject coin       = Instantiate(coinPrefab, new Vector2(transform.position.x, transform.position.y + 0.5f), Quaternion.identity);
            Coin       coinScript = coin.GetComponent <Coin>();
            coinScript.AddForce(false);
        }
    }