Пример #1
0
 public virtual void OnChestOpened()
 {
     AudioManager.Singleton.PlayChestSound(transform.position);
     m_ParticleSystem.Play();
     for (int i = 0; i < coins.Length; i++)
     {
         CoinRigidbody2D coin = coins[i];
         coin.gameObject.SetActive(true);
         float   x     = Random.Range(m_RandomForceXMinimum, m_RandomForceXMaximum);
         float   y     = Random.Range(m_RandomForceYMinimum, m_RandomForceYMaximum);
         Vector2 force = new Vector2(x, y);
         coin.Rigidbody2D.AddForce(force, ForceMode2D.Impulse);
         StartCoroutine(IgnoreAndEnableCollision(m_CurrentCharacter.Collider2D, coin.Collider2D));
     }
 }
Пример #2
0
        public virtual void OnChestOpened()
        {
            AudioManager.Singleton.PlayChestSound(transform.position);
            m_ParticleSystem.Play();
            int coinsCount = Random.Range(m_MinimumCoins, m_MaximumCoins);

            for (int i = 0; i < coinsCount; i++)
            {
                CoinRigidbody2D coin  = Instantiate <CoinRigidbody2D> (m_CoinRigidbody2D, m_SpawnPoint.position, Quaternion.identity, transform);
                float           x     = Random.Range(m_RandomForceXMinimum, m_RandomForceXMaximum);
                float           y     = Random.Range(m_RandomForceYMinimum, m_RandomForceYMaximum);
                Vector2         force = new Vector2(x, y);
                coin.Rigidbody2D.AddForce(force, ForceMode2D.Impulse);
                StartCoroutine(IgnoreAndEnableCollision(m_CurrentCharacter.Collider2D, coin.Collider2D));
            }
        }