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 ConsoleApplication1 {
- class Program {
- static void Main(string[] args) {
- }
- // This method is for waiting for the other players move.
- public static string[] WaitForMessage() {
- // Now we start our thread.
- Thread WaitForOtherPlayer = new Thread(WaitForMove);
- Tuple<string, int, int> parameters = new Tuple<string, int, int>("ich bin ein string", 12, 10);
- WaitForOtherPlayer.Start(parameters);
- }
- // And here is the method wich is started in the thread above
- // I would need to give more than one parameter to that method to be able to set the cursor to the richt position.
- // Can I give it an object (for example a tuple convertet to an object) and then convert it back to what it was first?
- public static void WaitForMove(object parameters) {
- Tuple<string, int, int> paramTuple = (Tuple<string, int, int>) parameters;
- string ichbinderstring = paramTuple.Item1;
- int ersterinteger = paramTuple.Item2;
- int zweiterinteger = paramTuple.Item3;
- int count = 0;
- ConsoleKeyInfo eingabe;
- do {
- eingabe = Console.ReadKey(true);
- Console.CursorVisible = false;
- Console.SetCursorPosition(ersterinteger, zweiterinteger); // How can I set the right position for the message without knowing the height of the gamefield??
- string output = string.Format("Warte, seit {0} Sekunden, dass \"{1}\" seinen Zug macht...", count, ichbinderstring);
- Console.ForegroundColor = ConsoleColor.White;
- Console.Write(output);
- Thread.Sleep(1000);
- count++;
- }
- while (eingabe.Key != ConsoleKey.Escape);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement