rhythmbullet/RhythmBullet/Zer01HD/Utilities/UI/LoadingScreen.cs

61 lines
2.0 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using RhythmBullet.Zer01HD.UI;
using RhythmBullet.Zer01HD.Utilities.UI;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RhythmBullet.Zer01HD.Game
{
class LoadingScreen : Screen
{
Texture2D recrown;
Color color;
Rectangle rectangleBounds;
float proportion = 0.4f;
RhythmBulletGame rhythmBullet;
double progress;
double timePassed;
public LoadingScreen(RhythmBulletGame rhythmBullet, Rectangle dimensions)
{
color = Color.White;
this.recrown = rhythmBullet.Content.Load<Texture2D>("RhythmBullet");
this.rhythmBullet = rhythmBullet;
rectangleBounds = new Rectangle(0, 0, (int)(dimensions.Height * proportion), (int)(dimensions.Height * proportion));
rectangleBounds.X = (dimensions.Width - rectangleBounds.Width) / 2;
rectangleBounds.Y = (dimensions.Height - rectangleBounds.Height) / 2;
}
public override void Update(GameTime gameTime)
{
if (progress < 1f)
{
double delta = gameTime.ElapsedGameTime.TotalSeconds;
timePassed += delta;
progress = timePassed / 4;
if (progress > 0.9f)
{
progress = 0.9f;
}
rhythmBullet.BackgroundColor.R = (byte)(progress * 255);
rhythmBullet.BackgroundColor.G = (byte)(progress * 255);
rhythmBullet.BackgroundColor.B = (byte)(progress * 255);
}
base.Update(gameTime);
}
public override void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(recrown, rectangleBounds, color);
base.Draw(spriteBatch);
}
}
}