Exemple #1
0
        SoundOrigin NewSound()
        {
            SoundOrigin sound = Instantiate(soundOriginPrefab);

            SceneManager.MoveGameObjectToScene(sound.gameObject, poolScene);
            sound.particleSoundFactory = this;
            sound.entity = entityManager.CreateEntity(soundOriginEntityArchetype);
            return(sound);
        }
Exemple #2
0
        public void Start()
        {
            entityManager = World.Active.EntityManager;
            soundOriginEntityArchetype = entityManager.CreateArchetype(
                typeof(Timer),
                typeof(Translation),
                typeof(SoundProperties));


            timerReset = new Timer
            {
                isOn = true,
                maxT = 0,
                T    = 0
            };

            soundPropertiesReset = new SoundProperties
            {
                syncMap     = false,
                branchCount = 0,
                baseColor   = Color.white,
                actualColor = Color.white
            };

            rigidBodyComponentsReset = new RigidBodyComponents
            {
                position = Vector3.zero,
                rotation = Quaternion.identity
            };

            soundPool = new List <SoundOrigin>();

            if (Application.isEditor)
            {
                poolScene = SceneManager.GetSceneByName(name);
                if (poolScene.isLoaded)
                {
                    GameObject[] rootObjects = poolScene.GetRootGameObjects();
                    for (int i = 0; i < rootObjects.Length; i++)
                    {
                        SoundOrigin pooledSound = rootObjects[i].GetComponent <SoundOrigin>();
                        if (pooledSound != null && !pooledSound.gameObject.activeSelf)
                        {
                            soundPool.Add(pooledSound);
                        }
                    }
                    return;
                }
            }
            poolScene = SceneManager.CreateScene(name);
        }
Exemple #3
0
 void ResetSound(bool syncMap, SoundOrigin instance, int loudNess, Vector2 originPosition, int radius, int colorIndex, float lifeTime, int width, bool bounce)
 {
     timerReset.maxT = lifeTime;
     timerReset.T    = 0;
     timerReset.isOn = true;
     soundPropertiesReset.colorIndex  = colorIndex;
     soundPropertiesReset.branchCount = loudNess;
     soundPropertiesReset.radius      = radius;
     soundPropertiesReset.width       = width;
     soundPropertiesReset.bounce      = bounce;
     soundPropertiesReset.syncMap     = syncMap;
     if (colorIndex >= 0 && colorIndex < colors.Length)
     {
         soundPropertiesReset.baseColor = colors[colorIndex];
     }
     else
     {
         soundPropertiesReset.baseColor = Color.white;
     }
     rigidBodyComponentsReset.position = originPosition;
     instance.SoundOriginStart(ref rigidBodyComponentsReset, ref soundPropertiesReset, ref timerReset);
 }
Exemple #4
0
 public void ReclaimSound(SoundOrigin soundToRecycle)
 {
     soundPool.Add(soundToRecycle);
 }