2018-09-15 19:05:14 +00:00
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2018-11-01 04:58:26 +00:00
|
|
|
|
using RhythmBullet.Zer01HD.Game.Screens;
|
2018-09-16 06:37:48 +00:00
|
|
|
|
using RhythmBullet.Zer01HD.Utilities.UI;
|
2018-09-15 19:05:14 +00:00
|
|
|
|
using System;
|
2018-10-31 06:10:15 +00:00
|
|
|
|
using System.Diagnostics;
|
2018-09-15 19:05:14 +00:00
|
|
|
|
|
|
|
|
|
namespace RhythmBullet.Zer01HD.Game
|
|
|
|
|
{
|
2018-10-31 23:21:44 +00:00
|
|
|
|
class LoadingScreen : Screen
|
2018-09-15 19:05:14 +00:00
|
|
|
|
{
|
2018-11-01 04:58:26 +00:00
|
|
|
|
Texture2D texture;
|
2018-10-31 23:21:44 +00:00
|
|
|
|
Color color;
|
2018-10-31 00:47:01 +00:00
|
|
|
|
Rectangle rectangleBounds;
|
2018-11-01 04:58:26 +00:00
|
|
|
|
float proportion = 0.5f;
|
|
|
|
|
bool recorded;
|
|
|
|
|
float rR, rG, rB;
|
|
|
|
|
float progR, progG, progB;
|
|
|
|
|
float progC = 254;
|
|
|
|
|
public LoadingScreen(Texture2D texture, Rectangle dimensions) : base(true)
|
2018-09-15 19:05:14 +00:00
|
|
|
|
{
|
2018-10-31 23:21:44 +00:00
|
|
|
|
color = Color.White;
|
2018-11-01 04:58:26 +00:00
|
|
|
|
this.texture = texture;
|
2018-10-31 06:10:15 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2018-11-01 04:58:26 +00:00
|
|
|
|
base.Update(gameTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void EnteringTransition(double delta, bool assetsLoaded, ref Color BGColor)
|
|
|
|
|
{
|
|
|
|
|
float deltaf = (float)delta;
|
|
|
|
|
if (progR < 254 || progG < 254 || progB < 254)
|
2018-10-31 06:10:15 +00:00
|
|
|
|
{
|
2018-11-01 04:58:26 +00:00
|
|
|
|
if (!recorded)
|
2018-10-31 06:10:15 +00:00
|
|
|
|
{
|
2018-11-01 04:58:26 +00:00
|
|
|
|
rR = (Color.White.R - BGColor.R) / 2.5f;
|
|
|
|
|
rG = (Color.White.G - BGColor.G) / 2.5f;
|
|
|
|
|
rB = (Color.White.B - BGColor.B) / 2.5f;
|
|
|
|
|
recorded = true;
|
2018-10-31 06:10:15 +00:00
|
|
|
|
}
|
2018-11-01 04:58:26 +00:00
|
|
|
|
progR += rR * deltaf;
|
|
|
|
|
progR = Math.Min(progR, 254);
|
|
|
|
|
progG += rG * deltaf;
|
|
|
|
|
progG = Math.Min(progG, 254);
|
|
|
|
|
progB += rB * deltaf;
|
|
|
|
|
progB = Math.Min(progB, 254);
|
|
|
|
|
BGColor.R = (byte)progR;
|
|
|
|
|
BGColor.G = (byte)progG;
|
|
|
|
|
BGColor.B = (byte)progB;
|
2018-10-31 06:10:15 +00:00
|
|
|
|
}
|
2018-11-01 04:58:26 +00:00
|
|
|
|
else if (progC > 0)
|
|
|
|
|
{
|
|
|
|
|
float rate = deltaf * 255 / 1.5f;
|
|
|
|
|
progC -= rate;
|
|
|
|
|
progC = Math.Max(progC, 0);
|
|
|
|
|
color.R = (byte)progC;
|
|
|
|
|
color.G = (byte)progC;
|
|
|
|
|
color.B = (byte)progC;
|
|
|
|
|
color.A = (byte)progC;
|
|
|
|
|
}
|
|
|
|
|
else if (assetsLoaded)
|
|
|
|
|
{
|
|
|
|
|
DoneTransition();
|
|
|
|
|
StartExitTransition();
|
|
|
|
|
}
|
|
|
|
|
base.EnteringTransition(delta, assetsLoaded, ref BGColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Screen ExitingTransition(double delta, bool assetsLoaded, ref Color backgroundColor)
|
|
|
|
|
{
|
|
|
|
|
return new MainScreen();
|
2018-09-15 19:05:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Draw(SpriteBatch spriteBatch)
|
|
|
|
|
{
|
2018-11-01 04:58:26 +00:00
|
|
|
|
spriteBatch.Draw(texture, rectangleBounds, color);
|
2018-09-15 19:05:14 +00:00
|
|
|
|
base.Draw(spriteBatch);
|
|
|
|
|
}
|
2018-11-01 04:58:26 +00:00
|
|
|
|
|
2018-09-15 19:05:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|