コード例 #1
0
        public IEnumerator onUpdateBuilding()
        {
            yield return(new WaitForSeconds(0.1f));

            using (new LockAssemblies())
            {
                while (true)
                {
                    if (curEnumerator == null)
                    {
                        clear();
                        Progress = 1f;
                        TimeSpan ts = DateTime.Now - startTime;
                        UseTime = ts.TotalMilliseconds;

                        Debug.Log("<color=green>Build finish!</color>");
                        yield break;
                    }

                    if (!curEnumerator.MoveNext())
                    {
                        finishWeight += curBuilding.Weight;

                        if (enumerators.Count > 0)
                        {
                            curBuilding   = enumerators.Dequeue();
                            curEnumerator = curBuilding.OnBuilding();

                            if (curEnumerator == null)
                            {
                                Debug.LogError("Wtf building enumrator is null ");
                            }
                        }
                        else
                        {
                            curEnumerator = null;
                            curBuilding   = null;
                        }
                    }

                    if (curBuilding != null)
                    {
                        Progress = (finishWeight + curBuilding.Progress * curBuilding.Weight) / totalWeight;
                    }

                    yield return(null);
                }
            }
        }
コード例 #2
0
        public void StartBuild()
        {
            buildLog.Clear();
            Progress = 0;

            curBuilding   = enumerators.Dequeue();
            curEnumerator = curBuilding.OnBuilding();

            this.mainWindow.SetPanelState(EToolbar.Building);
            startTime = DateTime.Now;

            BuildUtil.DisableCacheServer();

            EditorCoroutines.StartCoroutine(this.onUpdateBuilding(), this.mainWindow);
        }