Exemple #1
0
        public override void Update(TimeSpan delta)
        {
            // If we're generating a new
            if (state == InitState.BeforeGeneration)
            {
                // Clear out the text surface
                TextSurface = new BasicSurface(1, 1);
                state       = InitState.Generating;

                SetMessage("Generating map, please wait...  ");

                // Kick off task
                loadingAnimation.Start();
                createRandomWorldTask = new Task <BasicSurface>(GenerateWorld);
                createRandomWorldTask.Start();
            }
            else if (state == InitState.Generating)
            {
                // Update the animation
                loadingAnimation.Update();

                // "Print" the animation to the message console.
                loadingAnimation.Copy(messageData.TextSurface, messageData.Width - 1, 0);

                // If task done...
                if (createRandomWorldTask.IsCompleted)
                {
                    SetMessage("[SPACE] Change Map Info [ENTER] New Map -- Biome   ");
                    this.TextSurface = createRandomWorldTask.Result;
                    state            = InitState.AfterGeneration;
                }
            }
            else if (state == InitState.AfterGeneration)
            {
                loadingAnimation.Stop();
                state = InitState.Completed;
            }
            else
            {
                base.Update(delta);
            }
        }