예제 #1
0
파일: Game.cs 프로젝트: yuri410/lrvbsvnicg
        //public ScoreEntry[] ResultScore
        //{
        //    get;
        //    private set;
        //}

        public void Update(GameTime time)
        {
            if (!IsPaused)
            {
                scene.Update(time);
            }
            soundWorld.Update(time);

            RtsCamera camera = scene.Camera;

            SoundManager.Instance.ListenerPosition = camera.Position;// PlanetEarth.GetPosition(camera.Longitude, camera.Latitude);
            // scene.Camera.ViewMatrix.TranslationValue;

            if (!IsLoaded)
            {
                bool newVal = TerrainMeshManager.Instance.IsIdle &
                              ModelManager.Instance.IsIdle &
                              TextureManager.Instance.IsIdle &
                              TreeBatchModelManager.Instance.IsIdle;

                if (newVal)
                {
                    if (--loadingCountDown < 0)
                    {
                        IsLoaded = true;
                    }
                }
                else
                {
                    if (++loadingCountDown > 100)
                    {
                        loadingCountDown = 100;
                    }
                }

                int ldop = TerrainMeshManager.Instance.GetCurrentOperationCount();
                ldop += ModelManager.Instance.GetCurrentOperationCount();
                ldop += TextureManager.Instance.GetCurrentOperationCount();
                ldop += TreeBatchModelManager.Instance.GetCurrentOperationCount();

                if (ldop > maxLoadingOp)
                {
                    maxLoadingOp = ldop;
                }

                if (maxLoadingOp > 0)
                {
                    float newPrg = 1 - ldop / (float)maxLoadingOp;
                    if (newPrg > LoadingProgress)
                    {
                        LoadingProgress = newPrg;
                    }
                }

                ingameUI.Update(time);
            }
            else
            {
                //if (gameState.CheckGameOver())
                //{
                //if (!IsOver)
                //{
                //ResultScore = gameState.GetScores();
                //ScoreEntry[] entries = gameState.GetScores();
                //ingameUI.ShowScore(entries);
                //IsOver = true;
                //}
                //}
                //else
                {
                    if (!IsPaused)
                    {
                        gameState.Update(time);
                        if (gameState.CheckGameOver())
                        {
                            ingameUI.ShowFinished();
                        }
                    }
                }

                ingameUI.Update(time);
            }
        }