Пример #1
0
 private void Awake()
 {
     if (_impactSound == null)
     {
         _impactSound = GetComponent <SoundPlayOneshot>();
     }
 }
Пример #2
0
        //-------------------------------------------------
        private void SpawnParticles(GameObject particlePrefab, SoundPlayOneshot sound)
        {
            // Don't do this twice
            if (bParticlesSpawned)
            {
                return;
            }

            bParticlesSpawned = true;

            if (particlePrefab != null)
            {
                GameObject particleObject = Instantiate(particlePrefab, transform.position, transform.rotation) as GameObject;
                particleObject.GetComponent <ParticleSystem>().Play();
                Destroy(particleObject, 2f);
            }

            if (sound != null)
            {
                float lastSoundDiff = Time.time - s_flLastDeathSound;
                if (lastSoundDiff < 0.1f)
                {
                    sound.volMax *= 0.25f;
                    sound.volMin *= 0.25f;
                }
                sound.Play();
                s_flLastDeathSound = Time.time;
            }
        }
Пример #3
0
 public static void StartForLevel(int levelIndex)
 {
     Instance._StartForLevel(levelIndex);
     ScoreDisplay = GameObject.Find("ScoreText").GetComponent <Text>();
     ComboDisplay = GameObject.Find("ComboText").GetComponent <Text>();
     ComboSound   = GameObject.Find("ComboSounds").GetComponent <SoundPlayOneshot>();
 }
Пример #4
0
    private void OnCollisionEnter(Collision collision)
    {
        print("on collision enter: " + collision.transform.tag);

        if (collision.transform.tag == "Ax")
        {
            SoundPlayOneshot soundPlayOneshot = collision.transform.GetComponent <SoundPlayOneshot>();
            if (soundPlayOneshot != null)
            {
                soundPlayOneshot.Play();
            }
            else
            {
                Debug.LogError("SoundPlayOneshot component not found on axe.");
            }

            GameObject woodchipInstance = Instantiate(woodChipPrefab);
            woodchipInstance.transform.position = collision.contacts[0].point;

            chopCount++;

            if (chopCount > 2)
            {
                // Spawn logs and delete this.
                for (int i = 0; i < 3; i++)
                {
                    GameObject logInstance = Instantiate(logPrefab);
                    logInstance.transform.position = transform.position + new Vector3(Random.Range(-1f, 1f), Random.Range(0f, 0.5f), Random.Range(-1f, 1f));
                }

                GameObject smokeInstance = Instantiate(smokePrefab);
                smokeInstance.transform.position = transform.position;

                Destroy(gameObject);
            }
        }
    }
Пример #5
0
 protected void Awake()
 {
     ThrowSound        = GetComponent <SoundPlayOneshot>();
     VelocityEstimator = GetComponent <VelocityEstimator>();
 }
Пример #6
0
 private void Awake()
 {
     _interactable = GetComponentInParent <Interactable>();
     _impactSound  = GetComponent <SoundPlayOneshot>();
 }