예제 #1
0
 public PartyTimer(Party pa)
 {
     this.pa = pa;
     ci      = new ConsoleInput();
     Thread myThread = new Thread(new ThreadStart(ci.Start_input_reading));
 }
예제 #2
0
        public void StartConfiguration(ConsoleInput ci)
        {
            string ins = "";

            while (ins != "start" && pa.PlayersCount < 2 && pa.PlayersCount % 2 != 0)
            {
                ins = ci.read_next_msg();
                if (ins == "")
                {
                    Thread.Sleep(1000);
                }
                string[] insp = ins.Split(' ');
                switch (insp[0])
                {
                case "gametype":
                    if (insp.Length > 1)
                    {
                        set_game_type(insp[1]);
                    }
                    else
                    {
                        Console.WriteLine("GameType: " + pa.Gametype.GetType());
                    }
                    break;

                case "ip":
                    if (insp.Length > 1)
                    {
                        setip(insp[1]);
                    }
                    else
                    {
                        Console.WriteLine("IP: " + pa.Ip);
                    }
                    break;

                case "port":
                    if (insp.Length > 1)
                    {
                        setport(insp[1]);
                    }
                    else
                    {
                        Console.WriteLine("port: " + pa.Port);
                    }
                    break;

                case "nb_players":
                    if (insp.Length > 1)
                    {
                        setnb_players(insp[1]);
                    }
                    else
                    {
                        Console.WriteLine("nb_players: " + pa.PlayersCount + "   total players: " + pa.Slot);
                    }
                    break;

                case "start":
                    return;

                    Console.WriteLine("It seems that some parametre are invalides");
                    Console.WriteLine("Use 'rest' to rest the parametre...");
                    break;

                case "rest":
                    pa.Gametype = Party.GameType.Server_Hosting;
                    pa.Ip       = IPAddress.Parse("127.0.0.1");
                    pa.Port     = 65555;
                    pa.ClearPlayers();
                    Console.WriteLine("Rest Sucess Full");
                    break;

                default:
                    Console.WriteLine("Sorry, it is not legible");
                    help();
                    break;
                }
            }

            if (ins == "stop")
            {
                Program.finish = true;
            }
        }