Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7.  
  8.  
  9. namespace Hobo_Simulator
  10. {
  11. public static class Utils
  12. {
  13.  
  14. public static object TextUtils { get; private set; }
  15.  
  16. public static void PrintMessage(string message, int characterDelay, int pauseInMillis)
  17. {
  18. //Console.Clear();
  19. //Console.SetCursorPosition(Console.WindowWidth/2 - message.Length/2, Console.WindowHeight/2);
  20.  
  21. for (int i = 0; i < message.Length; i++)
  22. {
  23. Console.Write(message[i]);
  24. Thread.Sleep(characterDelay);
  25. }
  26. Thread.Sleep(pauseInMillis);
  27.  
  28. //Console.Clear();
  29. //Console.SetCursorPosition(0, 0);
  30. }
  31.  
  32.  
  33. public static void PrintBlockMessage(string message)
  34. {
  35. PrintBlockMessage(message, Console.CursorLeft, Console.CursorTop, ConsoleColor.White, ConsoleColor.Black);
  36. }
  37.  
  38. public static void PrintBlockMessage(string message, ConsoleColor foregroundColor, ConsoleColor backgroundColor)
  39. {
  40. PrintBlockMessage(message, Console.CursorLeft, Console.CursorTop, foregroundColor, backgroundColor);
  41. }
  42.  
  43. public static void PrintBlockMessage(string strMessage, int cursorPosLeft, int cursorPosTop, ConsoleColor foregroundColor, ConsoleColor backgroundColor)
  44. {
  45. string[] message = strMessage.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
  46.  
  47. // Setting cursor position
  48. //Console.SetCursorPosition(cursorPosLeft, cursorPosTop);
  49.  
  50. // Set color
  51. Console.ForegroundColor = foregroundColor;
  52. Console.BackgroundColor = backgroundColor;
  53.  
  54. // Longest string length
  55. int longestStringLength = GetLongestStringLenght(message);
  56.  
  57. int messageHeight = longestStringLength;
  58.  
  59. int messageX = cursorPosLeft;
  60.  
  61. // Loopar tills slutet av textblocket nåtts
  62. for (int i = 0; i < longestStringLength; i++)
  63. {
  64. for (int heightPos = cursorPosTop; heightPos < (message.Length + cursorPosLeft); heightPos++)
  65. {
  66. // As long as the string is not shorter than where the cursor is
  67. if (message[heightPos].Length <= Console.CursorLeft)
  68. {
  69. //Console.SetCursorPosition(messageX, heightPos);
  70. Console.WriteLine(message[heightPos]);
  71. Thread.Sleep(100);
  72. }
  73. // Nästa x-led
  74. messageX++;
  75. }
  76.  
  77. }
  78.  
  79. // * Loopa igenom för hela blockets längd
  80. // * Loopa för varje y-rad i listan
  81.  
  82. }
  83. /// <summary>
  84. /// Takes in an array and returns the length of the longest string.
  85. /// </summary>
  86. /// <param name="arr">The array of strings to be examinated</param>
  87. /// <returns></returns>
  88. ///
  89.  
  90.  
  91. public static int GetLongestStringLenght(string[] arr)
  92. {
  93. // Contains the longest string length
  94. int longest = 0;
  95.  
  96. // Looping through the list (array) of strings and measures the lenghts of them.
  97. // If the current string being examined is longer than what's registered, note that
  98. // down.
  99. for (int i = 0; i < arr.Length; i++)
  100. if (arr[i].Length > longest)
  101. longest = arr[i].Length;
  102.  
  103. // Return the longest string length
  104. return longest;
  105. }
  106.  
  107.  
  108. public static void loading()
  109. {
  110. Utils.PrintMessage(" ...", 100, 500);
  111. Console.Clear();
  112. }
  113.  
  114. public static void logoanimation()
  115. {
  116. int x_pos = 0;
  117. int y_pos = 0;
  118. int position = 0;
  119.  
  120. for (position = 0; position < 120; position++)
  121. {
  122. Console.SetCursorPosition(x_pos, y_pos + 1);
  123. Console.WriteLine(" ");
  124. Console.SetCursorPosition(x_pos, y_pos + 2);
  125. Console.WriteLine(" _ _ _ _ ");
  126. Console.SetCursorPosition(x_pos, y_pos + 3);
  127. Console.WriteLine(" _ |_|_| _ |_|_| ");
  128. Console.SetCursorPosition(x_pos, y_pos + 4);
  129. Console.WriteLine(" ___| |_ ___ ___ ___| |_ ___ ___ ");
  130. Console.SetCursorPosition(x_pos, y_pos + 5);
  131. Console.WriteLine(" | _| | . | . |_ | _| | . | . |");
  132. Console.SetCursorPosition(x_pos, y_pos + 6);
  133. Console.WriteLine(" |___|_|_|___| _| | |___|_|_|___| _|");
  134. Console.SetCursorPosition(x_pos, y_pos + 7);
  135. Console.WriteLine(" |_| |_| |_| ");
  136. Console.SetCursorPosition(10, 10);
  137. Console.Write(position);
  138.  
  139. Thread.Sleep(100);
  140. x_pos += 1;
  141. if (position == 119)
  142. {
  143. logoanimation();
  144. }
  145. }
  146. Console.Clear();
  147. position = -120;
  148. x_pos = -2;
  149. }
  150.  
  151. public static void BlockRevealTopToBottom(string strMessage, int cursorLeftStart, int cursorTopStart, int delayPerFrame)
  152. {
  153.  
  154. StringBuilder blockMessage = new StringBuilder();
  155. blockMessage.AppendLine(@" _____");
  156. blockMessage.AppendLine(@" | = |\");
  157. blockMessage.AppendLine(@" | = | \");
  158. blockMessage.AppendLine(@" | = | |");
  159. blockMessage.AppendLine(@" _______| = |__|____");
  160. blockMessage.AppendLine(@"| = |\");
  161. blockMessage.AppendLine(@"| =================== | \");
  162. blockMessage.AppendLine(@"|_______ = _______| |");
  163. blockMessage.AppendLine(@" \ | = |\ \ |");
  164. blockMessage.AppendLine(@" \_____| = | \_______\|");
  165. blockMessage.AppendLine(@" | = | |");
  166. blockMessage.AppendLine(@" | = | |");
  167. blockMessage.AppendLine(@" | = | |");
  168. blockMessage.AppendLine(@" | = | |");
  169. blockMessage.AppendLine(@" | = | |");
  170. blockMessage.AppendLine(@" | = | |");
  171. blockMessage.AppendLine(@" |_____| |");
  172. blockMessage.AppendLine(@" \ \ |");
  173. blockMessage.AppendLine(@" \______\|");
  174.  
  175.  
  176. Console.ReadKey();
  177. }
  178. }
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement