Exemplo n.º 1
0
 void Awake()
 {
     instance = this;
 }
Exemplo n.º 2
0
        private static void GetSpawnManager()
        {
            instance = (SpawnManager)FindObjectOfType(typeof(SpawnManager));

            if (instance != null)
            {
                window.waveFoldList = new List <bool>();
                for (int i = 0; i < instance.waveList.Count; i++)
                {
                    window.waveFoldList.Add(true);
                }

                //if path is empty, get a path
                if (instance.defaultPath == null)
                {
                    instance.defaultPath = (PathTD)FindObjectOfType(typeof(PathTD));
                }

                //verify and setup the procedural wave generation unit list
                List <ProceduralUnitSetting> unitSettingList = instance.waveGenerator.unitSettingList;
                List <ProceduralUnitSetting> newSettingList  = new List <ProceduralUnitSetting>();
                for (int i = 0; i < creepList.Count; i++)
                {
                    bool match = false;
                    for (int n = 0; n < unitSettingList.Count; n++)
                    {
                        if (unitSettingList[n].unit == creepList[i].gameObject)
                        {
                            newSettingList.Add(unitSettingList[n]);
                            match = true;
                            break;
                        }
                    }
                    if (!match)
                    {
                        ProceduralUnitSetting unitSetting = new ProceduralUnitSetting();
                        unitSetting.unit = creepList[i].gameObject;
                        newSettingList.Add(unitSetting);
                    }
                }
                instance.waveGenerator.unitSettingList = newSettingList;

                instance.waveGenerator.CheckPathList();
                if (instance.defaultPath != null && instance.waveGenerator.pathList.Count == 0)
                {
                    instance.waveGenerator.pathList.Add(instance.defaultPath);
                }

                List <ProceduralVariable> rscSettingList = instance.waveGenerator.rscSettingList;
                while (rscList.Count > rscSettingList.Count)
                {
                    rscSettingList.Add(new ProceduralVariable(10, 500));
                }
                while (rscList.Count < rscSettingList.Count)
                {
                    rscSettingList.RemoveAt(rscSettingList.Count - 1);
                }

                EditorUtility.SetDirty(instance);
            }
        }