Advertisement
lightxx

Untitled

Feb 17th, 2013
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.00 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. namespace ConsoleApplication1 {
  9.     class Program {
  10.         static void Main(string[] args) {
  11.         }
  12.         // This method is for waiting for the other players move.
  13.  
  14.         public static string[] WaitForMessage() {
  15.             // Now we start our thread.
  16.             Thread WaitForOtherPlayer = new Thread(WaitForMove);
  17.             Tuple<string, int, int> parameters =  new Tuple<string, int, int>("ich bin ein string", 12, 10);
  18.             WaitForOtherPlayer.Start(parameters);
  19.          
  20.         }
  21.  
  22.  
  23.  
  24.         // And here is the method wich is started in the thread above
  25.         // I would need to give more than one parameter to that method to be able to set the cursor to the richt position.
  26.         // Can I give it an object (for example a tuple convertet to an object) and then convert it back to what it was first?
  27.  
  28.         public static void WaitForMove(object parameters) {
  29.             Tuple<string, int, int> paramTuple = (Tuple<string, int, int>) parameters;
  30.             string ichbinderstring = paramTuple.Item1;
  31.             int ersterinteger = paramTuple.Item2;
  32.             int zweiterinteger = paramTuple.Item3;
  33.             int count = 0;
  34.             ConsoleKeyInfo eingabe;
  35.             do {
  36.                 eingabe = Console.ReadKey(true);
  37.                 Console.CursorVisible = false;
  38.                 Console.SetCursorPosition(ersterinteger, zweiterinteger);  // How can I set the right position for the message without knowing the height of the gamefield??
  39.                 string output = string.Format("Warte, seit {0} Sekunden, dass \"{1}\" seinen Zug macht...", count, ichbinderstring);
  40.                 Console.ForegroundColor = ConsoleColor.White;
  41.                 Console.Write(output);
  42.                 Thread.Sleep(1000);
  43.                 count++;
  44.             }
  45.             while (eingabe.Key != ConsoleKey.Escape);
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement