JustPaste.it

float flipPageSpread = 0;
int colorRGB = 255;
public override void Draw(GameTime gameTime)
{
if (Global.animationDone)
{
if (Global.state == Global.GameState.PageTurning)
{
if (takeScreenshot)
{
RenderTarget2D renderTarget;
renderTarget = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
GraphicsDevice.SetRenderTarget(renderTarget);
drawPage();
GraphicsDevice.SetRenderTarget(null);
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream rawStream = storage.CreateFile("screenshot"))
{
renderTarget.SaveAsJpeg(rawStream, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
screenshot = Texture2D.FromStream(GraphicsDevice, rawStream);
}
}
Global.stateForScreenshot = Global.GameState.Reading;
currentPage = Storage.LoadPage(pageToLoadValue);
takeScreenshot = false;
}
Global.backgroundPositionChange = 0;
Global.pagePositionChange = 0;
drawPage();
spriteBatch.Begin();
spriteBatch.Draw(screenshot, new Rectangle(0, 0, (int)pageTurnPosition.X, 800), new Color(colorRGB, colorRGB, colorRGB));
spriteBatch.Draw(pageTurn, pageTurnPosition, Color.White);
if (pageTurnPosition.X < 250)
{
colorRGB -= (int)turnSpeed;
flipPageSpread += turnSpeed / 2;
spriteBatch.Draw(pageBackground, new Vector2(pageTurnPosition.X - flipPageSpread, 0), new Rectangle(0, 0, (int)flipPageSpread, 800), Color.White);
if (pageTurnPosition.X + 2 - flipPageSpread < pageTurnPosition.X - pageFlipShadow.Width)
spriteBatch.Draw(pageFlipShadow, new Vector2(pageTurnPosition.X - pageFlipShadow.Width, 0), Color.White);
else spriteBatch.Draw(pageFlipShadow, new Vector2(pageTurnPosition.X - flipPageSpread, 0), new Rectangle(0, 0, (int)(flipPageSpread), 800), Color.White);
}

spriteBatch.End();
}

if (Global.state == Global.GameState.Reading || Global.state == Global.GameState.MainMenu || Global.state == Global.GameState.NewGame)
drawPage();
}

base.Draw(gameTime);
}

int startBookPosition = 60;
void drawPage()
{
spriteBatch.Begin();
if (Global.backgroundPositionChange > 800) Global.backgroundPositionChange = 0;
if (Global.backgroundPositionChange < -800) Global.backgroundPositionChange = 0;
spriteBatch.Draw(pageBackground, new Vector2(0, 800 + Global.backgroundPositionChange), Color.White);
spriteBatch.Draw(pageBackground, new Vector2(0, -800 + Global.backgroundPositionChange), Color.White);
spriteBatch.Draw(pageBackground, new Vector2(0, 0 + Global.backgroundPositionChange), Color.White);


int pozycjaPlusImage = 0;
if (currentPage.image != "")
{
spriteBatch.Draw(imageList[currentPage.image], new Vector2(240 - imageList[currentPage.image].Width / 2, startBookPosition + 20 + Global.pagePositionChange), Color.White);
pozycjaPlusImage = 220;
}
spriteBatch.DrawString(firstCharFont, currentPage.caption, new Vector2(25, pozycjaPlusImage + startBookPosition + 20 + Global.pagePositionChange), Color.Black);
spriteBatch.DrawString(bookFont, currentPage.tekst, new Vector2(25, pozycjaPlusImage + startBookPosition + 40 + Global.pagePositionChange), Color.Black);
float decisionPositions = bookFont.MeasureString(currentPage.tekst).Y + pozycjaPlusImage + startBookPosition + 60;
firstDecisionPosition = decisionPositions;
foreach (PageDecisions pd in currentPage.decisions)
{
Color color;
if (!pd.available)
color = Color.Gray;
else
color = Color.Blue;
spriteBatch.DrawString(bookFont, pd.tekst, new Vector2(25, decisionPositions + Global.pagePositionChange), color);
decisionPositions += 60;
}
if ((Global.state == Global.GameState.Reading || Global.stateForScreenshot == Global.GameState.Reading) && Global.maxStamina > 0)
HubEngine.DrawHub(bookFont, spriteBatch, bar, progress, backpack);
if (Global.state == Global.GameState.NewGame || Global.stateForScreenshot == Global.GameState.NewGame)
{
NewGame.DrawPageForNewGame(spriteBatch, bookFont);
}
spriteBatch.End();

}