Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- namespace Hobo_Simulator
- {
- public static class Utils
- {
- public static object TextUtils { get; private set; }
- public static void PrintMessage(string message, int characterDelay, int pauseInMillis)
- {
- //Console.Clear();
- //Console.SetCursorPosition(Console.WindowWidth/2 - message.Length/2, Console.WindowHeight/2);
- for (int i = 0; i < message.Length; i++)
- {
- Console.Write(message[i]);
- Thread.Sleep(characterDelay);
- }
- Thread.Sleep(pauseInMillis);
- //Console.Clear();
- //Console.SetCursorPosition(0, 0);
- }
- public static void PrintBlockMessage(string message)
- {
- PrintBlockMessage(message, Console.CursorLeft, Console.CursorTop, ConsoleColor.White, ConsoleColor.Black);
- }
- public static void PrintBlockMessage(string message, ConsoleColor foregroundColor, ConsoleColor backgroundColor)
- {
- PrintBlockMessage(message, Console.CursorLeft, Console.CursorTop, foregroundColor, backgroundColor);
- }
- public static void PrintBlockMessage(string strMessage, int cursorPosLeft, int cursorPosTop, ConsoleColor foregroundColor, ConsoleColor backgroundColor)
- {
- string[] message = strMessage.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
- // Setting cursor position
- //Console.SetCursorPosition(cursorPosLeft, cursorPosTop);
- // Set color
- Console.ForegroundColor = foregroundColor;
- Console.BackgroundColor = backgroundColor;
- // Longest string length
- int longestStringLength = GetLongestStringLenght(message);
- int messageHeight = longestStringLength;
- int messageX = cursorPosLeft;
- // Loopar tills slutet av textblocket nåtts
- for (int i = 0; i < longestStringLength; i++)
- {
- for (int heightPos = cursorPosTop; heightPos < (message.Length + cursorPosLeft); heightPos++)
- {
- // As long as the string is not shorter than where the cursor is
- if (message[heightPos].Length <= Console.CursorLeft)
- {
- //Console.SetCursorPosition(messageX, heightPos);
- Console.WriteLine(message[heightPos]);
- Thread.Sleep(100);
- }
- // Nästa x-led
- messageX++;
- }
- }
- // * Loopa igenom för hela blockets längd
- // * Loopa för varje y-rad i listan
- }
- /// <summary>
- /// Takes in an array and returns the length of the longest string.
- /// </summary>
- /// <param name="arr">The array of strings to be examinated</param>
- /// <returns></returns>
- ///
- public static int GetLongestStringLenght(string[] arr)
- {
- // Contains the longest string length
- int longest = 0;
- // Looping through the list (array) of strings and measures the lenghts of them.
- // If the current string being examined is longer than what's registered, note that
- // down.
- for (int i = 0; i < arr.Length; i++)
- if (arr[i].Length > longest)
- longest = arr[i].Length;
- // Return the longest string length
- return longest;
- }
- public static void loading()
- {
- Utils.PrintMessage(" ...", 100, 500);
- Console.Clear();
- }
- public static void logoanimation()
- {
- int x_pos = 0;
- int y_pos = 0;
- int position = 0;
- for (position = 0; position < 120; position++)
- {
- Console.SetCursorPosition(x_pos, y_pos + 1);
- Console.WriteLine(" ");
- Console.SetCursorPosition(x_pos, y_pos + 2);
- Console.WriteLine(" _ _ _ _ ");
- Console.SetCursorPosition(x_pos, y_pos + 3);
- Console.WriteLine(" _ |_|_| _ |_|_| ");
- Console.SetCursorPosition(x_pos, y_pos + 4);
- Console.WriteLine(" ___| |_ ___ ___ ___| |_ ___ ___ ");
- Console.SetCursorPosition(x_pos, y_pos + 5);
- Console.WriteLine(" | _| | . | . |_ | _| | . | . |");
- Console.SetCursorPosition(x_pos, y_pos + 6);
- Console.WriteLine(" |___|_|_|___| _| | |___|_|_|___| _|");
- Console.SetCursorPosition(x_pos, y_pos + 7);
- Console.WriteLine(" |_| |_| |_| ");
- Console.SetCursorPosition(10, 10);
- Console.Write(position);
- Thread.Sleep(100);
- x_pos += 1;
- if (position == 119)
- {
- logoanimation();
- }
- }
- Console.Clear();
- position = -120;
- x_pos = -2;
- }
- public static void BlockRevealTopToBottom(string strMessage, int cursorLeftStart, int cursorTopStart, int delayPerFrame)
- {
- StringBuilder blockMessage = new StringBuilder();
- blockMessage.AppendLine(@" _____");
- blockMessage.AppendLine(@" | = |\");
- blockMessage.AppendLine(@" | = | \");
- blockMessage.AppendLine(@" | = | |");
- blockMessage.AppendLine(@" _______| = |__|____");
- blockMessage.AppendLine(@"| = |\");
- blockMessage.AppendLine(@"| =================== | \");
- blockMessage.AppendLine(@"|_______ = _______| |");
- blockMessage.AppendLine(@" \ | = |\ \ |");
- blockMessage.AppendLine(@" \_____| = | \_______\|");
- blockMessage.AppendLine(@" | = | |");
- blockMessage.AppendLine(@" | = | |");
- blockMessage.AppendLine(@" | = | |");
- blockMessage.AppendLine(@" | = | |");
- blockMessage.AppendLine(@" | = | |");
- blockMessage.AppendLine(@" | = | |");
- blockMessage.AppendLine(@" |_____| |");
- blockMessage.AppendLine(@" \ \ |");
- blockMessage.AppendLine(@" \______\|");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement