//---------------------------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (C)2007 DarkWynter Studios. All rights reserved.
//
//---------------------------------------------------------------------------------------------------------------------------------------------------
// {Contact : darkwynter.com for licensing information
//---------------------------------------------------------------------------------------------------------------------------------------------------
namespace ElementalGame.Menus
{
#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
#endregion
using DarkWynterEngine.Menus;
using DarkWynterEngine.Globals;
//public class Line
//{
// List actors; // Actors in the Scene
// Background background; // The Scene
// int Timer; // Length of time to render this line
//}
//public class Actor
//{
// Texture2D image; // Background Picture
// string line; // Text writer
// string audio; // Audio Track
//}
//public class Background
//{
// Texture2D image; // Background Picture
// string audio; // Audio Track
//}
///
/// Flip book system for drawing cutscene stories.
///
public class CutScene : GameScreen
{
///
/// Ordered list of textures displayed using screenTimeDelays.
///
protected List screens = new List();
///
/// Time steps used to advance screens in non-uniform timing.
///
protected List screenTimeDelays = new List();
///
/// Compared to screenTimeDelays list to time screens.
///
protected System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
///
/// Current screen being drawn.
///
protected int currentScreenIndex = 0;
///
/// Current time delay from screenTimeDelays.
///
protected int currentTimeDelay = 0;
///
/// Notes when a cutscene has completed.
///
protected bool isFinished = false;
///
/// Cut scene constructor.
///
public CutScene(Enums.EngineState GameEngineState)
: base(GameEngineState)
{
//Instantiate the GameMenu
menu = new GameMenu("", 0, 0);
}
///
/// Starts the cutscene progression.
///
public void StartCutScene()
{
stopWatch.Reset();
stopWatch.Start();
currentScreenIndex = 0;
SetBackground(screens[currentScreenIndex]);
currentTimeDelay = screenTimeDelays[currentScreenIndex];
isFinished = false;
}
///
/// Checks to see if cut scene is finished.
///
/// True if completed.
public bool IsFinished()
{
return isFinished;
}
///
/// Skips the cutscene.
///
public void Skip()
{
isFinished = true;
}
///
/// Draws the cut scene's current frame.
///
/// SpriteBatch used to draw used for draw.
public new void Draw(SpriteBatch spriteBatch)
{
if (stopWatch.ElapsedMilliseconds >= currentTimeDelay)
{
if (currentScreenIndex == screens.Count - 1)
{
isFinished = true;
}
else
{
currentScreenIndex++;
SetBackground(screens[currentScreenIndex]);
currentTimeDelay = screenTimeDelays[currentScreenIndex];
}
stopWatch.Reset();
stopWatch.Start();
}
base.Draw(spriteBatch);
}
}
}