Exemple #1
0
    void SpawnCurrency(int _mousePower, int _getHitPower)
    {
        if (FindObjectOfType <Shop>() != null)
        {
            return;
        }

        audioManager.SpawnSlapSource();

        for (int i = 0; i < (int)PrefabManager.E_CURRENCY.SIZE - 1; ++i)
        {
            if (_mousePower == i)
            {
                break;
            }
            else
            {
                int numOfSpawnings = Random.Range(1, Mathf.Abs(_getHitPower));
                for (int j = 0; j < numOfSpawnings; ++j)
                {
                    GameObject currencyPrefab = prefabManager.GetCurrencyPrefab((PrefabManager.E_CURRENCY)i);
                    float      prefabPosZ     = currencyPrefab.transform.position.z;
                    Instantiate(currencyPrefab, new Vector3(SlapPoint.position.x, SlapPoint.position.y, prefabPosZ), Quaternion.identity);
                    AddMoney(currencyPrefab.GetComponent <Currency>().value);
                }
            }
        }

        //if its axe, spawn red and yellow gem as well
        if (mouseWeapon.cursorID == PrefabManager.E_WEAPON.AXE)
        {
            Debug.Log("spawning diamonds");
            GameObject extraDiamondPrefab = prefabManager.GetCurrencyPrefab(Random.Range(0, 2) == 0 ? PrefabManager.E_CURRENCY.DIAMOND_RED : PrefabManager.E_CURRENCY.DIAMOND_YELLOW);
            float      prefabPosZ         = extraDiamondPrefab.transform.position.z;
            Instantiate(extraDiamondPrefab, new Vector3(SlapPoint.position.x, SlapPoint.position.y, prefabPosZ), Quaternion.identity);
            AddMoney(extraDiamondPrefab.GetComponent <Currency>().value);
        }
    }