Unverified Commit a29bc6ab authored by Geri's avatar Geri Committed by GitHub
Browse files

Add files via upload

Some first day fug fixes.
parent 70467168
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -66,6 +66,8 @@ Pool pool; //The pool scriptable object goes here
Pooler.CreatePools(pool); //Create the pool, without creating it you cannot spawn it
Pool[] pools;
Pooler.CreatePools(pools); //Create multiple pools
Pooler.Destroy(gameObject); //Destroys a GameObject and returns it into the pool scene

Pooler.SpawnFromPool("Name", Vector3.zero); //Spawns an object into a specific position
Pooler.SpawnFromPool("Name", Vector3.zero, Quaternion.identity); //Spawn into a specific position and rotation
Pooler.SpawnFromPool("Name", Vector3.zero, transform); //Spawn into a specific position and parent
+43 −0
Original line number Diff line number Diff line
@@ -43,6 +43,9 @@ public class AudioManager : MonoBehaviour{
    }

    #region Play
    /// <summary>Use this to play a sound with a specific name
    /// <para>It has to be in the Sound asset referenced in the AudioManager instance</para>
    /// </summary>
    public void Play(string name){
        Sounds.List s = Array.Find(soundList.sounds, sound => sound.name == name);
        if(s == null){
@@ -53,6 +56,9 @@ public class AudioManager : MonoBehaviour{
        s.source.volume = s.RandomVolume;
        s.source.Play();
    }
    /// <summary>Use this to play a sound with a specific name and with a certain delay
    /// <para>It has to be in the Sound asset referenced in the AudioManager instance</para>
    /// </summary>
    public void Play(string name, float delay){
        Sounds.List s = Array.Find(soundList.sounds, sound => sound.name == name);
        if (s == null){
@@ -63,6 +69,9 @@ public class AudioManager : MonoBehaviour{
        s.source.volume = s.RandomVolume;
        s.source.PlayDelayed(delay);
    }
    /// <summary>Use this to play one shot of a sound with a specific name
    /// <para>It has to be in the Sound asset referenced in the AudioManager instance</para>
    /// </summary>
    public void PlayOneShot(string name){
        Sounds.List s = Array.Find(soundList.sounds, sound => sound.name == name);
        if (s == null){
@@ -73,6 +82,9 @@ public class AudioManager : MonoBehaviour{
        s.source.volume = s.RandomVolume;
        s.source.PlayOneShot(s.clip);
    }
    /// <summary>Use this to play an intro song and then start playing the song loop
    /// <para>It has to be in the Sound asset referenced in the AudioManager instance</para>
    /// </summary>
    public void PlayWithIntro(string intro, string song){
        Sounds.List s = Array.Find(soundList.sounds, sound => sound.name == intro);
        if (s == null){
@@ -88,6 +100,9 @@ public class AudioManager : MonoBehaviour{
    }
    #endregion
    #region Pause
    /// <summary>Use this to pause a sound with a specific name
    /// <para>It has to be in the Sound asset referenced in the AudioManager instance</para>
    /// </summary>
    public void Pause(string name){
        Sounds.List s = Array.Find(soundList.sounds, sound => sound.name == name);
        if (s == null){
@@ -98,6 +113,9 @@ public class AudioManager : MonoBehaviour{
        s.source.volume = s.RandomVolume;
        s.source.Pause();
    }
    /// <summary>Use this to unpause a sound with a specific name
    /// <para>It has to be in the Sound asset referenced in the AudioManager instance</para>
    /// </summary>
    public void UnPause(string name){
        Sounds.List s = Array.Find(soundList.sounds, sound => sound.name == name);
        if (s == null){
@@ -110,6 +128,9 @@ public class AudioManager : MonoBehaviour{
    }
    #endregion
    #region Stop
    /// <summary>Use this to stop a sound with a specific name
    /// <para>It has to be in the Sound asset referenced in the AudioManager instance</para>
    /// </summary>
    public void Stop(string name){
        Sounds.List s = Array.Find(soundList.sounds, sound => sound.name == name);
        if (s == null){
@@ -120,6 +141,9 @@ public class AudioManager : MonoBehaviour{
        s.source.volume = s.RandomVolume;
        s.source.Stop();
    }
    /// <summary>Use this to stop all the sounds
    /// <para>It has to be in the Sound asset referenced in the AudioManager instance</para>
    /// </summary>
    public void StopAll(){
        foreach (Sounds.List s in soundList.sounds){
            if (s.source){
@@ -128,6 +152,9 @@ public class AudioManager : MonoBehaviour{
        }
    }
    #endregion
    /// <summary>This function returns the AudioSource that contains a specific sound
    /// <para>It has to be in the Sound asset referenced in the AudioManager instance</para>
    /// </summary>
    public AudioSource GetSource(string name){
        Sounds.List s = Array.Find(soundList.sounds, sound => sound.name == name);
        if (s == null){
@@ -137,6 +164,9 @@ public class AudioManager : MonoBehaviour{
        return s.source;
    }
    #region Fades
    /// <summary>Use this to start playing a sound with a fade in
    /// <para>It has to be in the Sound asset referenced in the AudioManager instance</para>
    /// </summary>
    public void FadeIn(string name, float duration){
        StartCoroutine(FadeInCoroutine(name, duration));
    }
@@ -154,6 +184,9 @@ public class AudioManager : MonoBehaviour{
            audioSource.volume = volume;
        }
    }
    /// <summary>Use this to stop playing a sound with a fade out
    /// <para>It has to be in the Sound asset referenced in the AudioManager instance</para>
    /// </summary>
    public void FadeOut(string name, float duration){
        StartCoroutine(FadeOutCoroutine(name, duration));
    }
@@ -173,6 +206,9 @@ public class AudioManager : MonoBehaviour{
        }
    }

    /// <summary>Use this to start playing a sound muted
    /// <para>It has to be in the Sound asset referenced in the AudioManager instance</para>
    /// </summary>
    public void PlayMuted(string name){
        Sounds.List s = Array.Find(soundList.sounds, sound => sound.name == name);
        if (s == null){
@@ -183,6 +219,10 @@ public class AudioManager : MonoBehaviour{
        s.source.volume = 0f;
        s.source.Play();
    }
    /// <summary>Use this to fade in a sound that is currently muted
    /// <para>It has to be in the Sound asset referenced in the AudioManager instance</para>
    /// <para>WARNING: If the PlayMuted hasn't been called before, this function won't work</para>
    /// </summary>
    public void FadeMutedIn(string name, float duration){
        StartCoroutine(FadeMutedInCoroutine(name, duration));
    }
@@ -199,6 +239,9 @@ public class AudioManager : MonoBehaviour{
        }
        s.source.volume = s.volume;
    }
    /// <summary>Use this to fade out a sound and keep playing that muted
    /// <para>It has to be in the Sound asset referenced in the AudioManager instance</para>
    /// </summary>
    public void FadeMutedOut(string name, float duration){
        StartCoroutine(FadeMutedOutCoroutine(name, duration));
    }
+6 −1
Original line number Diff line number Diff line
@@ -20,9 +20,14 @@ public static class ScreenShake{
        }
    }

    /// <summary>Shake the camera
    /// <para>It needs a cinemachine camera with a noise profile in it.</para>
    /// </summary>
    public static void Shake(float intensity, float time){
        if(vCam == null || shakeUpdate == null){
        if(vCam == null){
            vCam = Camera.main.GetComponent<CinemachineBrain>().ActiveVirtualCamera.VirtualCameraGameObject.GetComponent<CinemachineVirtualCamera>();
        }
        if(shakeUpdate == null){
            shakeUpdate = new GameObject("ShakeUpdate").AddComponent<ScreenShakeUpdate>();
        }
        shakeUpdate.startingIntensity = intensity;
+3 −0
Original line number Diff line number Diff line
@@ -22,6 +22,9 @@ public class DialogueSystem : MonoBehaviour{
        anim = GetComponent<Animator>();
    }

    /// <summary>Start or continue the dialogue
    /// <para>This function returns false if the dialogue has ended.</para>
    /// </summary>
    public bool Dialogue(Dialogue dialogue){
        if(!talking){
            if (dialogue.displayName){
+59 −7
Original line number Diff line number Diff line
@@ -11,13 +11,27 @@ public static class Pooler{
    static Dictionary<string, Pool.PoolPrefab> poolDictionary;
    static Scene poolScene;

    /// <summary>Generate a scene with the objects of the pools in it
    /// <para>If this isn't called, the pooler won't work</para>
    /// </summary>
    public static void CreatePools(Pool pool){
        if(pool == null){
            Debug.LogWarning("You have to provide a pool.");
            return;
        }

        poolDictionary = new Dictionary<string, Pool.PoolPrefab>();
        if (SceneManager.GetSceneByName("PoolScene").IsValid()){
            poolScene = SceneManager.GetSceneByName("PoolScene");
        }else{
            poolScene = SceneManager.CreateScene("PoolScene");
        }

        foreach (Pool.PoolPrefab p in pool.pools){
            if (!p.undetermined){
                if(p.determinedPool == null){
                    p.determinedPool = new Queue<GameObject>();
                }
                for (int i = 0; i < p.size; i++){
                    GameObject obj = Object.Instantiate(p.prefab);
                    obj.SetActive(false);
@@ -26,19 +40,35 @@ public static class Pooler{
                    p.determinedPool.Enqueue(obj);
                }
            }else{
                if(p.undeterminedPool == null){
                    p.undeterminedPool = new List<GameObject>();
                }
            }
            poolDictionary.Add(p.tag, p);
        }
    }
    /// <summary>Generate a scene with the objects of the pools in it
    /// <para>If this isn't called, the pooler won't work</para>
    /// </summary>
    public static void CreatePools(Pool[] pools){
        if (pools == null){
            Debug.LogWarning("You have to provide a pool.");
            return;
        }

        poolDictionary = new Dictionary<string, Pool.PoolPrefab>();
        if (SceneManager.GetSceneByName("PoolScene").IsValid()){
            poolScene = SceneManager.GetSceneByName("PoolScene");
        }else{
            poolScene = SceneManager.CreateScene("PoolScene");
        }

        for (int i = 0; i < pools.Length; i++){
            foreach (Pool.PoolPrefab p in pools[i].pools){
                if (!p.undetermined){
                    if (p.determinedPool == null){
                        p.determinedPool = new Queue<GameObject>();
                    }
                    for (int j = 0; j < p.size; j++){
                        GameObject obj = Object.Instantiate(p.prefab);
                        obj.SetActive(false);
@@ -47,12 +77,16 @@ public static class Pooler{
                        p.determinedPool.Enqueue(obj);
                    }
                }else{
                    if (p.undeterminedPool == null){
                        p.undeterminedPool = new List<GameObject>();
                    }
                }
                poolDictionary.Add(p.tag, p);
            }
        }
    }
    /// <summary>Destroy an object and return it to the pool scene
    /// </summary>
    public static void Destroy(GameObject gameObject){
        PoolChecker poolChecker = gameObject.GetComponent<PoolChecker>();
        if (poolChecker == null){
@@ -74,6 +108,9 @@ public static class Pooler{
        }
    }

    /// <summary>Spawn an object into a specific position
    /// <para>The CreatePools function must have been called before.</para>
    /// </summary>
    public static GameObject SpawnFromPool(string tag, Vector3 position){
        if (!poolDictionary.ContainsKey(tag)){
            Debug.Log("Pool with tag " + tag + " doesn't exist.");
@@ -111,6 +148,9 @@ public static class Pooler{
        }
        return objectToSpawn;
    }
    /// <summary>Spawn an object into a specific position and parent
    /// <para>The CreatePools function must have been called before.</para>
    /// </summary>
    public static GameObject SpawnFromPool(string tag, Vector3 position, Transform parent){
        if (!poolDictionary.ContainsKey(tag)){
            Debug.Log("Pool with tag " + tag + " doesn't exist.");
@@ -149,6 +189,9 @@ public static class Pooler{
        }
        return objectToSpawn;
    }
    /// <summary>Spawn an object into a specific position, parent and set if it's in world space or not
    /// <para>The CreatePools function must have been called before.</para>
    /// </summary>
    public static GameObject SpawnFromPool(string tag, Vector3 position, Transform parent, bool instantiateInWorldSpace){
        if (!poolDictionary.ContainsKey(tag)){
            Debug.Log("Pool with tag " + tag + " doesn't exist.");
@@ -194,6 +237,9 @@ public static class Pooler{
        }
        return objectToSpawn;
    }
    /// <summary>Spawn an object into a specific position and rotation
    /// <para>The CreatePools function must have been called before.</para>
    /// </summary>
    public static GameObject SpawnFromPool(string tag, Vector3 position, Quaternion rotation){
        if (!poolDictionary.ContainsKey(tag)){
            Debug.Log("Pool with tag " + tag + " doesn't exist.");
@@ -231,6 +277,9 @@ public static class Pooler{
        }
        return objectToSpawn;
    }
    /// <summary>Spawn an object into a specific position, rotation and parent
    /// <para>The CreatePools function must have been called before.</para>
    /// </summary>
    public static GameObject SpawnFromPool(string tag, Vector3 position, Quaternion rotation, Transform parent){
        if (!poolDictionary.ContainsKey(tag)){
            Debug.Log("Pool with tag " + tag + " doesn't exist.");
@@ -269,6 +318,9 @@ public static class Pooler{
        }
        return objectToSpawn;
    }
    /// <summary>Spawn an object into a specific position, rotation, parent and set if it's in world space or not
    /// <para>The CreatePools function must have been called before.</para>
    /// </summary>
    public static GameObject SpawnFromPool(string tag, Vector3 position, Quaternion rotation, Transform parent, bool instantiateInWorldSpace){
        if (!poolDictionary.ContainsKey(tag)){
            Debug.Log("Pool with tag " + tag + " doesn't exist.");
Loading