コード例 #1
0
ファイル: Map.cs プロジェクト: blr-dev/Follow-the-Line-3D
 void StartLevel()
 {
     platformsPool.Instantiate();
     size = platformsPool.prefab.transform.localScale.x;
     Instantiate(startPlatformPrefab, transform);
     InvokeRepeating("SpawnPlatform", 1f, 0.25f);
     lastpos = platformsPool.prefab.transform.position;
 }
コード例 #2
0
    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");
        }
    }