using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Input.Touch; using Penguloon.Scenes; using System; using System.Collections.Generic; namespace Penguloon.Scenes { public class LoadingScene : SceneBase { public LoadingScene(Main main) : base(main) { } public override void CreateControls() { } public override void Draw(float deltaTime) { base.Draw(deltaTime); // if were still loading assets for loading screen, return if (!ContentManager.DonePreLoading) return; // background Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/background"), destinationRectangle: new Rectangle(0, 0, (int)StaticUIValues.ScreenViewport.X, (int)StaticUIValues.ScreenViewport.Y)); DrawSnowflakes(); // draw progressbar DrawProgressbar(); // draw title DrawText(ContentManager.GetFont(StaticUIValues.LoadingScreenTitle), "Penguloon", new Vector2(0, 100), StaticUIValues.ScreenViewport, TextAllignment.CenterTop, Color.Red, Color.Black, 4); } /// /// Draw progress bar. /// private void DrawProgressbar() { int barWidth = (int)(StaticUIValues.LoadingProgressbarSize.X * ContentManager.LoadPercentageF); Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/red"), destinationRectangle: new Rectangle(StaticUIValues.LoadingProgressbarValuePosition.ToPoint(), new Point(barWidth - 10, (int)StaticUIValues.LoadingProgressbarSize.Y - 10))); Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/progressbar"), destinationRectangle: new Rectangle(StaticUIValues.LoadingProgressbarPosition.ToPoint(), StaticUIValues.LoadingProgressbarSize.ToPoint())); } public override void Update(float deltaTime, TouchLocation[] touchLocations) { base.Update(deltaTime, touchLocations); // if loading is completed if (ContentManager.DoneLoading) { SceneManager.MenuScene = new MenuScene(Main); SceneManager.SelectedScene = SelectedScene.Menu; } } } }