Exemplo n.º 1
0
 public void     AddBugs(List <BugParticleSetting> newBugs)
 {
     for (int i = 0; i < newBugs.Count; i++)
     {
         //foreach (BugParticleSetting bugSetting in newBugs) {
         BugParticleSystem bugSystem = GetBugSystem(newBugs[i]);
         if (bugSystem == null)
         {
             continue;                     // Couldn't find prefab to create from
         }
         bugSystem.Setting = newBugs[i];
     }
 }
Exemplo n.º 2
0
        private void ClearDeadBugSystems()
        {
            for (int i = 0; i < BugEmitters.Count; i++)
            {
                if (BugEmitters[i] == null)
                {
                    continue;
                }
                if (!BugEmitters[i].Alive)
                {
                    BugParticleSystem bugSystem = BugEmitters[i];
                    BugEmitters.RemoveAt(i);
                    // Bugs continue to exist until destroyed
                    for (int j = 0; j < bugSystem.Emitters.Count; j++)
                    {
                        Destroy(bugSystem.Emitters[j].transform.gameObject);
                    }

                    break;
                }
            }
        }
Exemplo n.º 3
0
        private BugParticleSystem GetBugSystem(BugParticleSetting bugSetting)
        {
            var systemEnumerator = BugEmitters.GetEnumerator();

            while (systemEnumerator.MoveNext())
            {
                // Check if BugEmitter was already created
                //foreach (BugParticleSystem bugSystem in BugEmitters) {
                bugSystem = systemEnumerator.Current;
                if (bugSystem == null)
                {
                    continue;
                }

                if (bugSystem.Setting.BugType == bugSetting.BugType)
                {
                    return(bugSystem);
                }
            }

            // Attempt to Create BugSystem
            // Can only create if AtmoParticleManager has the prefab
            for (int i = 0; i < bugParticlePrefabs.Length; i++)
            {
                bugPrefab = bugParticlePrefabs[i];
                if (bugPrefab.name == bugSetting.BugType)
                {
                    BugParticleSystem newBugSystem = new BugParticleSystem();
                    newBugSystem.BugPrefab = bugPrefab;
                    // Add to List to find later to change settings, destroy, or emit
                    BugEmitters.Add(newBugSystem);
                    return(newBugSystem);
                }
            }

            return(null);
        }