コード例 #1
0
ファイル: SoundKit.cs プロジェクト: imec-int/arcadeGameJam
    void Awake()
    {
        // avoid duplicates
        if (instance != null)
        {
            // we set dontDestroyOnLoad to false here due to the Destroy being delayed. it will avoid issues
            // with OnLevelWasLoaded being called while the object is being destroyed.
            dontDestroyOnLoad = false;
            Destroy(gameObject);
            return;
        }

        instance = this;

        if (dontDestroyOnLoad)
        {
            DontDestroyOnLoad(gameObject);
        }

        // Create the _soundList to speed up sound playing in game
        _availableSounds = new Stack <SKSound>(maxCapacity);
        _playingSounds   = new List <SKSound>();

        for (int i = 0; i < initialCapacity; i++)
        {
            _availableSounds.Push(new SKSound(this));
        }
    }
コード例 #2
0
ファイル: RockGame.cs プロジェクト: jusw85/ld47-unity
    private void Start()
    {
        soundKit = Toolbox.Instance.TryGet <SoundKit>();
        soundKit.playBackgroundMusic(bgm, 1.0f, false);

        SceneManager.LoadSceneAsync(Scenes.EFFECTS, LoadSceneMode.Additive);
    }
コード例 #3
0
ファイル: AudioEventEditor.cs プロジェクト: jusw85/ld46-unity
 public void OnEnable()
 {
     // _previewer = EditorUtility
     //     .CreateGameObjectWithHideFlags("Audio preview", HideFlags.HideAndDontSave, typeof(AudioSource))
     //     .GetComponent<AudioSource>();
     _previewer = EditorUtility
                  .CreateGameObjectWithHideFlags("Audio preview", HideFlags.HideAndDontSave, typeof(SoundKit))
                  .GetComponent <SoundKit>();
     _previewer.initialCapacity = 1;
     _previewer.maxCapacity     = 1;
     _previewer.Awake();
 }
コード例 #4
0
ファイル: RandomAudioEvent.cs プロジェクト: jusw85/ld46-unity
    // public override void Play(AudioSource source)
    // {
    //     if (clips.Length == 0) return;
    //
    //     source.clip = clips[Random.Range(0, clips.Length)];
    //     source.volume = Random.Range(volume.Min, volume.Max);
    //     source.pitch = Random.Range(pitch.Min, pitch.Max);
    //     source.Play();
    // }

    public override void Play(SoundKit source)
    {
        if (clips.Length == 0)
        {
            return;
        }

        AudioClip ranClip  = clips[Random.Range(0, clips.Length)];
        float     ranVol   = Random.Range(volume.Min, volume.Max);
        float     ranPitch = Random.Range(pitch.Min, pitch.Max);

        source.playSound(ranClip, ranVol, ranPitch, 0f);
    }
コード例 #5
0
    private void Start()
    {
        sk = Toolbox.Instance.TryGet <SoundKit>();

        GameObject treeObj  = GameObject.FindGameObjectWithTag(Tags.TREES);
        GameObject grassObj = GameObject.FindGameObjectWithTag(Tags.GRASS);

        treeAnimators  = treeObj.GetComponentsInChildren <Animator>();
        grassAnimators = grassObj.GetComponentsInChildren <Animator>();

        skyboxMaterial = RenderSettings.skybox;
        skyboxMaterial.SetFloat("_AtmosphereThickness", atmosphereThickness);
        tweenTarget = new CustomTweenTarget(skyboxMaterial);
    }
コード例 #6
0
 private void Start()
 {
     soundKit = Toolbox.Instance.TryGet <SoundKit>();
     platformController.IsJumpingThisFrameCallback += () =>
     {
         isJumping = true;
         jumpAudio?.Play(soundKit);
     };
     platformController.IsLandingThisFrameCallback += () =>
     {
         isJumping = false;
         if (Time.time - attackActuatedTime <= earlyAttackTimeTolerance)
         {
             attackCanAttackCancel = false;
             animator.SetTrigger(AnimatorParams.ATTACK);
         }
     };
 }
コード例 #7
0
    // public override void Play(AudioSource source)
    // {
    //  float totalWeight = 0;
    //  for (int i = 0; i < Entries.Length; ++i)
    //      totalWeight += Entries[i].Weight;
    //
    //  float pick = Random.Range(0, totalWeight);
    //  for (int i = 0; i < Entries.Length; ++i)
    //  {
    //      if (pick > Entries[i].Weight)
    //      {
    //          pick -= Entries[i].Weight;
    //          continue;
    //      }
    //
    //      Entries[i].Event.Play(source);
    //      return;
    //  }
    // }
    public override void Play(SoundKit source)
    {
        float totalWeight = 0;

        for (int i = 0; i < Entries.Length; ++i)
        {
            totalWeight += Entries[i].Weight;
        }

        float pick = Random.Range(0, totalWeight);

        for (int i = 0; i < Entries.Length; ++i)
        {
            if (pick > Entries[i].Weight)
            {
                pick -= Entries[i].Weight;
                continue;
            }

            Entries[i].Event.Play(source);
            return;
        }
    }
コード例 #8
0
	void Awake()
	{
		// avoid duplicates
		if( instance != null )
		{
			// we set dontDestroyOnLoad to false here due to the Destroy being delayed. it will avoid issues
			// with OnLevelWasLoaded being called while the object is being destroyed.
			dontDestroyOnLoad = false;
			Destroy( gameObject );
			return;
		}

		instance = this;

		if( dontDestroyOnLoad )
			DontDestroyOnLoad( gameObject );

		// Create the _soundList to speed up sound playing in game
		_availableSounds = new Stack<SKSound>( maxCapacity );
		_playingSounds = new List<SKSound>();

		for( int i = 0; i < initialCapacity; i++ )
			_availableSounds.Push( new SKSound( this ) );
	}
コード例 #9
0
ファイル: SoundKit.cs プロジェクト: imec-int/arcadeGameJam
 void OnApplicationQuit()
 {
     instance = null;
 }
コード例 #10
0
ファイル: SoundKit.cs プロジェクト: imec-int/arcadeGameJam
 public SKSound(SoundKit manager)
 {
     _manager                = manager;
     audioSource             = _manager.gameObject.AddComponent <AudioSource>();
     audioSource.playOnAwake = false;
 }
コード例 #11
0
 public SKSound( SoundKit manager )
 {
     _manager = manager;
     audioSource = _manager.gameObject.AddComponent<AudioSource>();
     audioSource.playOnAwake = false;
 }
コード例 #12
0
 void OnApplicationQuit()
 {
     instance = null;
 }
コード例 #13
0
 public override void Play(SoundKit source)
 {
     source.playSound(clip, volume, pitch, 0f);
 }
コード例 #14
0
 // public abstract void Play(AudioSource source);
 public abstract void Play(SoundKit source);