Advertisement
Guest User

Untitled

a guest
Dec 7th, 2014
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.97 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 IntroComic
  12. {
  13. List<string> txt = new List<string>(15);
  14. public static Color textColor = MainMenu.TEXT_HIGHLIGHT;
  15. int pointer = 0;
  16.  
  17. Range txt2show;
  18. float txtSpeed = 5;
  19.  
  20. Animation button_b;
  21.  
  22. public IntroComic()
  23. {
  24. button_b = TextureManager.buttonB.MakeAnim();
  25.  
  26.  
  27. txt.Add("The world was still fresh from the shock of the\n\"Steamfull\" war which brought about scientific\nprogress...");
  28. txt.Add("but also destroyed infrastructure and killed millions\nof innocent civilians.");
  29. txt.Add("War technologies were adapted to peacetime.\nManufacturing developed and automated factories\nwere opened. Cities had electricity, cars and\nairplanes. The world stepped into the industrial era.");
  30. txt.Add("Albert Steiner, mathematical and physics genius,\nwas finishing his project that could make him famous\nfor ages.");
  31. txt.Add("The project was the development of the differential\nsteam engine (DSE). Albert had recently finished its\nprototype. This DSE was way more powerful than any\nstandard engine and also used less energy.");
  32. txt.Add("Its purpose was to advance agriculture and ease the\nlife of farmers.");
  33. txt.Add("The scientist was so absorbed with his work that he\neven stopped teaching at the university and was\nnever seen outside of his laboratory.");
  34. txt.Add("His daughter Judith Steiner loved tinkering with the\nequipment and she would help him as much as she\ncould.");
  35. txt.Add("The situation in the country was volatile and\nterrorists were plotting against the Fat Queen. The\nworld was waiting for the next war.");
  36. txt.Add("One day, one of the terrorists came to Albert and\noffered a large amount of money for drafts of the\nDSE.");
  37. txt.Add("Albert declined the offer, but the terrorist brandished\na weapon and demanded that he hand over the DSE\ndrafts.");
  38. txt.Add("Albert refused so the terrorist shot him and took the\ndrawings.");
  39. txt.Add("When Judith came home she saw her dad dying. He\nasked her to stop the villain so that his designs would\nnot be used for the wrong purpose. Judith swore she\nwould not let that happen!");
  40. txt.Add("She straddled an experimental steam aircraft she\nand her father had been working on for the last\ncouple of months...");
  41. txt.Add("and chased after the terrorist!");
  42.  
  43. //txt.Add("She known that there is an office of RF in here. So he\nmust go there.");
  44. //
  45.  
  46.  
  47. txt2show = new Range(0, txt[pointer].Length, txtSpeed);
  48. txt2show.growState = Range.GrowState.GROW_UP;
  49.  
  50. }
  51.  
  52. public void Update(GameTime gameTime)
  53. {
  54. if (AnyGamePad.OnButtonDown(Buttons.B) || StarGame.OnKeyDown(Keys.B) || StarGame.OnKeyDown(Keys.Escape))
  55. {
  56. ended = true;
  57. }
  58.  
  59. if (ended)
  60. return;
  61.  
  62. txt2show.Update(gameTime);
  63. if (Input())
  64. {
  65. if (txt2show.IsMax())
  66. {
  67. pointer++;
  68. if (pointer >= txt.Count)
  69. {
  70. pointer--;
  71. ended = true;
  72. }
  73. else
  74. {
  75. txt2show = new Range(0, txt[pointer].Length, txtSpeed);
  76. txt2show.growState = Range.GrowState.GROW_UP;
  77. }
  78. }
  79. else
  80. {
  81. txt2show.SetOnMax();
  82. }
  83. }
  84.  
  85. }
  86. public static Vector2 ramkaPos = new Vector2(256 - 2 - 20, -1);
  87. public static Rectangle doubled = new Rectangle(1280/2 - 640/2, 720/2 - 360/2 - 360/4 - 32, 640, 360);
  88. public void Draw(Camera camera)
  89. {
  90.  
  91.  
  92. // some images used for more then one screen
  93. int img = pointer + 1;
  94. if (img == 1)
  95. img = 1;
  96. else if (img == 2 || img == 3)
  97. img = 1;
  98. else if (img == 4 || img == 5)
  99. img = 2;
  100. else if (img == 6 || img == 7)
  101. img = 3;
  102. else
  103. img -= 4;
  104.  
  105.  
  106. img--;
  107.  
  108.  
  109.  
  110. camera.GetSpriteBatch().Draw(TextureManager.intro_comic_ramka, ramkaPos, Color.White);
  111. camera.GetSpriteBatch().Draw(TextureManager.intro_comic, doubled, new Rectangle(0, 360*img, 640, 360), Color.White);
  112.  
  113. Rectangle rect = new Rectangle(172 + 136 / 2, 720 - 200 - 720 / 10, 804, 200);
  114. camera.GetSpriteBatch().Draw(TextureManager.blackBox64x64.images[0], rect, new Color(1,1,1,0.3f));
  115.  
  116. string out_txt = txt[pointer].Substring(0, (int)txt2show);
  117. Vector2 pos = new Vector2(rect.X + 30, rect.Y + 20);
  118. camera.DrawString(StarGame.monoFont, out_txt, new Vector2(rect.X + 30, rect.Y + 20) + DialogItem.shadowOffset, MainMenu.SHADOW_COLOR);
  119. camera.DrawString(StarGame.monoFont, out_txt, new Vector2(rect.X + 30, rect.Y + 20), textColor);
  120.  
  121. string skippText = "Press to skip intro";
  122. #if WINDOWS
  123. skippText = "Press to skip intro";
  124. #endif
  125. camera.DrawString(StarGame.monoFont, skippText, new Vector2(rect.X + 30, rect.Y + 202) + DialogItem.shadowOffset, MainMenu.SHADOW_COLOR);
  126. camera.DrawString(StarGame.monoFont, skippText, new Vector2(rect.X + 30, rect.Y + 202), textColor);
  127. #if XBOX
  128. camera.Draw(button_b, new Vector2(rect.X + 30 + 64 + 24, rect.Y + 202));
  129. #endif
  130. #if WINDOWS
  131. int size = 64;
  132. int x = 6;
  133. int y = 0;
  134. Rectangle src;
  135. src = new Rectangle(size * x, size * y, size, size);
  136. camera.Draw(TextureManager.klava.images[0], src, new Vector2(rect.X + 30 + 64 + 24 - 2, rect.Y + 202));
  137. #endif
  138. }
  139.  
  140. bool Input()
  141. {
  142. bool mouseSelect = false;
  143. #if WINDOWS
  144. mouseSelect = Mouse.GetState().LeftButton == ButtonState.Pressed && StarGame.oldMouseState.LeftButton == ButtonState.Released;
  145. #endif
  146. return AnyGamePad.OnButtonDown(Buttons.A)
  147. || AnyGamePad.OnRightTriggerDown()
  148. || StarGame.OnKeyDown(Keys.Space)
  149. || StarGame.OnKeyDown(Keys.Z)
  150. || StarGame.OnKeyDown(Keys.Y)
  151. || StarGame.OnKeyDown(Keys.X)
  152. || StarGame.OnKeyDown(Keys.Enter)
  153. || mouseSelect;
  154. }
  155.  
  156.  
  157. bool ended = false;
  158. public bool IsEnded()
  159. {
  160. return ended;
  161. }
  162. }
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement