Пример #1
0
    /// <summary>
    /// Plays the given clip as a 3D sound by making the sound originate from the given position
    /// If audio is set to loop it will only stop when either:
    /// <see cref="PauseSounds"/> or <see cref="StopAll"/> are called
    /// or when you stop it through the returned AudioSource
    /// </summary>
    /// <param name="clipName"></param>
    /// <param name="position"></param>
    /// <param name="settings"></param>
    /// <returns></returns>
    public AudioSource PlaySoundAt(AudioClipName clipName, Vector3 position)
    {
        AudioClipInfo   info = GetClipInfo(clipName);
        AudioClip       clip = info.Clip;
        SingleShotAudio fx   = CreateNewSoundSource();

        info.Settings.volume = SoundFxVolume;
        fx.PlaySoundAt(clip, position, info.Settings);
        AudioSource source = fx.Source;

        return(source);
    }
Пример #2
0
    /// <summary>
    /// Plays the given clip as 2D sound which means it will be heard equally from all speakers
    /// If audio is set to loop it will only stop when either:
    /// <see cref="PauseSounds"/> or <see cref="StopAll"/> are called
    /// or when you stop it through the returned AudioSource
    /// </summary>
    /// <param name="clipName">The name of the clip to play</param>
    /// <param name="volume">Modify the default volume of the clip</param>
    /// <param name="pitch">Modify the pitch of the sound</param>
    /// <returns></returns>
    public AudioSource Play2DSound(AudioClipName clipName, float volume = 1f, float pitch = 1f)
    {
        AudioClipInfo       info     = GetClipInfo(clipName);
        AudioSourceSettings settings = info.Settings;

        // Override settings
        settings.volume = volume * SoundFxVolume;
        settings.pitch  = pitch;

        SingleShotAudio fx = CreateNewSoundSource();

        fx.Play2DSound(info.Clip, settings);

        return(fx.Source);
    }
Пример #3
0
 /// <summary>
 /// A lassítás beszűntetése.
 /// </summary>
 /// <param name="Scale">Régi időskála</param>
 void DestroyAndResetTime(float Scale)
 {
     Time.timeScale = Scale;
     SingleShotAudio.Play(Game.Instance.SlowMotionOutSound, transform.position);
     Destroy(gameObject);
 }
Пример #4
0
 /// <summary>
 /// Induláskor az idő belassítása, a működési idő korrigálása az új időskálára, és hang lejátszása.
 /// </summary>
 void Start()
 {
     Duration *= TimeScale;
     OldScale  = Time.timeScale;
     SingleShotAudio.Play(Game.Instance.SlowMotionInSound, transform.position);
 }
Пример #5
0
 /// <summary>
 /// Létrejöttekor kombóhang lejátszása.
 /// </summary>
 void Awake()
 {
     SingleShotAudio.Attach(Game.Instance.ComboSound, gameObject);
 }
Пример #6
0
        /// <summary>
        /// Találatkor hívódik meg.
        /// </summary>
        /// <param name="Score">Elvágó játékos pontszáma</param>
        public void Hit(ref int Score)
        {
            if (GotHit || !Body)
            {
                return;
            }
            GotHit = true; // Ha ez nincs, rengetegszer meghívódna a függvény
            if (name.StartsWith("Menu"))
            {
                Game.SelectedMenuItem = Convert.ToInt32(name.Substring(4)); // A kiválasztott menüelem száma a névben van
            }
            if (Game.Playing)                                               // Csak játék közben módosítson statisztikákat, mert a Game Over menüvel nem tűnnek el -> nem bug, feature
            {
                Dispenser.ObjectDespawned();
                Game.SinceLastCombo = 0;
                Game.ThisCombo++;
                Game.LastHit = transform.position;
                if (Type == Types.Grenade)
                {
                    ((GameObject)Instantiate(Game.Instance.Explosion, transform.position, transform.rotation)).transform.localScale *= Game.Instance.Scale * .1f; // Nagyobb robbanás effekt
                    foreach (Rigidbody EachBody in FindObjectsOfType(typeof(Rigidbody)))                                                                          // Lökjön el mindent magától
                    {
                        if (EachBody != Body)
                        {
                            Destroy(EachBody.gameObject.GetComponent <Target>());
                            EachBody.gameObject.AddComponent <DespawnTime>();
                            Dispenser.ObjectDespawned();
                        }
                        EachBody.AddExplosionForce(Game.Instance.Scale * 50, transform.position, Game.Instance.Scale + Game.Instance.Scale);
                    }
                    Game.LoseLife = true;
                    if (Game.GameMode == GameModes.Multiplayer) // Többjátékos módban pontlevonás is jár a gránátért
                    {
                        Score -= 25;
                    }
                    Game.ThisCombo = 0;
                }
                else
                {
                    Score++;
                }
                // Ha power up vágódott el, aktiválódjon
                if (PowerUp != PowerUps.None)
                {
                    switch (PowerUp)
                    {
                    case PowerUps.DoubleScore: PwrDoubleScore.Activate(); break;

                    case PowerUps.Itemstorm: PwrItemstorm.Activate(); break;

                    case PowerUps.SlowMotion: PwrSlowMotion.Activate(transform.position); break;
                    }
                }
            }
            Vector3 ParentVelocity = Body.velocity;

            foreach (GameObject Shrapnel in Shrapnels)   // Essen szét darabokra
            {
                Shrapnel.transform.parent = null;
                Shrapnel.AddComponent <Despawner>();
                Rigidbody ChildBody = Shrapnel.AddComponent <Rigidbody>();
                ChildBody.AddForce(ParentVelocity);
                ChildBody.AddTorque(new Vector3(Random.value * 100, Random.value * 100, Random.value * 100));
                ChildBody.AddExplosionForce(Game.Instance.Scale * 6, transform.position, 10);
            }
            ((GameObject)Instantiate(Game.Instance.Explosion, transform.position, transform.rotation)).transform.localScale *= Game.Instance.Scale * .02f; // Robbanás effekt
            SingleShotAudio.Play(Game.Instance.SliceSounds[Random.Range(0, Game.Instance.SliceSounds.Length)], transform.position);                        // Vágás hangja
            Destroy(gameObject);
        }