loading screen now has the option to rotate image; change in how transitions are handled
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using RhythmBullet.Zer01HD.Game.Screens.Transitions;
|
||||
using RhythmBullet.Zer01HD.UI;
|
||||
using RhythmBullet.Zer01HD.Utilities.UI;
|
||||
using System;
|
||||
@@ -12,14 +13,16 @@ namespace RhythmBullet.Zer01HD.Game.Screens
|
||||
{
|
||||
class MainScreen : Screen
|
||||
{
|
||||
FadeInTransition fadeInTransition;
|
||||
|
||||
public MainScreen() : base(true)
|
||||
public MainScreen(GraphicsDevice graphicsDevice, Color transitionFromColor) : base(true)
|
||||
{
|
||||
|
||||
fadeInTransition = new FadeInTransition(graphicsDevice, transitionFromColor, ScreenSize);
|
||||
}
|
||||
|
||||
public override void EnteringTransition(double delta, bool assetsLoaded, ref Color backgroundColor)
|
||||
{
|
||||
fadeInTransition.Fade((float)delta);
|
||||
base.EnteringTransition(delta, assetsLoaded, ref backgroundColor);
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ namespace RhythmBullet.Zer01HD.Game.Screens.Transitions
|
||||
}
|
||||
|
||||
|
||||
internal void Fade(SpriteBatch batch, float deltaf)
|
||||
internal bool Fade(float deltaf)
|
||||
{
|
||||
if (progR > 0 || progG > 0 || progB > 0)
|
||||
{
|
||||
@@ -53,8 +53,17 @@ namespace RhythmBullet.Zer01HD.Game.Screens.Transitions
|
||||
color.G = (byte)progG;
|
||||
color.B = (byte)progB;
|
||||
color.A = (byte)progA;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
internal void Draw(SpriteBatch batch)
|
||||
{
|
||||
if (curtain != null)
|
||||
{
|
||||
batch.Draw(curtain, curtainSize, color);
|
||||
}
|
||||
batch.Draw(curtain, curtainSize, color);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
@@ -9,21 +9,30 @@ namespace RhythmBullet.Zer01HD.Game
|
||||
{
|
||||
class LoadingScreen : Screen
|
||||
{
|
||||
Texture2D texture;
|
||||
readonly Texture2D texture;
|
||||
Color color;
|
||||
Rectangle rectangleBounds;
|
||||
float proportion = 0.5f;
|
||||
Rectangle textureBounds;
|
||||
readonly float proportion;
|
||||
bool recorded;
|
||||
float rR, rG, rB;
|
||||
float progR, progG, progB;
|
||||
float progC = 254;
|
||||
public LoadingScreen(Texture2D texture, Rectangle dimensions) : base(true)
|
||||
float rotation;
|
||||
readonly bool rotate;
|
||||
Vector2 origin;
|
||||
|
||||
public LoadingScreen(Texture2D texture, float proportion, Rectangle dimensions, bool rotate = false) : base(true)
|
||||
{
|
||||
color = Color.White;
|
||||
this.texture = texture;
|
||||
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;
|
||||
this.proportion = proportion;
|
||||
this.rotate = rotate;
|
||||
textureBounds.Width = (int)(dimensions.Height * proportion);
|
||||
textureBounds.Height = (int)(dimensions.Height * proportion);
|
||||
textureBounds.X = (dimensions.Width) / 2;
|
||||
textureBounds.Y = (dimensions.Height) / 2;
|
||||
origin.X = texture.Width / 2;
|
||||
origin.Y = texture.Height / 2;
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
@@ -33,16 +42,20 @@ namespace RhythmBullet.Zer01HD.Game
|
||||
|
||||
public override void EnteringTransition(double delta, bool assetsLoaded, ref Color BGColor)
|
||||
{
|
||||
float deltaf = (float)delta;
|
||||
if (rotate)
|
||||
{
|
||||
DoRotate(deltaf);
|
||||
}
|
||||
if (assetsLoaded)
|
||||
{
|
||||
float deltaf = (float)delta;
|
||||
if (progR < 254 || progG < 254 || progB < 254)
|
||||
{
|
||||
if (!recorded)
|
||||
{
|
||||
rR = (Color.White.R - BGColor.R) / 3f;
|
||||
rG = (Color.White.G - BGColor.G) / 3f;
|
||||
rB = (Color.White.B - BGColor.B) / 3f;
|
||||
rR = (Color.White.R - BGColor.R) / 2f;
|
||||
rG = (Color.White.G - BGColor.G) / 2f;
|
||||
rB = (Color.White.B - BGColor.B) / 2f;
|
||||
recorded = true;
|
||||
}
|
||||
progR += rR * deltaf;
|
||||
@@ -55,34 +68,50 @@ namespace RhythmBullet.Zer01HD.Game
|
||||
BGColor.G = (byte)progG;
|
||||
BGColor.B = (byte)progB;
|
||||
}
|
||||
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
|
||||
{
|
||||
DoneTransition();
|
||||
DoneEnterTransition();
|
||||
StartExitTransition();
|
||||
}
|
||||
|
||||
}
|
||||
base.EnteringTransition(delta, assetsLoaded, ref BGColor);
|
||||
}
|
||||
|
||||
public override Screen ExitingTransition(double delta, bool assetsLoaded, ref Color backgroundColor)
|
||||
public override bool ExitingTransition(double delta, bool assetsLoaded, ref Color backgroundColor)
|
||||
{
|
||||
return new MainScreen();
|
||||
float deltaf = (float)delta;
|
||||
if (rotate)
|
||||
{
|
||||
DoRotate(deltaf);
|
||||
}
|
||||
if (progC > 0)
|
||||
{
|
||||
float rate = deltaf * 255 / 1f;
|
||||
progC -= rate;
|
||||
progC = Math.Max(progC, 0);
|
||||
color.R = (byte)progC;
|
||||
color.G = (byte)progC;
|
||||
color.B = (byte)progC;
|
||||
color.A = (byte)progC;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DoRotate(float deltaf)
|
||||
{
|
||||
rotation += (2f / 3f) * (float)Math.PI * deltaf;
|
||||
if (rotation >= 2 * Math.PI)
|
||||
{
|
||||
rotation = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
spriteBatch.Draw(texture, rectangleBounds, color);
|
||||
spriteBatch.Draw(texture, textureBounds, null, color, rotation, origin, SpriteEffects.None, 0f);
|
||||
base.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
|
@@ -39,9 +39,9 @@ namespace RhythmBullet.Zer01HD.Utilities.UI
|
||||
|
||||
}
|
||||
|
||||
public virtual Screen ExitingTransition(double delta, bool assetsLoaded, ref Color backgroundColor)
|
||||
public virtual bool ExitingTransition(double delta, bool assetsLoaded, ref Color backgroundColor)
|
||||
{
|
||||
return null;
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Show()
|
||||
@@ -67,7 +67,7 @@ namespace RhythmBullet.Zer01HD.Utilities.UI
|
||||
}
|
||||
}
|
||||
|
||||
public void DoneTransition()
|
||||
public void DoneEnterTransition()
|
||||
{
|
||||
state = ScreenState.Normal;
|
||||
}
|
||||
|
Reference in New Issue
Block a user