void StartLevel() { platformsPool.Instantiate(); size = platformsPool.prefab.transform.localScale.x; Instantiate(startPlatformPrefab, transform); InvokeRepeating("SpawnPlatform", 1f, 0.25f); lastpos = platformsPool.prefab.transform.position; }
private void CreateCoin(BoardCellIndex cellIndex) { if (coinCreationParticlesPrefab != null && audioManager != null) { var position = CalculateGlobalCellCenter(cellIndex); var coin = coinsPool.Instantiate(position); coin.transform.localScale = cellSize; if (IsLeftBorder(cellIndex)) { coin.GetComponent <Rigidbody2D>().AddForce(Vector2.left * UnityEngine.Random.Range(5.0f, 25.0f), ForceMode2D.Impulse); } else if (IsRightBorder(cellIndex)) { coin.GetComponent <Rigidbody2D>().AddForce(Vector2.right * UnityEngine.Random.Range(5.0f, 25.0f), ForceMode2D.Impulse); } else if (IsTopBorder(cellIndex)) { coin.GetComponent <Rigidbody2D>().AddForce(Vector2.up * UnityEngine.Random.Range(15.0f, 25.0f), ForceMode2D.Impulse); } else // is bottom border { coin.GetComponent <Rigidbody2D>().AddForce(Vector2.down * UnityEngine.Random.Range(0.0f, 10.0f), ForceMode2D.Impulse); } var particles = Instantiate(coinCreationParticlesPrefab, position, Quaternion.identity); Destroy(particles, 0.5f); audioManager.CreateTemporaryAudioSource("CoinCreation"); } }