2018-11-01 06:09:10 +00:00
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2018-12-05 05:37:05 +00:00
|
|
|
|
using RecrownedAthenaeum.ScreenSystem;
|
2018-11-01 06:09:10 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
2018-12-04 05:05:54 +00:00
|
|
|
|
namespace RecrownedAthenaeum.Screens.Transitions
|
2018-11-01 06:09:10 +00:00
|
|
|
|
{
|
2018-11-04 05:01:17 +00:00
|
|
|
|
internal class FadeAwayTransition : IDisposable, ITransition
|
2018-11-01 06:09:10 +00:00
|
|
|
|
{
|
2018-11-11 18:45:37 +00:00
|
|
|
|
private float time;
|
2018-11-04 05:01:17 +00:00
|
|
|
|
public Texture2D curtain;
|
2018-11-02 03:02:25 +00:00
|
|
|
|
public Rectangle curtainSize;
|
|
|
|
|
private Color color;
|
2018-11-01 06:09:10 +00:00
|
|
|
|
private float progR, progG, progB, progA;
|
2018-11-04 05:01:17 +00:00
|
|
|
|
private float rR, rG, rB, rA;
|
2018-11-01 06:09:10 +00:00
|
|
|
|
|
2018-11-11 18:45:37 +00:00
|
|
|
|
internal FadeAwayTransition(float time)
|
2018-11-02 03:02:25 +00:00
|
|
|
|
{
|
2018-11-11 18:45:37 +00:00
|
|
|
|
this.time = time;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void InitiateTransition(Rectangle dimensions)
|
|
|
|
|
{
|
|
|
|
|
curtainSize = dimensions;
|
2018-11-04 05:01:17 +00:00
|
|
|
|
color = Color.White;
|
2018-11-11 18:45:37 +00:00
|
|
|
|
rR = (0 - 254) / time;
|
|
|
|
|
rG = (0 - 254) / time;
|
|
|
|
|
rB = (0 - 254) / time;
|
|
|
|
|
rA = (0 - 254) / time;
|
2018-11-02 03:02:25 +00:00
|
|
|
|
|
|
|
|
|
progA = color.A;
|
|
|
|
|
progR = color.R;
|
|
|
|
|
progG = color.G;
|
|
|
|
|
progB = color.B;
|
|
|
|
|
}
|
2018-11-01 06:09:10 +00:00
|
|
|
|
|
2018-11-04 05:01:17 +00:00
|
|
|
|
private bool Fade(float deltaf)
|
2018-11-01 06:09:10 +00:00
|
|
|
|
{
|
|
|
|
|
if (progR > 0 || progG > 0 || progB > 0)
|
|
|
|
|
{
|
|
|
|
|
progR += rR * deltaf;
|
|
|
|
|
progR = Math.Max(progR, 0);
|
|
|
|
|
progG += rG * deltaf;
|
|
|
|
|
progG = Math.Max(progG, 0);
|
|
|
|
|
progB += rB * deltaf;
|
|
|
|
|
progB = Math.Max(progB, 0);
|
|
|
|
|
progA += rA * deltaf;
|
|
|
|
|
progA = Math.Max(progA, 0);
|
|
|
|
|
color.R = (byte)progR;
|
|
|
|
|
color.G = (byte)progG;
|
|
|
|
|
color.B = (byte)progB;
|
|
|
|
|
color.A = (byte)progA;
|
2018-11-02 02:20:46 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-11-04 05:01:17 +00:00
|
|
|
|
return true;
|
2018-11-02 02:20:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-04 05:01:17 +00:00
|
|
|
|
public void DrawTransition(SpriteBatch batch)
|
2018-11-02 02:20:46 +00:00
|
|
|
|
{
|
2018-11-13 00:34:11 +00:00
|
|
|
|
if (curtain != null)
|
|
|
|
|
{
|
|
|
|
|
batch.Draw(curtain, curtainSize, color);
|
|
|
|
|
}
|
2018-11-01 06:09:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
curtain.Dispose();
|
|
|
|
|
}
|
2018-11-04 05:01:17 +00:00
|
|
|
|
|
2019-01-15 02:06:17 +00:00
|
|
|
|
public bool UpdateEnteringTransition(double delta, bool assetsLoaded)
|
2018-11-04 05:01:17 +00:00
|
|
|
|
{
|
|
|
|
|
return Fade((float)delta);
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-15 02:06:17 +00:00
|
|
|
|
public bool UpdateExitingTransition(double delta, bool assetsLoaded)
|
2018-11-04 05:01:17 +00:00
|
|
|
|
{
|
|
|
|
|
return Fade((float)delta);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdatePreviousScreenFrame(RenderTarget2D previousScreenFrame)
|
|
|
|
|
{
|
|
|
|
|
curtain = previousScreenFrame;
|
|
|
|
|
}
|
2018-11-01 06:09:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|