Ejemplo n.º 1
0
        public IEnumerator LoadUnits()
        {
            var ListEnum = UnitsToLoad.GetEnumerator();

            int count        = UnitsToLoad.Count;
            int counter      = 1;
            int BreakCounter = 0;

            MapLuaParser.Current.InfoPopup.Show(true, "Loading map...\n( Loading units " + counter + "/" + count + ")");
            yield return(null);

            bool NeedReload = false;

            while (ListEnum.MoveNext())
            {
                NeedReload = !GetGamedataFile.IsUnitSourceLoaded(ListEnum.Current.type);

                ListEnum.Current.Instantiate();
                counter++;
                BreakCounter++;

                if (BreakCounter > 100)
                {
                    BreakCounter = 0;
                    NeedReload   = true;
                }

                if (NeedReload)
                {
                    MapLuaParser.Current.InfoPopup.Show(true, "Loading map...\n( Loading units " + counter + "/" + count + ")");
                    yield return(null);
                }
            }
            ListEnum.Dispose();

            yield return(null);
        }