Advertisement
Guest User

Untitled

a guest
Dec 7th, 2014
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.Xna.Framework;
  4. using Microsoft.Xna.Framework.Graphics;
  5. using Microsoft.Xna.Framework.Input;
  6.  
  7.  
  8.  
  9. namespace StarAttack
  10. {
  11. public class EndComic
  12. {
  13. List<string> txt = new List<string>(15);
  14. List<Texture2D> img = new List<Texture2D>(15);
  15. int pointer = 0;
  16.  
  17. Range txt2show;
  18. float txtSpeed = 5;
  19.  
  20. private static EndComic INSTANCE = null;
  21. Timer question = new Timer();
  22.  
  23. public static EndComic GetInstance()
  24. {
  25. if (INSTANCE == null)
  26. {
  27. INSTANCE = new EndComic();
  28. }
  29. return INSTANCE;
  30. }
  31.  
  32. private EndComic()
  33. {
  34.  
  35. img.Add(TextureManager.end_comic_1);
  36. img.Add(TextureManager.end_comic_2);
  37. img.Add(TextureManager.end_comic_3);
  38. img.Add(TextureManager.end_comic_4);
  39. img.Add(TextureManager.end_comic_5);
  40. img.Add(TextureManager.end_comic_6);
  41. img.Add(TextureManager.end_comic_7);
  42. img.Add(TextureManager.end_comic_8);
  43.  
  44.  
  45. txt.Add("In an unequal struggle Judith still managed to win over\nthe huge steam battleship of the Queen and disrupted\nher plans to start a war.");
  46. txt.Add("The Fat Queen and her servants were caught and jailed.\nAnd though tyranny was defeated and the war was\naverted, it could not bring back the people - victims\nof the purges and repressions.");
  47. txt.Add("One of these people was the father of Judith, Albert\nSteiner. The whole country joined the final journey of\nthe scientist. His rueful friend also was at the\nfuneral.");
  48. txt.Add("However the dream and the lifework of the scientist\ncame true: the DSE technology became a national\nproperty, and a Technical University named after\nAlbert was opened in the capital city. Unfortunately\nhe did not have a chance to see this.");
  49. txt.Add("The throne was inherited by the son of the Fat Queen,\nprince Slonovich. And although his mother could not be\ncalled the most philanthropic ruler, he himself had\nreformatory views. People's lives were improved during\nhis reign and the effects of exploitation were undone.");
  50. txt.Add("The left leaning terrorist organization, which was\nstruggling against the Fat Queen's regime, could not\nignore these better times, and through a series of\nconcessions from the King Slonovich, it self-disbanded.");
  51. txt.Add("Judith became a popular favorite, and thanks to her\nexcellent pilot skills she began to serve the new King\nin an elite squadron.");
  52. txt.Add("But who knows what else her fate might have in store\nfor her.\n\n THE END.");
  53.  
  54.  
  55.  
  56.  
  57.  
  58. txt2show = new Range(0, txt[pointer].Length, txtSpeed);
  59. txt2show.growState = Range.GrowState.GROW_UP;
  60.  
  61. if (txt.Count != img.Count)
  62. throw new Exception("Somthing wrong here. txt no " + txt.Count + " img no " + img.Count);
  63. }
  64.  
  65. public void Update(GameTime gameTime)
  66. {
  67. question.Update(gameTime);
  68.  
  69. if (ended)
  70. return;
  71.  
  72. txt2show.Update(gameTime);
  73. if (Input())
  74. {
  75. if (txt2show.IsMax())
  76. {
  77. pointer++;
  78. if (pointer >= txt.Count)
  79. {
  80. pointer--;
  81. ended = true;
  82. }
  83. else
  84. {
  85. txt2show = new Range(0, txt[pointer].Length, txtSpeed);
  86. txt2show.growState = Range.GrowState.GROW_UP;
  87.  
  88. if (pointer == txt.Count - 1)
  89. {
  90. question.ScheduleAction(() =>
  91. {
  92. string lolka = "..........?";
  93. txt[txt.Count - 1] += lolka;
  94. txt2show.SetMax(txt2show.GetMax() + lolka.Length);
  95. }, 7 * 1000);
  96.  
  97. }
  98. }
  99. }
  100. else
  101. {
  102. txt2show.SetOnMax();
  103. }
  104. }
  105.  
  106. }
  107. public void Draw(Camera camera)
  108. {
  109. camera.GetSpriteBatch().Draw(TextureManager.intro_comic_ramka, IntroComic.ramkaPos, Color.White);
  110. camera.GetSpriteBatch().Draw(img[pointer], IntroComic.doubled, Color.White);
  111. Rectangle rect = new Rectangle(172 + 136 / 2, 720 - 200 - 720 / 10, 824, 200);
  112. camera.GetSpriteBatch().Draw(TextureManager.blackBox64x64.images[0], rect, new Color(1, 1, 1, 0.3f));
  113.  
  114. string out_txt = txt[pointer].Substring(0, (int)txt2show);
  115. Vector2 pos = new Vector2(rect.X + 30, rect.Y + 20);
  116. camera.DrawString(StarGame.monoFont, out_txt, new Vector2(rect.X + 30 - 16, rect.Y + 20) + DialogItem.shadowOffset, DialogItem.shadowColor);
  117. camera.DrawString(StarGame.monoFont, out_txt, new Vector2(rect.X + 30 - 16, rect.Y + 20), IntroComic.textColor);
  118.  
  119. }
  120.  
  121. bool Input()
  122. {
  123. bool mouseSelect = false;
  124. #if WINDOWS
  125. mouseSelect = Mouse.GetState().LeftButton == ButtonState.Pressed && StarGame.oldMouseState.LeftButton == ButtonState.Released;
  126. #endif
  127. return mouseSelect || AnyGamePad.OnButtonDown(Buttons.A) || AnyGamePad.OnRightTriggerDown() || StarGame.OnKeyDown(Keys.Space) || StarGame.OnKeyDown(Keys.Enter) || StarGame.OnKeyDown(Keys.Z) || StarGame.OnKeyDown(Keys.X) || StarGame.OnKeyDown(Keys.Y);
  128. }
  129.  
  130.  
  131. bool ended = false;
  132. public bool IsEnded()
  133. {
  134. return ended;
  135. }
  136. }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement